• Day 2 (Part 1) - Power, Breadboarding, User Interface

    scott.mcgimpsey08/26/2019 at 21:00 0 comments

    [Update: I've uploaded the code discussed in this post to the project page.]

    I've added the headers to the Oak. If I want to use this specific module on my prototype, I can just pop some male headers on the protoboard for the board to plug into. I'm a bit short on headers at the moment, but I'm sure I can scrounge up enough to make do for this board. Programming is a lot easier this way anyhow.

    Since the WS2812B uses 5v for power and communication, and the Oak uses 3.3v, I'll be using the Oak's 5v->3.3v voltage regulator to power the ESP8266 (built in already) and as the voltage reference for the logic shifter. The WS2812B will take straight 5v from the USB supply.  Typical USB ports off a computer offer 500mA on the high end. I'll use this as my low-bar for supplied power, as most USB Power supplies and batteries offer more than this. The NeoPixel (brand name of WS281x series) guide over at Mouser offers a quick rule of thumb estimate of 20mA for standard operation, and 60mA peak per RGB LED. Apparently the logic circuitry on the chip consumes very little power.

    For the ESP8266 , this Espressif page lists the highest current draw of the in a series of tests at being 170mA. I have a 470ohm pull-down resistor on the 3.3v side of the logic shifter, so that's another 7mA consumed. The Voltage Regulator on the Oak is rated for 500mA, so no issues there. All in, that's around (5v * 60mA) + (3.3v * 170mA) + (3.3v * 7mA) = 884.1mW power draw, and a theoretical 2500mW supply. Plenty of wiggle room, though I may add a capacitor across the 5v line to buffer the supply, mostly for fun. I spent a few minutes looking for my USB inline power indicator, but couldn't find it for the life of me. Once I find it I will check and share my back-of-the-napkin against real-world measurements.


    Breadboarding the circuit took a few minutes longer than expected. I was able to write code to the ESP8266 without trouble, but was having issues getting communication to work between the Oak and the WS2812B. I eventually found that the logic shifter needed that pulldown resistor, (must not be included on the circuit side of the ESP or Oak) and that the LED required the 400kHz communication option to be set instead of the 800kHz. 

    Now that I have the circuit wired up, I've got a nice little flow for coding, testing, and updating the code. I was able to get the WS2812B test code to run alongside the vanilla Wifi Configuration code. After that, I found a quick example of a WebUI which toggles pin states, and used that as a template for my implementation. I'm not in love with the implementation, but I'm a big fan of getting the "Functionally Adequate" version to work, then refining the output.

    After playing around with the HTML and CSS for a bit, and some of the logic, I have the device updating the state variable (Safe, Caution, Unsafe) whenever the user passes a Get request for a the /state/{state goes here}. I can use this as a call method later from a control device. For the web-ui, there's 3 buttons to set the different states, and the current state indicated on the page, along with some helper text. The state does not survive a reboot (intentionally, at the moment as I expect the person changing the state to be the most unreliable element of the flow -- I can implement in EEPROM memory later if I decide to alter my workflow), so when the device first boots up it holds an "unknown" state (blue on the LED), and suggests manually evaluating the situation before attempting to enter.

    [Tom Nardi] made a very good point about the dangers of telling a significant other (my wife, in this case) where they can and can't go, so I may soften up the language a bit. Remember, safety first!

    Next up I'll need to transfer all of these parts from the breadboard to some protoboard so I can do some field-testing to figure out where changes need to be made and features added. I'm already starting...

    Read more »

  • Day 1 - Requirements, Parts, and Probes

    scott.mcgimpsey08/25/2019 at 03:23 0 comments

    I started out by putting together a rough sketch of what this thing is supposed to do and what it might look like. Some of the requirements are bound to change as I think more about the users (myself and my wife) and how I can optimize communication without creating MORE distractions.

    After I put this together, I started rummaging through my parts drawers to figure out what I was going to build this out of. The parts I landed on for the build were:

    • A Digistump Oak (ESP8266 with 5v VREG and MicroUSB)
    • A single WS2821B NeoPixel on breakout board
    • A logic level shifter (for the 3.3 to 5v communication)
    • A 1000uF capacitor (for power stability)

    The concept was to have the ESP host a simple WebUI which shows the current status and provides buttons to change the status. As the status changes, the LED changes colors to match the status. 

    I hunted down my FTDI 3.3v cable (the MicroUSB on the Digistump Oak is for power only -- it does not provide a programming interface) and started pulling up all the documentation for the pinout of the Oak and the board support for the ESP8266 in the Arduino IDE.

    One of my favorite features of WiFi IoT devices I've come across is when an unconfigured device hosts an access point for setup. No nonsense apps to download off the Play Store -- just a simple as pie web interface to configure the wireless settings on the device. Thankfully, [tzapu] has already made WiFi Manager -- a nice little package to do just this. At this point, I spent a LOT of time fiddling with little logic probe clips and jumper cables to try to get a solderless programming connection. It was a disaster -- The clips are likely lovely for pins, but for through-holes, it was a constant fight to keep them from popping off with the slightest movement. 

    I eventually got it to work long enough to write out the program, but I believe I'll have to experiment with a different type of clip, or maybe pogo pins next time around.

     I managed to get vanilla Wifi Config up and running, and was able to join the ESP8266 to my home network. Next time, I'll solder some headers to the Oak, and get some example libraries for the WS2812B.