Introduction: IOT Based Room Temperature Control
This is instructable on IOT based room temperature control project.
1. Automatically turn ON fan above the specified room temperature.
2. Automatically turn OFF fan below the specified room temperature.
3. Manual control at any point of time at any temperature
- NodeMCU ESP8266 development board
- DHT11 temperature sensor
- Single channel relay board (5V)
- Jumper Wires
- Wifi router or portable hotspot (to connect NodeMCU ESP8266 to internet)
- 9V battery
So let's dive into tutorial.
Step 1: Setup Firebase and Get Secret Key
We are going to use a real-time database by Google firebase. This real-time database will act as a midway broker between Nodemcu and Android device.
- First of all, navigate to firebase site and log in using your google account.
- Create a new real-time database.
- Get real-database URL and secret key to access the database from the app. For a detailed tutorial, you can check out how to use firebase with MIT app inventor.
Step 2: Create App Using MIT App Inventor 2
We are going to use MIT app inventor 2 to create our Android app. Its very simple to use and easy to integrate win Google firebase.
- Download attached MIT app inventor 2 project file (.aia file).
- Go to MIT app inventor 2 home page and login to your account. Then go to projects >> import project. Select the file from your computer and upload it.
- Go to layout window, click on firebaseDB1 (located at bottom of the workspace), enter database URL and secret key. Also set ProjectBucket as S_HO_C_K (as shown in screenshot 2).
After that, click on the build button and save app file (.apk file) to your computer. Later transfer that file to your Android device.
Step 3: Configure Arduino IDE for Nodemcu ESP8266
- First of all, configure Arduino IDE for Nodemcu esp8266. I would recommend this step by step tutorial on NodeMCU basics by Armtronix. Thanks Armtronix for this helpful tutorial.
- After that, add these two libraries (reference screenshot) :-
Step 4: Upload Code to NodeMCU ESP8266
Download Arduino IDE file (.ino file) attached below. After that, alter the program for some necessary changes:-
- At line 3, enter database URL without 'https://'.
- At line 4, enter database secret key.
- At line 5 and 6, don't forget to update WiFi SSID and Wifi password (to which you want to connect NodeMCU ESP8266).
Once done, upload program to NodeMCU ESP8266 development board.
Step 5: Assemble Hardware
- Create circuit as shown in above figure.
- Install the app (created in step 2) on your Android smartphone.
- Power up the circuit and enjoy!
Participated in the
Arduino Contest 2019