0% found this document useful (0 votes)
23 views8 pages

Karmbir 19 ML (2) (1) - Merged

This document describes building an IoT weather monitoring system using a Nodemcu board, sensors for temperature, humidity, pressure, and rainfall, and the Thingspeak cloud platform. The system obtains sensor readings, sends the data to a Thingspeak channel, and displays the readings. Components are connected, the Thingspeak app is configured, and code is written to read sensors, connect to WiFi, and post data to the channel.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views8 pages

Karmbir 19 ML (2) (1) - Merged

This document describes building an IoT weather monitoring system using a Nodemcu board, sensors for temperature, humidity, pressure, and rainfall, and the Thingspeak cloud platform. The system obtains sensor readings, sends the data to a Thingspeak channel, and displays the readings. Components are connected, the Thingspeak app is configured, and code is written to read sensors, connect to WiFi, and post data to the channel.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Project File

“Machine Learning with Python”

Department
Of
Computer Science and Engineering
2023-24

Submitted To: Submitted By:


Miss Surbhi Name: Karmbir
Prof. Registration: 181261103032
CSE, IGU, Meerpur MCA 3rd Sem.
Rewari, Haryana 2022-2024
Weather Monitoring System
In this report we will learn how to make an IoT based weather monitoring system
using Nodemcu and Thingspeak. This project is mainly based on IoT technology.
Also, if you don’t know about Thingspeak. Through this system, we can monitor
factors such as temperature, humidity, pressure and rainfall. The DHT11,
BMP180 and Rain sensors are used for that. Also, we can use this system mainly
for farms and greenhouses.

The process of this system


When this system is powered on, the Nodemcu board connects to the algorithm
development system called MATLAB through the Thingspeak cloud. Then,
values are obtained from the sensors. Also, these values are sent to the thingspeak
app using the internet. Then, we can see the values as a visualization on the
screen.
So, let’s do this project step by step. The required components are given below.

Nodemcu board x 1 —

DHT11 sensor x 1 —

BMP180 sensor x 1 —

Rain sensor x 1 —

Breadboard x 1 —

Jumper wires —

Secondly, connect these components. To do this, use


the circuit diagram below.
Thirdly, we set up the Thingspeak app. To do this, follow the steps below.

First, go to the Thingspeak website and create a new account using your email
address. Then, click the “New channel” button.
Next, enter your project name as you like. Then, activate the four fields and
name them Temperature, Humidity, Pressure, and Rainfall respectively. After,
click the “Save channel” button.

Now, let’s create the program for this project.


WI-Fi library -
BMP180 library-
DHT11 library-

code
#include <SFE_BMP180.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include "DHT.h"

DHT dht(D3, DHT11);


SFE_BMP180 bmp;
double T, P;
char status;
WiFiClient client;

String apiKey = "";


const char *ssid = "";
const char *pass = "";
const char* server = "api.thingspeak.com";

void setup() {
Serial.begin(115200);
delay(10);
bmp.begin();
Wire.begin();
dht.begin();
WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}

void loop() {
//BMP180 sensor
status = bmp.startTemperature();
if (status != 0) {
delay(status);
status = bmp.getTemperature(T);

status = bmp.startPressure(3);// 0 to 3
if (status != 0) {
delay(status);
status = bmp.getPressure(P, T);
if (status != 0) {

}
}
}

//DHT11 sensor
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

//Rain sensor
int r = analogRead(A0);
r = map(r, 0, 1024, 0, 100);

if (client.connect(server, 80)) {
String postStr = apiKey;
postStr += "&field1=";
postStr += String(t);
postStr += "&field2=";
postStr += String(h);
postStr += "&field3=";
postStr += String(P, 2);
postStr += "&field4=";
postStr += String(r);
postStr += "\r\n\r\n\r\n\r\n";

client.print("POST /update HTTP/1.1\n");


client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey
+ "\n");
client.print("Content-Type: application/x-www-
form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n\n\n");
client.print(postStr);

Serial.print("Temperature: ");
Serial.println(t);
Serial.print("Humidity: ");
Serial.println(h);
Serial.print("absolute pressure: ");
Serial.print(P, 2);
Serial.println("mb");
Serial.print("Rain");
Serial.println(r);

}
client.stop();
delay(1000);
}
Next, select board and port. After, upload this code to the Nodemcu board.
Now, go back to the Thingspeak app and click the private view tab.
Now we can see the monitered Tempersture,Humidity,Pressure and can detect
Rain by this project.

thankyou

You might also like