I work in a company that has offices spread over 3 floors of a building. We have a dedicated table tennis room on the third floor, while my desk is on the first floor. It is pretty annoying to me to climb two floors just to see that the table tennis room is busy so I'll have to try again later.
I decided to create an application that informs me if the table tennis room is busy or not and also, in case that the room is busy, to notify me as soon as it becomes available. As implementation, I use Kemet proximity sensor in order to figure out what the status of the room is, this sensor is pluged to an Arduino board that communicates with a server via wifi. The business logic app running on server receives and sends information to the end-user through Facebook Messenger Platform.
The hardware components installed in the table tennis room are:
- UNO+WIFI board (ATmega328P and ESP8266)
- Kemet Pyroelectric Infrared Sensor
- Jumper 05SR-3S that connect the above components each other
How it worksIn the table tennis room there is a device consisting in the PIR sensor, ATmega microcontroller and Wifi board. The microcontroller code asks the sensor status every second and it implements an algorithm that detects the change of the room availability. There was a challenge: because in the same room there is a automatic vending machine, so there are people that use to pass through the front of the sensor, I had to adapt the algorithm so this unexpected and short term motion to not be taken in the account.
Concretely, the switch from available to busy status is triggered if the sensor detects "motion" during 50 seconds of the last 60. The switch from busy to available happens when the sensor detects "no motion" during 20 seconds of the last 60.
Every time a switch happens, the code from the wifi board creates a server request by sending as parameter the new state of the room.
On the server side, the switches are recorded in a database.
The end-user uses Facebook Messenger as client app (in desktop/browser or on mobile). Basically I developed a Facebook bot. This means that I created a Facebook Page and a Facebook App. When the user sends a message to the Facebook Page, the message is directed (using a webhook) to the server app that sends back a response that will be displayed in the user's messenger.
There are 2 possible interactions with the user:
1. The user wants to know if the table tennis room is available or not. The server app informs the user about this availability.
2. In case that the room is not available, the user is asked if she wants to be notified when the room becomes available.
Moreover, because I want that the application to not be used only by me, I implemented a reservation queue, the users being notified one by one once the room becomes available.
Comments