ESP8266 IoT room thermometer – part 4: the code

In response to a flood of requests – well, okay, one – I’ve posted the code for this project on GitHub. But don’t expect to be able to run it.

That’s the thing about a maker project – you can create it to be used by anyone who cares to download your designs and code; or you can optimise it for your own particular needs. I tend towards the latter.

And so it is with this project. There are two things that ensure you can’t just download the code and run it. No, on second thoughts, there are three.

The first is that you need the specific hardware I’m using – but that applies to pretty much any project of this sort, so let’s not worry too much about that. You also need all the right libraries, but ditto. (There are quite a few projects for which I won’t share the code because they use my own, homebrewed libraries and sharing everything would get messy. But that’s not the case here.)

The second is that I’ve used specific fonts for the display. I’ve put those in the GitHub repository, along with the settings I’m using for the TFT_eSPI library. You’ll need to manually move the files into the right locations – in some cases overwriting existing library files – to get this to work. So note the warnings in the Readme.md file. If you’re already using the TFT_eSPI library for other purposes, it’s possible my settings will clash with yours. Good luck with that.

The third issue – and this is more intractable – is that the thermometer communicates with a REST API running on my home intranet server. I don’t want to get into publishing the code for that. For example, it gets the current time, date and weather for our nearby town from that server. And it regularly reports its readings to the server. So you’ll need to roll an API server of your own to deal with that.

Putting this is perspective, the code is provided merely for information and amusement – not as a project you can easily replicate. So take from it what you will.

By the way, even sharing this code involved some effort. I pulled up the Arduino code and tried compiling it. It failed. At some point it seems I had done an update or made some other changes that meant the ESP8266 board was no longer installed in the Arduino IDE. Which is weird.

So I installed the board libraries and tried compiling again. It failed.

This time it was the TFT_eSPI library that was barfing. I updated that, which meant copying my font and configuration files into the library again (see the GitHub repo to understand what I mean).

Third time lucky? Well, yes. But it’s weird how code can age like this, almost like it’s rusting away…

» The GitHub repo for this project »

Leave a Reply

Your email address will not be published.

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