IOT Based Room Temperature Control

by Rishi Rishi in Circuits > Microcontrollers

4087 Views, 8 Favorites, 0 Comments

IOT Based Room Temperature Control

Control Room Temperature From Anywhere Just For $10

This is instructable on IOT based room temperature control project.

Features:-

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

Requirements:-

  • 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.

Setup Firebase and Get Secret Key

welcome firebase.PNG
realtime databse settings.PNG

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.

Create App Using MIT App Inventor 2

tricksumo.com 1.PNG
tricksumo.com 2.PNG

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.

Configure Arduino IDE for Nodemcu ESP8266

library.PNG
  • 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) :-
  1. Arduino Json
  2. Firebase Arduino
  3. DHT Sensor Library

  4. Adafruit Universal Sensor Library

Upload Code to NodeMCU ESP8266

tricksumo.com 5.PNG

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.

Assemble Hardware

[SOLVED] DHT11 Temperature Sensor Not Working With NodeMCU ESP8266
tricksumo DHT11.jpg
  • Create circuit as shown in above figure.
  • Install the app (created in step 2) on your Android smartphone.
  • Power up the circuit and enjoy!