Unit testing your code is peace of mind. It has two main direct benefits that impact on your confidence about the code you are writing:
Testing expected behaviors
Avoiding regressions (i.e. breaking something that was working fine before)
Unit testing embedded systems is a bit more involved since there is the additional constraint of the hardware itself, sometimes more than one device or even different platforms. Quitting (or not even thinking about it) is the easy answer to the problem. All of us have debugged expected behaviors with inline prints. But automating some of these tasks have a huge benefit on the code quality and development speed. Continue reading →
This time I’d like to write a quick post about a small project we’ve been working on at the The Things Network community in Barcelona (@ttncat). We were worried about the monitoring of the gateways we have deployed, both as a community but also as individuals. Some of our partners have also deployed their own gateways and they are part of the community.
So how do we get (almost) real-time notifications of incidences in the local TTN network? We want to be able to track them as soon as possible and open the proper ticket in our management system to solve them if the solution is in our hands or notify the entity responsible for the gateway.
Some time ago I worked on a home project to get a notification when my washing machine had done its job based on monitoring its power consumption. There was a good reason for that, the machine was outside the house and I had already forgotten about the laundry several times. And when that happens your only option is to wash it again, because it really smells musty…
Monitoring your appliances
Use ESPurna 🙂
OK, there are different ways to get the info about power consumption. But since we want to be able to process the data ourselves most commercial products won’t be suitable unless we modify it.
Alternatively, those that use radio communication to send data from the meter to the base station might be suitable for a man-in-the-middle hack. For instance, if you own an Efergy power meter you must know you can sniff the data it sends using a simple RTL-SDR dongle.
But for most cases, your best chance is to get your hands on a commercial product with an ESP8266 chip in it and change the firmware to suit your needs. You can write your own or use an existing firmware like ESPurna, that already supports a bunch of power metering smart switches.
What info do you need?
The idea is to report (via MQTT) power data from each individual appliance very minute. You can then use Node-RED along with InfluxDB and Grafana (or Graphite) to receive, persist and graph your data like in the image below.
You might have heard aboutThe Things Network (TTN from now on) here or somewhere else. If you have not, then it’s a good opportunity to visit the project and check if there is a community of users around you. I have been a core member of the TTN Catalunyacommunity for over 2 years now. This year we are working hard deploying several new gateways in Barcelona and doing workshops and hackathons with the main goal of helping individuals and social entities to carry out projects around a LoRaWan open, libre (free as in freedom) and neutral telemetry network.