Weather Monitoring Using API
Weather Monitoring Using API
Aim:
Components:
LCD 16 x 2 Display
Wi-Fi Module ESP 8266
Aurdino UNO R3 Board
Resistors
LED
Potentiometer
Power Supply
Wires
Procedure:
Open Tinkercad online and create account using Email
Select circuits under the side panel
Change file name
Open the Components library and draw the required components into the Workspace
Connect them properly
Open code in txt format and give the appropriate code.
Open Thinkspace Webpage
Create a Channel
Copy the Unique API key and Paste it in the code
Stimulate
Circuit:
Code:
// include the library code for LCD
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float value;
int pressureinbar = 0;
int setupESP8266(void) {
// Start our ESP8266 Serial Communication
Serial.begin(115200); // Serial connection over USB to computer
Serial.println("AT"); // Serial connection on Tx / Rx port to ESP8266
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 1;
}
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
setupESP8266();
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
value = analogRead(A0)*0.004882814;
value = (value - 0.5) * 100.0;
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.print(value);
lcd.print("C");
float pressureSensorVal = analogRead(A1);
float barVoltage = (pressureSensorVal/1024.0) * 5.0;
if (pressureSensorVal < 102.00 || pressureSensorVal == 102.00){ pressureinbar = 0;
}
else {
float pressureinbarToRound = ((barVoltage * 155.0) / 0.5) * 1.333 ;
pressureinbar = (int)roundf(pressureinbarToRound);
}
lcd.setCursor(0,1);
lcd.print("Pressure:");
lcd.print(pressureinbar);
lcd.print("mb");
anydata(pressureinbar);
delay(10);
}
Output:
Inference:
From the above graphs we can see the temperature and pressure variations at
different time intervals. To view the change in pressure we vary the voltage of the power supply and to
view the change in temperature we slide the controls over the temperature
sensor.
Result:
The output graphs have been obtained and verified.