Originally posted at https://tech.labs.oliverwyman.com/blog/2015/11/29/pyrexia-iot-office-temperature-monitoring/
Most of the projects I write about here are pretty much complete, or at least good enough. This one is a little bit more of a work in progress for reasons that will become clear fairly soon…
One of the ongoing conversations in LShift over the years has been regarding the temperature in the office. It starts simple: do we feel cold in here today? Is this meeting room stuffy? Of course, then being a bunch of developers, it gets more complicated, with discussions including speculation on the nature of the control mechanism behind the air conditioning (I²C is the current opinion I think), and could we make a better version…
All of this is generally based off pretty much zero data, and is a subject for heavy bikeshedding. I decided to actually put some numbers to it, and the recent surge in interest in the NodeMCU boards made me think I could actually do this for not much money. Enter Pyrexia, an IoT temperature monitoring system.
Initial results were pretty good. Got some NodeMCUs cheap, wrote some Lua code, and all appeared to be working ok. Built a shiny little frontend Clojurescript app for it (started with Om, got annoyed at it, switched to Reagent which is a lot friendlier) and figured out a nice way to get data into it without having to write pretty much any backend code (see also diagram, but a combination of RabbitMQ with MQTT, Logstash and Elasticsearch). Plugged the first two nodes in at the office, and left them overnight to bed in.
Huh. They’ve stopped working. Ok, poke the code, add some redundancy bits, repeat. No luck. Add a immensely hacky mechanism where the nodes restart themselves every 5 minutes. Gets a few more hours, but then stops working. Enter instead Raspberry Pi’s :) So, it turns out there’s a downside to the NodeMCU. It’s cheap. Like, £4 for a WiFi-enabled node with USB power and an ok processor. It is however, an evil little [expletive] to work with, and will just stop working for no reason I can yet determine. For those of you who haven’t dealt with proper embedded systems (Raspberry Pi’s don’t count), there’s no logs. There’s probably basically no storage, and getting information about why it just decided to stop working, especially when switching one on/off again makes it work again. There’s probably ways to figure this out (leaving it plugged into a laptop overnight and getting the logs via serial that way might work if nothing decides to go to sleep), but I’ve reached my frustration threshold on these things.
Actually having a proper Linux system to work with is much nicer, and they’ve been stable for at least several days, probably longer (other than colleagues accidentally unplugging the temperature sensors). That any of the Pi models is complete overkill for temperature recording means I can attempt to get early ones off of eBay cheap-ish (and I’ve got a Pi Zero heading my way), as any model at all will do.
There’s still some work to do (make nice boards so the temperature sensors aren’t just connected by jumper wires for one), but I’m at least starting to finally get some data on the patterns in the office. Looks like I need a few more nodes yet though!