In my student dorm we share a washing machine with at least 10-15 persons. Everytime you want to wash it's occupied and you have to wait. And the worst thing is: you don't know how long you have to wait. So it's really difficult to plan the day with it.
I'd like to present you my laundrylearn project. The goal of this project is a IoT device, which logs sensordata of my laundry machine. The planned sensors are: photoresistors on leds, accelerometer, gyroscope, temperature, humidity and current of the machine.
When the data is collected I want to push it into something like an machine learning algorithm which then does a prediction of the remaining time.
At last the data will be presented on a webpage online.
Yesterday I did a full setup of the environment and started with a little Proof-Of-Concept code. At first I'd like to present the architecture:
We start at the top left. There will be some GPIO detection and logging Module. This module detects sensor data and pastes it to my MQTT Broker. Since MQTT as a protocol has no data persistence, you have to implement it yourself: the MQTT-Data-Service receives this data and saves it to a database. At last a webscript polls the data from there and displays it for the users.
GPIO Detection v0.01 - NodeMCU
Since my originally planned RaspberryPi 3 has not arrived, I did a little first-shot with a NodeMCU module. I simply put it on a breadboard and connected a photosensitive resistor on Port A0. The resistor is connected to the "washing"-LED of the laundry machine with formable glue.
The NodeMCU is programmed with platform IO and the arduino framework. It connects to WLAN and MQTT and posts the status of A0 port every 10 seconds. No rocket science now. You can find the code here.
MQTT-Broker
As broker I use mosquitto on Ubuntu 16.04.
MQTT-Data-Service
As i mentioned, MQTT will not preserve your data. When a client posts, and you are not connected to receive it, the value will disappear in nirvana. So I had to implement a persistence module myself. This is a little python tool which reads a config.ini file, where the MySQL/MQTT connections are defined and also every subscription topic, that should be followed. It then connects to the MQTT broker and subscribes to every defined topic. When it receives a message, it simply pastes it into the database. For further information about the structure of the database please consider the Github Repository.
Webserver/Script
I use nginx as a webserver. The super simple script is written in php7. It connects to the database, receives the current MQTT Data and displays it on a bootstrap webpage.
HAHA I cannot remove that last list point. What a bug! :D