YIPPEE!! I’ve been getting great replies on my UART0 question at the MicroPython forum.  I’m thinking about hardware versus software UARTs and the Arduino/MicroPython environments.  I like the use of SoftwareSerial when the hardware supports only one hardware UART.  Yes, I can use WebREPL but it does not truly displace the ease of dedicating the hardware UART to programming and other serial access needs.  I think I will explore this route if “one last thing” doesn’t work (here is where I feel myself waisting time but it is like overeating – just can’t stop!!!).

Check out these awesome replies on the MicroPython forum:


Reading UART0 bytes from RX

Postby happyday » Sat Jan 21, 2017 7:28 am

I have a CO2 sensor that uses a UART. The only UART that seems available is UART0. I am running MicroPython from WebREPL so the CO2 sensor can use the UART.
I create a main.py and upload. The gasdata has the right return bytes from the CO2 sensor (verified with a logic analyzer):

from machine import UART
if __name__ == ‘__main__’:
uart = UART(0,9600) 
for value in gasdata:

DOESN’T WORK (bytes in gasdata are all = 0):

from machine import Timer
from machine import UART
def getReadings():
co2 = UART(0,9600) 
gasdata = bytearray(9)
for value in gasdata:
def takeReadings():

if __name__ == ‘__main__’:
t = Timer(1)
t.init(period=5000,mode=Timer.PERIODIC,callback=lambda t:takeReadings())

What am I missing to be able to get the correct bytes read and into gasdata? (what am i not understanding?)

thank you.





OK…one last try…maybe a timeout occurs after reading and the bytes in the UART registers go poof before getting into the gasdata buffer?  Maybe I don’t know what I’m talking about (maybe?  “-) )…. 

 Sadly, I ended up running pretty much what I did yesterday…

from machine import Timer

def getReading():

    from machine import UART

    co2 = UART(0,9600

    gasdata = bytearray(9)



    for value in gasdata:


def takeReading():



if __name__ == ‘__main__’:

    t = Timer(1)

    t.init(period=5000,mode=Timer.PERIODIC,callback=lambda t:takeReading())

didn’t work. But what the heck…why not try to see if I can get this person’s software serial to work? …I feel a camaraderie with this person…I mean…why not (well – because at some point…or besides family, learning this stuff brings an incredible joy…yah – I’ll take that explanation for now 🙂 ).

YIPPEE! I approach installing a Linux Virtual Machine with just a tad of delight.  Because I am taken back to the joyful time when I was taking Contextual Electronics and Eric and Ron made this stuff so easy.  Can I get this stuff to work today based on that this person has written up and their code?….a challenge…a puzzle…the game is afoot…

OK…first take a step back…what do I need to do?  I need to

  • get to a MicroPython build (c files and goo) that includes the software serial code.
  • Compile the code into a binary.
  • Copy the binary onto the D1.


  • Get some coffee and feed the dogs.
  • Do breathing exercises and relax.
  • Take heed of the warning at the end of the thread: “I would recommend that anyone who wants to integrate this code into their own projects should do more thorough testing for special use cases.”
  • Check thread to get link to latest GitHub where the MicroPython fork with machine.SoftUART extension can be downloaded and download.
  • Do breathing exercises and relax.
  • Build MicroPython…as noted: “This firmware can be built according to Adafruit’s helpful Feather HUZZAH guide (https://learn.adafruit.com/building-and … d-firmware) if you substitute this repo instead of the one included on the vagrant VM.”
  • Do breathing exercises and relax.
  • Update the MicroPython Firmware on the D1 to this build.
  • Do breathing exercises and relax.
  • Test (and optimistically be happy.  OK,,,even if this doesn’t work be happy/be kind 🙂 ).
  • Walk the dogs.

Getting Ready To Compile MicroPython

Given what the Adafruit post says, compiling will take place within an Ubuntu VM.  So first thing is to install an Ubuntu VM.

I had an older virtual machine installed from my Contextual Electronics days.  I watched on older video from the course where Chris walked through removing an older VM.  Steps:

  • open a terminal window at the root where the VM is located.
  • type vagrant destroy at the prompt.
This seemed to work.  Now I’m going to follow Adafruit’s steps.
  • I created and navigated to /Users/margaret/MicroPython
  • Ran the command line stuff Adafruit has to load up the VM.
  • Ran the command vagrant ssh
  • OOPSY…I just ran the MicroPython from the the GitHub location Adafruit’s steps pointed to and not this persons.  (ACTUALLY NO…I just installed the Ubuntu VM)
  • let’s see I’ll try getting rid of the vagrant install….did a vagrant destroy in the folder then deleted the subfolder under MicroPython. (DUMB)
  • The GitHub location I’ll clone is here
  • OOPSY…DUMB…Go  back to getting Ubuntu VM from the Adafruit’s GitHub Code.  Reran these steps and now have a Ubuntu VM.  VM installed and ready to go

Build MicroPython

  • Start a VM session.

$ vagrant ssh

Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-61-generic x86_64)


 * Documentation:  https://help.ubuntu.com/


 System information disabled due to load higher than 1.0


  Get cloud support with Ubuntu Advantage Cloud Guest:



0 packages can be updated.

0 updates are security updates.


New release ‘16.04.1 LTS’ available.

Run ‘do-release-upgrade’ to upgrade to it.




now here’s the problem.  The Vagrant install by Adafruit copies the ESP open SDK into the VM since the VM has it’s own file system.  The challenge is to build the other MicroPython build…I’m asking a question on the MicroPython forum because I am not sure of a few things.  Basically, I’m clueless on getting compiling “right.”

…back to the relays….

The Relays

The 4 channel relay board came in.  Time to give it a twirl.


  • Test the DC side of it by not hooking up the VAC end.
  • Hook up the pump.
  • Use WebREPL to turn the pump on/off.

Test the DC Side

I’ll hook the D1 to the relay using the wiring given in this diagram:


Hooked up to D1’s GND, 5V, and pin 5.  I used pin 5 based on the note on GPIO Pins: “Not all pins are available to use, in most cases only pins 0, 2, 4, 5, 12, 13, 14, 15, and 16 can be used.”

Pasted Image 1 22 17 7 33 AM 


Plugged the D1 into the Mac’s USB port.  Light went on the D1 but no LED light on the relay board. Perhaps there just isn’t one.  I feel “better” when I plug something in if an LED lights up.  With that said, I sure hope this little experiment doesn’t blow up my Mac.

Running MicroPython

I started by getting rid of main.py since this had the timer code I was playing around with:

>>> import os

>>> os.listdir()

[‘boot.py’, ‘webrepl_cfg.py’, ‘main.py’]

>>> os.remove(‘main.py’)

>>> os.listdir()

[‘boot.py’, ‘webrepl_cfg.py’] 


Hmmm…I thought using the pins would be simple… My challenge:

>>> import machine                                                                        

>>> pin = machine.Pin(13, machine.Pin.IN)                                                 

>>> pin.value()                                                                           


>>> pin.low()                                                                             

>>> pin.value()                                                                           


>>> pin.high()                                                                            

>>> pin.value()                                                                           


I don’t seem to be able to toggle the i/o pin.  So the steps I’ll take:

  • Figure out the D1 R1 pin out to use when instantiating a Pin in MicroPython

Here’s the Wemos board:

Check this comment out from here:


Simpson DOHKnow What I am Buying Before Buying

I got the WeMos as an impulse buy from Amazon.com on a day I wanted to play around with an esp8266.  I should have known better.  Yet, I insist on banging my head over and over again.


You know what?  Perhaps this is impulsive. But I’m going to stop the madness and do this:


I actually enjoy supporting Adafruit.  Great learning, great support, confident in product quality, Folks from top on down are totally impressive.

So much for the Grove Base…

I live on the west coast so deliver from Adafruit is S-L-O-W…this time I’m trying USPS Priority Mail.  I have good luck with Priority mail when I send packages to my kid at her college on the East Coast…so…


For now, stopping MicroPython using the Wemos D1 R1 board.  I’m excited to give a more robust MicroPython environment a twirl.  I’m less excited to be practicing patience.  But such as it is.

The CO2 Sensor

You know one thing I’ve been thinking about?  What about using a different CO2 circuit?  So I’m coming around to looking at the CCS811 (data sheet).  I looked briefly at this air quality sensor a bit ago and had purchased one on Tindie from Matthew Kerley.  Unfortunately, I was not able to get the BoB to work.  I’m taking a closer look…

Here’s a picture of Matthew’s BoB:


A picture of how the pins are defined:


And a picture of the schematic:




 Here’s pictures of the BoB I received:

NewImage          NewImage

 hhmmm…why should this work?  It says in the data sheet: “Pins 4 and 5 must be connected together.”  They don’t seem to be.  Also, “nRESET […which is pin 2…] is optional but external 4.7KΩ pull-up and/or decoupling of the nRESET pin may be necessary to avoid erroneous noise-induced resets.”


So you know what?  I’m going to build a CCS811 BoB and base it on the schematic / layout in this CCS811 document.


Here’s the schematic:


and here’s the layout:


look at that…the BoB includes a temperature and relative humidity sensor.


Well, that’s it for today.  A lot of fun.  Not sure on the progress.