owned this note
owned this note
Linked with GitHub
# Internet of Tubs @ Bornhack19
Once upon a time at a hacker festival, there was a hot tub. It was there because Jérémie Zimmermann [had urged hackers](https://www.youtube.com/watch?v=KNw9_7AUIZ0) to take better care of themselves and one another. This inspired the wellness-area at Bornhack.
## The challenge
After giving the water a whirl, richard42graham remembered working on a ["shitty addon"](https://hackaday.com/2019/03/20/introducing-the-shitty-add-on-v1-69bis-standard/) the year before during soldering practice, and wanted to combine the temperature sensor from this addon with a WiFi-connected _ESP8266_ chip. This would turn the hot tub into a quirky collaborative festival-project.
Owing to its wood-burning stove and open-air location, the water temperature in the tub would naturally fluctuate. And while cooling it down is a relatively quick feat, raising it takes time, making it difficult to hit the sweet spot of around 40C celcius.
Keeping the temperature up with team-alerts and beckoning new patrons with the temperature became the objectives.
## The process
A team of two hackers (Richard & Max) soldered a sensor to an ESP chip and wrote some quick firmware and a web front-end. The hot tub was now connected to the internet: with a plastic bag weighed down with a stone, with wires sticking out of it, dangling inside the hot tub. The ESP8266 ran a simple HTTP server with a `/data` endpoint serving out a JSON array with temperature points (measured every 20 seconds), so a 5 hour timeseries graph could be drawn.
It was probably not a good idea to let everybody query the ESP directly, especially after gaining popularity, so it was quickly decided that we would have to build something in front of it. MQTT seemed like an obvious way to publish the sensor data, so we hacked together a scraper extracting the latest measurement from the existing endpoint, with the aim to change the webinterface to do the same later.
With the data made public in a reliable way, it was now possible to retrieve the temperature for the obligatory IRC and Twitter bots, which still had to be coded. This proved to be a challenge, given most IRC bot frameworks apparently were not actively maintained. After some pain and grief, we settled with Sopel. People could query the bot about the current temperature, and it would alert when the water was getting too cold (so more wood could be put in), or if the water was good to jump in.
On top of that, the Ohmlights, some LED torches present all over the camp site gained a "Hot Tub Mode", streaming the current temperature in a marquee font.
The campsite solder gave up around midnight, which left our fancy new inventions showing 0.0 degrees, so the unit had to be retreived; a good opportunity to improve the firmware. Next day, we fired up the Arduino IDE and the ESP8266 toolchain and had to fight a bit, because the Arduino IDE was packaged in a snap which didn't have permission to access the `/dev/ttyUSB0` serial device. We updated the firmware of the ESP so it would push to MQTT directly, rendering the scraper obsolete.
As written above, we weren't quite happy about the rudimentary HTML temperature graph, so this needed to be improved as well. With the data already being exposed over MQTT, we could set up a Telegraf datalogger, which would subscribe to the MQTT broker and dump the temperature into InfluxDB, a time series database.
Afterwards we could get shiny graphs thanks to Grafana, so people in the bar could easily read the temperature from a less crappy frontend, without having to leave their beer alone.
At the end of the festival, the tools and gadgets we had created worked quite well, and ideas for future updates were many. Some new ideas include showing how many people are in the hot tub (using lasers, mats, or heat-sensing cameras), as well as changing the temperature sensor to a waterproof one (to get rid of the plastic-bag waterproofing), and temperature-dependent text color on the Ohmlights.
LM1117 (linear regulator 5v to 3v)
DC-DC regulator (12 to 5V)
Temperature sensor TMP112
richard42graham (esp + firmware)
0m-ax (esp + firmware)
flokli (mqtt + irc bot + grafana + writeup)
Pawel (twitter bot)
baskee (irc bot + writeup)
IRC & Twitter Bot + Ohmlight script + ESP firmware + MQTT scraper: