Disclaimer: This post has lots of links to the Adafruit website. There are no referral links, I received no consideration, I just buy parts from there and do cool things with them.
A couple of
weeks months ago I did a writeup of a prototype environment monitoring device for my office built out of a Raspberry Pi Zero W and some off the shelf components. In the time since I've found time here and there to work on the embedded version, which doesn't use a full computer system but a microcontroller with just enough functionality to drive a couple of sensors, get onto a wireless network, and run some custom software to do the heavy lifting. Because I'm a lousy electrical engineer I once again went with development boards that I could reliably patch together with my limited electronics skills but program for readily.
I'm a software geek, what can I say?
Anyway, I once again went with Adafruit's AHT20 temperature and humidity sensor, which I already knew how to program with. It's not perfect but it is well documented and stable. After some research and head scratching, I decided to go with the Feather Huzzah development board, based upon the ESP8266 microcontroller. It's a pretty nice little chip, with wifi built in and four megs of storage on board. Unfortunately, Circuitpython is no longer supported on this board by Adafruit so I decided to give the port of Micropython to this board a try, and aside from a couple of drivers included in the default install which would be third party modules for Circuitpython, it was pretty much the same. So that there would be a display on board to make it easier to work on I went with a fairly standard display, the 128x32 pixel OLED Featherwing.
Unfortunately I didn't take any photographs during the build process, but I did try to document the build after the fact. I tried to make the pictures reflect as many parts of the construction process as possible. Most of the process was, to be fair, soldering the pin headers onto the Huzzah. What I did was, I bought the version of the Featherwing OLED which had the headers already soldered on, stuck the pin headers onto the pins of the OLED, droped the Huzzah on top (the long sides have different numbers of pins so it'll fit only one way), and solder them in place one after the other. That way, the display would always be on top, and if I wanted to remove the display for some reason, I could.
Incidentally, the code I wrote for this device tests for the presence of the display, and if it doesn't find out it just goes about its business instead of locking up or something. So, if you can't find one of these displays or you just don't want one, don't worry.
Looking at the pinouts (the map of what each pin does) for the Huzzah there are only a couple of pins that I cared about: The 3 volt and ground pins for supplying power to the AHT20 sensor and the two I2C pins (SDA and SCL) that would be used to get data from the sensor. If you've never worked with it before, the I2C bus was designed for hooking weird little devices to microcontrollers with a minimum of hassle. The neat thing about I2C, however, is that every kind of device (display, sensor, what have you) has its own I2C address (the AHT20's address is 0x38, and the Featherwing OLED display's address is 0x3c), and the protocol was designed so that you can daisy chain devices, so you don't need one pair of pins for every gadget you're attaching to the microcontroller. Moreover, if a packet on the I2C bus from one sensor hits another device on the bus, the second device will ignore the message and it'll continue down the line. So, the OLED display and the temperature/humidity sensor play nicely together and you don't have to do anything fancy to get them to work.
All of that said about I2C, when I soldered the AHT20 sensor into place I used a couple of jumper wires to the 3VDC and GND pins for power, and the SDA and SCL pins for the I2C bus. Once I was sure that I'd done it correctly I used a couple of pieces of kapton tape to reinforce and insulate the solder connections.
The Micropython installation instructions are straightforward and easy to follow. I installed esptool on Windbringer and used it to flash the Micropython firmware image (v1.12 stable, for 2 or more megs of flash storage) over USB. ampy was used to upload the Micropython code I was writing to the Huzzah. Just for fun I used picocom to connect to the Huzzah directly to interact with it. By default, a direct serial-over-USB connection will drop you into the interactive Python interpreter. If you've uploaded your own boot.py and main.py files you can see any output they have and interrupt them with control-c if necessary.
That's pretty much all I've got right now. I've tried to make the documentation for the software I wrote as easy to understand as possible. Primarily, it's set up to display the humidity and temperature on the OLED display (if one is present) and, if you configure it properly you can get it on your local wireless network and have it send measurements someplace for monitoring, maybe with a dashboard. Of course, I have mine send their measurements to Huginn but do whatever works for you. The code I wrote is a work in progress. There are still one or two things that I want to work out (namely, detecting if the sensor has dropped off the wireless network and rebooting to try to fix the situation) - if anybody wants to file a pull request with a patch, please do!