Washing Machines - IoT This project was motivated from the necessity of managing the washing machines remotely. Everytime a user needed to wash/dry their clothes, would need to go physically to check if there was someone using it before.

To solve this, I created this tiny PoC for an IoT course during my Master Degree in IoT (UNISA).

The main features needed were:

  1. Make a Reservation for any available machine.
  2. Authorize the loading/unloading of clothes only to the user that reserved it.
  3. Notify users when drying/laundring is done, to avoid blocking a machine because user never went to look for their clothes.

1. System Architecture

For this project, the approach taken was:

  1. Arduino - Handle servo motors and listen to MQTT server.
  2. Backend (FastAPI) - Server to handle connections to database (mongodb and firebase), the MQTT server and the business logic of the application.
  3. Mobile Application - For users to interact with the system.
Washing Machines - IoT - Architecture

2. System Development - "(Mobile Application + Backend + Arduino)"

For the Backend application, I decided to use FastAPI since it’s very fast to set it up, work with the pydantic models and it’s very flexible for most of the tasks I needed to implement. Regarding the databases used, I built this project with two different possibilities, either using Firestore or MongoDB.

Also the server, needed to manage the MQTT messages to notify the Arduino controller to block/unblock the doors, that in this project, is represented by the servo motors blocking/unblocking the washing machine doors.

The reason of doing this, was that, during the presentation, they asked me to set up this project within the lab. So I got some issues by working with Firebase from the lab network. That ended up on using a local solution to deploy the whole system.

The lab have Portainer to handle containers, so I built the MongoDB version that is currently hosted in the lab, just to have an example working. One of the issues I faced with setting up mongo, was setting the replica conf, but after solving that, everything was very straightforward. The docker-compose is in the repo in case you could be interested in using something like this in the future.

For the Mobile Application, I did it with Flutter, since I got previous experience with the framework, so I would get the App working by the required deadline.

Lastly for the Arduino Controller, I set up a system to monitor and control washing machines. With a small OLED display, it communicates essential details to users in real-time. The project uses Wi-Fi for MQTT communication, making it easier to integrate it with the network.

The setup involves defining credentials in arduino_secrets.h to connect and publish updates to relevant topics like "status" and "servo_control.". The components handled by Arduino are:

  • Display Control: With a compact 128x32 OLED display, the system provides a clear and minimalistic interface.
  • MQTT Integration: It interacts with an MQTT broker for real-time communication.

2.1 Some Deployment Issue/Experience

When I tried to deploy the project using Firestore as database in the lab, the physical computer where the docker container was running, was returning a date that was old, so because of that, every request I would make the FirestoreAPI would fail.

In order to solve that I went to the official Google Auth Python Library and instead of using the time from the system, which would make sense actually, I requested it from an external service. The reason of going in this path was because the system administrators weren’t to much available in that moment to make the fix in the system itself, so I had to workaround this. The end results was this fork, which worked :D !

After that, other issue I’ve found was that the Python Client for CloudFirestore API, didn’t had support for async snapshot_callback. Only for sync functions, so I workaround it as well with the following fork. I posted an issue on the official library to add support to this, and there was a great suggestion of doing it properly, from developer from the library, but I didn’t have the time at that moment to release it fully.

3. Demo - Views

Washing Machine - IoT - Demo

4. Repositories

The full source code and documentation are available on:

5. Possible enhancements

  1. Notify the server once servo motor has been activated. (For the app to have knowledge in case some issue could have happened).
  2. Improve UI/UX for the mobile application.
  3. Add estimated time for the user and notify it for events.
  4. In case user reserve and doesn’t use it within 15 minutes, ban it for 1 hour.