Saturday, February 27, 2016

First IoT Gizmo: Enhanced

I know what you're probably thinking after reading this post title: "How could it possibly get any better?"

I agree.  It's a thing of beauty already, but some parts showed up recently including a 128x64 .96" OLED.  I thought it would be a better value add to visually display the current temperature (and some other data) on the OLED display.

Getting this thing to work with the ESP8266 proved to be a bit of a challenge.

First off, the device's documentation is mostly nonexistent.  Before you can get anywhere with an I2C slave device, you need to know its address.  After using the addresses on the back of the PCB with no success (and some beating my head on the wall), I did some outside the box thinking and found this little gem.  It scans the I2C bus and looks for slaves on every possible address.

After determining that the correct address was 0x3c, I started hunting for a library that let me use this thing without implementing low level code.  Several Arduino libraries for 128x64 OLEDs were available, but they only sort-of worked.  The Adafruit library ran for a little while but it would always crash and cause the ESP8266 to reboot.  Eventually I found this library, which is specifically written for the ESP8266.  The only minor issue was that the code didn't compile, but it was minor so I fixed it, submitted a patch on github, and moved on.

The code I've got so far is worthy of calling a "proof of concept".  It works, but it usually crashes.  I'm 99.9% confident that it's the excessive use of delay(...) calls, causing starvation to things like the WiFi stack.  Before I deploy this thing in practice, I'll probably try running it using a cyclic executive.  This is a perfect use case for timers, but I've not found readily available documentation on the ESP8266 timers.  This is part of the down side of using the Arduino framework on this thing - you have no idea what's actually running under the hood.  More research may be in order here...

Here are some photos of the "proof of concept":





Also, I wanted to get this thing off of my ESP8266 programming board + breadboard, so I whipped up a protoboard version.  Side note: I'm feeling much more confident in my soldering and board layout having made just a small number of these things.  If you haven't moved past breadboards, I would strongly recommend soldering up some permanent boards.  Visuals:




If anyone is interested, here's a schematic of the board.  Note that RST and CH_PD pins on the ESP8266 need to be pulled high in order for it to run.


No comments:

Post a Comment