Introduction: Iot Weather Station Using Firebase and MIT App Inventor

Hello all during this Global Outbreak of COVID-19, the world is swiftly moving towards technology Dependence. Controlling things remotely and Working from Home is the new normal. Learning IOT or say Internet of things is the absolute necessity of time and making a Weather station would be the best way to learn Internet of Things. so in this blog post, we will learn to make a Weather station that will monitor Temperature, Humidity and Rainfall too, we will integrate all of this on an Android APP.


Step 1: Watch Video

Step 2: Electronics

In this project, we need to create a hardware interface between our Control Point and Internet, which basically means we need 2 Node Points (or say 2 devices), one at Sensor side and another at Control side. The Medium would be Internet.


For our build, we will need a Microcontroller that can read our Sensor Data, Send it to Internet and also react to any Inputs received from the Internet. Most Capable candidate for this Task Will be a NodeMCU which has ESP8266 Wi-Fi Enabled board along with USB Interface and Complementary Electronics and the best part is that we can Program it with Arduino IDE. Refer to this blog to go through the basics of node MCU.


For Temperature and Humidity, we will use a DH11 Sensor to sense Temperature and Humidity, we have also covered the basics of DHT sensor in this Post.

For Rain, we will use a generic Rain Sensor, which uses Conductive Property of water to change resistance and indicate if it’s raining or not, and also how intense is the rain. It comes as a Set with an operational amplifier to provide more accurate Calibrations which give us Digital or Analog Corresponding Outputs, it has a Potentiometer that can be used to Adjust the Sensitivity of sensor, which we will calibrate by pouring few drops of water on sensor and adjusting the pot until we see output LED glow.


For now, connection are very simple,


Vcc - 3.3v of Node MCU

GND - GND of Node MCU

Data - D5 of Node MCU

Rain Sensor

Vcc - 3.3v of Node MCU

GND - GND of Node MCU

Data - D2 of Node MCU

Thanks to offer electronic components for my projects

Step 3: Software Overview

To Control or Monitor our Sensor in real time, we will need 2 nodes, one node is Microcontroller that connects to Internet via Wireless ACCESS POINT, but we need a second node or point to store data or Process it, for which we have quite a lot of option like Adafruit IO, Blynk, IFTTT, MQTT, Firebase, etc.

The Initial goal of the project was to push the data on Website server,with Firebase and a Firebase WordPress Integration plugin, but couldn’t get it working like expected, so switched to Firebase and MIT- App inventor to make an Android App that would display our data, and it turned out to be Awesome, We will learn that in the further steps.

Step 4: Firebase Database

First go to, use your Google Accounts and get started,

start a new Project by naming and completing the follow-up steps till you see the Dashboard, now go to database option on left side, remember we have Real-time data to deal with, so create a Real-time Database, now it asks if we need authentication or not, since we will make an App and we want it to be publicly available, so choose test mode Database, which will keep Authentication off, it is less secure but works for this application.

the Database URL is very important, since we will push our Sensor data to this Node or server. copy the database URL for now.

Step 5: Node MCU Code

Open the code and Libraries attached in this step and Paste the URL copied in previous step in firebase_host definition line without the https and /(backslash). Make sure you remove it or else the data won’t be directed correctly.

#define FIREBASE_HOST "Paste URL here"  // Enter the Firebase Database URL Without Https and backslash<br>

Other than that we need internet connectivity, for which we have to enter our Wi-Fi SSID and Password in definitions.

#define WIFI_SSID "Enter your WiFI SSID"   // Change the name of your WIFI
#define WIFI_PASSWORD "WIFI PASSWORD"      // Change the password of your WIFI<br>

rest of the code is very simple and self-explanatory, where in we are basically pushing all the data from sensor on Real-time Database of firebase.

void loop() 
 float h = dht.readHumidity();
 float t = dht.readTemperature();         // Reading temperature as Celsius (the default)
 int r = digitalRead(4);                  // Reading the Rain Sensor Data
 Firebase.setFloat ("Temperature",t);
 Firebase.setFloat ("Humidity",h);
 if (r == 1)
   Firebase.setString("Rain", "Yeah");
   Serial.println("its raining");
   Firebase.setString("Rain", "Nah");
   Serial.println("no rains today");

find the code here!

and Libraries here!

Step 6: Mobile APP

We used MIT APP DEVELOPER, so that you can easily reproduce this project for yourself, here is the .aia file which you can import into MIT App inventor and easily customize for your project and application.

Simply import the project and go to build option, which will show you link and QR code, next install this app on your phone.

We can do this entire Task with BLYNK which indeed looks better in terms of UI, but blynk is not completely free, it comes with lot of restrictions, yet coding and backend work of Blynk is way easier than MIT and definitely is useful for making simple Switch projects.

Step 7: Power Electronics

We need to mount this system in Balcony or some place with access to Environment, we can’t power this system with USB wire, so it makes sense to use a Battery, best option would be a Lithium Polymer Battery but my Balcony is home to lots of birds and squirrels, I can’t afford accidental fire here. So safer option would be a Lithium Ion battery, which adds up a little weight but offers higher Capacity and Safety as well. I have this Lithium Ion Cell with 2000 mAh Capacity and we will add a TP4056 Li ion charging module along with it.

After looking at Node MCU’s datasheet, we get to know that NODE MCU uses up to 170 milliamps. At 2000 mAh capacity and current draw of 170 milliamps, we get use time of around 11 hours, which is not much, but luckily we have Deep Sleep Mode in our NodeMCU, which basically puts our System in Deep Sleep to reduce Power Consumption. Simply add Esp.deepsleep (time in microseconds) at the end of our loop.

Esp.deepsleep (3e+8);<br>

Upload the code and then connect D0 to Reset pin,do not connect D0 and Reset before uploading the code else you will get uploading error. During the Sleep mode, our system uses 8 milliamps. Which turns down our overall current consumption of system and it brings battery life to 10 days ideally. We can remove the LEDs on Node MCU, DHT11 and Rain sensor to further reduce power consumption, but honestly 10 days is fine with me and I am happy with this system.

Step 8: Printed Circuit Board

As of yet, this project was on Breadboard, so we need to convert it to a PCB for which can be done using Online PCB services or by using a General Purpose Board. Since I was short on time, I went with a rather unprofessional way, that is a General Purpose Board, yet I have designed PCB and added Gerber File, which can be found here! and Schematic can be Found here!

Step 9: Enclosure

We are done with our PCB and Code, it’s time to test Everything with our APP, system is working well, it is optimized in power consumption, but it looks like mess, let’s try to bring the system in an enclosure, but I don’t have a 3D printer, so I would use a Plastic Container to stuff everything inside, make appropriate slot for DHT11 sensor and I choose to Mount Rain Sensor independent of box to reduce chances of unnecessary water entering into system via slots, after all drilling and cutting was done, I painted the enclosure with a High Temperature Silver Paint and finally used few zip ties to secure this system to my grill.

Step 10: Conclusion!

Finally after doing all the above steps, we can easily monitor Temperature at balcony from anywhere in world, just to get a gist of this, I told my friends to install this app on their phones and see how the app updates sensor’s data in real-time. if you enjoyed this Detailed yet Fun IOT project, do give this blog a Like, if your feel this helped you in any way, share it with your friends, that will help us grow and definitely it boosts our morale.

Thank You!

Backyard Contest

Participated in the
Backyard Contest