This week I was writing a lot of code. I had been putting together some sensors for measuring temperature and humidity around the house. I planned on monitoring a number of rooms so I went with something cheap, which was the Huzzah, an ESP8266 microcontroller that costs about $10, combined with a cheap temperature and humidity sensor, which was the HTS221, which was also about $10. In doing so there was a few “observations” I had that I wanted to share so that others could avoid the same pitfalls and time sinks that I did.

  • Avoiding the DHT22
  • CircuitPython does not support ESP Devices: Huzzah, Arduino/C++, and CircuitPython

Avoiding the DHT22
Why the HTS221, why not a DHT22, I specifically avoided using any sort of DHT22 sensor because I had tinkered with them in the past and real didn’t have a good experience. First off, the DHT22 is slow, it’s either in the libraries or the sensor itself but querying it takes about a full second, so if you wanted to get data from other sensors too, then you are already looking at times longer than a second. Second, the DHT22 doesn’t seem to be very reliable and there are times when it will not return any data, again this could be the sensor or the library, but the code needs to deal with Nulls and it seems as the sensor gets exposed to the elements, which a humidity sensor is bound to do, those Nulls increase in frequency. So, in my experience with the DHT22, in the end you have a slow sensor that sometimes doesn’t return data and as the project ages, the sensor likes to return less and less data. Not fun from any sort of monitoring perspective.

CircuitPython does not support ESP Devices: Huzzah, Arduino/C++, and CircuitPython
The heading was a painful lesson for me to learn and it was after I had gone down the road of getting the devices, designing and 3D printing the housing, and assembling. I should now just write some simple python and be done, but that wasn’t the case for me. The HTS221 has some good example code that shows how to use it from an Arduino and a CircuitPython approach. Since discovering it a little while ago, micropython has been my go to for working with microcontrollers because it’s so simple and easy to use. For my setup I figured I would use micropython with my sensor and all the networking pieces to collect the data and then send it over the network to be received and handled by some other computer with more horsepower to do any manipulation and recording. In trying to write the code to work with the sensor I learned that I needed the library for the HTS221 and that there are two libraries out there: one for Arduino and one for CircuitPython. CircuitPython is just the downstream version of micropython so I assumed it would be simple to just load it up and continue on, however in trying to do so I learned that CircuitPython does not support the ESP8266 microcontrollers because they don’t have that much memory, which makes perfect sense, once you load on CircuitPython there’s very little resources left to load actual code and libraries to do anything. So I hit a roadblock: I wanted to use micropython but the library was for CircuitPython, and I can’t use CircuitPython since it’s an ESP8266 device and not supported, therefore I would be writing Arduino code for this project. Not what I had planned to do and the networking pieces would be harder to do, but it’s all still doable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.