IoT Smart Bathroom
This project aims to develop a “smart” bathroom making use of relevant capacity utilization data, such as: people flow during a pre-established time interval; facility utilization data (number of visitors versus time they stayed in the bathroom), and, according to the physical space utilization rate, trigger “on demand” cleaning process alert (via Twitter). This kind of technological solution can be applied in areas with intense flow of people, such as hospital hallways, restaurants, museums and similar ones. As result, a better cleaning team dimensioning is expected, which leads to optimization of resources utilization.
Before reading the next steps, make sure that your Intel Edison is configured with the newest firmware.
Create the Circuit on the Protoboard and Fix It!
For this step, you will need:
- 1 Protoboard
- 1 Ultrasonic Sensor HCSR04
- 4 Jumpers
- 1 Intel Edison
- A wi-fi network
Fix the ultrasonic sensor in the protoboard, then connect the jumpers into the right pins (gnd to gnd, 5V to 5V, trig to output and echo to input).
Make sure that the Ultrasonic Sensor is set in front of the bathroom door looking to the door. It has to be able to detect when someone passes between the sensor and the door.
Using Python
The whole code of the project makes use of Python, so make sure you have installed the following API's:
- Pip Python.
$ opkg install python-pip
- TwitterAPI.
$ pip install 'TwitterAPI'
You can check the TwitterAPI documentation here:
https://github.com/geduldig/TwitterAPI
Attention: Make sure you have the newest version of the firmware, because you have to use the library "mraa", and it doesn't work with older versions.
Conect Your Edison in a Wi-Fi Network
Copy this code to the terminal and set a Wi-Fi network:
$ configure_edison --wifi
Find your wi-fi network, write the password and connect your Edison to it.
Requiriments to Include TwitterAPI to Your Code
For this step, you will need a Twitter account.
1. Sign in your Twitter account
2. Enter this link:
https://apps.twitter.com/app/new
3. Input a name, any description, a website url and agree with the terms.
4. Click on "Keys and Acess Tokens"
5. Save the following information: Consumer Key, Consumer Secret, Acces Token Key and Acces Token Secret.
Those steps are necessary and they will be included on this part of the code:
from TwitterAPI import TwitterAPI TWEET_TEXT = "YOUR TEXT HERE" CONSUMER_KEY = 'YOUR CONSUMER KEY HERE' CONSUMER_SECRET = 'YOUR CONSUMER SECRET HERE' ACCESS_TOKEN_KEY = 'YOUR ACESS TOKEN KEY HERE' ACCESS_TOKEN_SECRET = 'YOUR ACCESS TOKEN SECRET api = TwitterAPI(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_TOKEN_KEY,ACCESS_TOKEN_SECRET) r = api.request('statuses/update', {'status': TWEET_TEXT}) print('SUCCESS' if r.status_code == 200 else 'FAILURE')
The Interface
A web interface is used to check the status and information given by the SmartBathroom.
Here is the code for ToiletDash.json:
https://github.com/leo-alves-melo/smartbathroom/bl...
Run the Code
Download the code from the link, change the data of your Twitter account, compile to your Edison and you will have your Smart Bathroom!
https://github.com/leo-alves-melo/smartbathroom.git
Important Note: The complete code is commented, thus you get the explanation on how it works.