Monthly Archives: May 2018

Provisioning and using the ESP8266 controller

The ESP8266 controller is preprogrammed with the ability to connect to your local wifi network and be remotely controlled.

Provisioning

Initially, the controller does not know how to connect to your network, so it sets up its own network. Here is how to set it up:

  • Using your phone/laptop/tablet, connect to the network named something like “EDP_1002170403”. The password is the same as name of the node.
  • One you are connected, open up your browser and navigate to http://192.168.4.1. That should enter the provisioning page. Enter the SSID of your wireless network and the password, and click on connect.
  • If everything is working correctly, that will connect to your wireless network. You can find out the IP address by looking for the “EDP_…” name in your browser’s host table, or you can hook the esp board up to your computer and watch what it writes out the serial port when it boots.
  • Controlling via http

    You can control the LEDs via http by sending textual commands to controller. The format looks like this:

    http://[ip address]/message?content=[message]

    Controlling vs UDP

    If you want realtime control of the LEDs, http may have too much latency, which may result in unexpected pauses. The controller also supports communicating through UDP.

    To connect via UDP, use the same IP address and pass commands directly. The internal controller code runs at 100 Hz; if you drive with UDP messages at 60 Hz everything should just work great.

    Supported Messages

    All commands are three letters long, followed by another character (the examples use an underscore (“_”), followed by numeric parameters.

    The following commands are supported:

    Alternate

    Alternate between two colors.

    alt_r1,g1,b1,r2,g2,b2,time

    r1, g1, b1: the rgb values (0,255) for the first color (0-255)
    r2, b2, b2: the rgb values for the second color
    time: the time for each color

    Example: alt_0,100,000,000,000,000,250


    Blend to

    Blend from the current color to a specified color

    rgb_r,g,b,time

    r, g, b: the rgb values (0,255) for the new color
    time: the time for the blend

    Example: rgb_255,255,255,1000

    Color rotate

    Rotate through a bunch of different colors.

    col_speed,brightness

    speed: the speed of the rotate
    brightness: The brightness of the colors

    Example: col_5000,200

    Flash decay

    fdc_decay,min,max

    decay: the speed of the decay
    min: the minimum pause before the next flash
    max: the maximum pause before the next flash

    Example: fdcx250,10,500

    Full control

    Full control is used to control the color of all the leds directly.

    ind_chunk,data-bytes

    chunk: the number of leds to apply each set of data to.
    data-bytes: colors express as two digit HEX values in the format RRGGBB

    Example: ind_011,000044440000004400

    Each color in data-bytes will apply to 11 LEDs. The data-bytes contain 3 color values:

    000044 – a blue value
    440000 – a red value
    000044 – a green value



    DLE (Globes of Fire) Part 4

    It’s been very long since my last update, and a fair bit has happened.

    Hardware:

    I did a rev 1.2 of the board and sent them off to allpcb for a small run (10 IIRC, so 120 of the LED boards and 15 of the end boards).

    The boards showed up quickly, and didn’t work. Well, two of the LEDs worked sometimes, but the third would not.

    Clever me, I did some led moving and I managed to route the VCC line for LED #2 right across the data out pad when I did some moving. I could break the pad by hand and get them to work, which through trying to be quick led me creating a circuit that would work for all the colors except white because I didn’t break the trace completely. Which led me to think a new real of LEDs was bad and waste a couple of days trying to track down what was going on.

    I took the opportunity to do rev 1.3:

    image

    I bumped the VCC and ground tracks up in size, redid the VCC routing, and just generally cleaned things up to be nicer. I also added (finally) a 100 nF decoupling capacitor to the right of the #1 LED, which should help eliminate glitches in the future.

    I spun a small verification order (3) through OSHPark because it was only $5, and those worked great. After that, I pulled out my little list of material costs, went back to reprice the PCBs, and found that JLCPCB would do my full first order for $83 delivered, which was about 30% less than the $120 I had written down. Given the temporary nature of PCB special deals, I put that order in, and today found this on my doorstep:

    IMG_9215

    Well, technically they were in a *box* on my front porch. That is 600 of the LED facets in the two bags at the top and 50 of the top facet in the small box. And the two pretty purple boards are the test ones from OSHPark.

    Assembly

    I’ve gotten pretty good at soldering the LEDs on the facets, but my plan all along was to reflow them. Towards that, I picked up a few things:

    That’s a nice little Black & Decker TO1313SBD toaster oven.

    And:

    That’s a Controleo3 toaster oven conversion kit. We’re going to hot-rod that oven, adding a full computer control to it (the blue board on the left), add an extra heating element, a lot of insulation, and even a servo to open the door.

    All of this will give me a reflow oven; you can put a board with solder paste and components on it, hit a button, and it will heat the board at a certain rate until the solder melts and then cool them down at an appropriate rate. It’s going to live under the garage near the laser cutter, and my guess is that I’m going to need a bit of ventilation for it.

    Firmware

    I am at what I think is the V1 firmware, for approximately the third time. This took a whole lot of time and effort, with the usual fun of running two different codebases on two microcontrollers connected over USB.

    Provisioning

    The first time setup for IoT devices can be a bit of a pain, as they have to get your wireless ssid and password. In playing around, I found that iOS doesn’t let you enumerate wireless networks or change connections programmatically, which meant it might be a real pain to set up multiple nodes by hand.

    Then, I had a small bit of insight, and realized that I already had a device that could easily enumerate all the wireless networks; the ESP can do that an I already had the code because I needed it for testing. It was merely a matter of grafting it onto the existing code.If you connect to the network for any node and give it an SSID and password, it will verify that it works and then pass it off to all of the other nodes so that they can auto-configure. That code is all done, and it’s pretty cool to watch because the current firmware shows the state of the connection by flashing. Okay, maybe that’s only a little cool.

    Animation

    I wrote a few of the simple animations that I want; some color rotations, a flash and decay animation, and a blend from the current color to a new one.

    I also wanted to be able to go fully to the metal and control every LED remotely and quickly. That led me to a better Http server for the ESP, a brief flirtation with TCP, and finally an implementation based on UDP. The server is fast enough that you could send the data for all 33 leds 500 times a second and it would work; it is currently constrained to 100 Hz because that is the speed the animation loop runs at, and I expect that for real applications sending data at 60 Hz would be fine.

    I am particularly happy with how the command processor worked out; the implementation is nice and clean.

    The wireless information is stored in permanent memory, and it is also possible to store the current animation so that it will resume on startup.

    Software (app)

    I want to have an app to control all of this. It needs to support both Android and iOS, which made Xamarin the logical choice; I can support both and I can write C# code which is a huge plus in my book.

    Like many open-sourcy software, it can be a real pain at times, but I’m able to build an app that deploys to my phone and debugs, and that’s a decent first step. I’m working on network discovery right now; once the provisioning is done, the app needs to enumerate all local ip addresses and see if one of my controllers is hiding there.

    And I’m using Xamarin Forms, which is built on top of XAML, which I guess is an advantage since I did XAML professional for a fair bit, but it’s a bit of a mind-bender as usual.

    I wanted to do something different for discovery, so I wrote a graphical pinger. Here’s a video.

    The app still needs a lot of work; it needs a way to do the initial provisioning, a way to list the different animations it can do, a color picker, etc.