Weather monitoring and forecasting have been around for hundreds of years using tinkerCAD. Initially, observation and intuition was the key to understand the climatic changes. (In modern times), the parameters for weather forecasting remain the same: temperature, pressure, wind and humidity but the tools to measure them have come a long way. Satellite communication and sensor arrays have facilitated the monitoring of atmospheric conditions with extreme accuracy.
This project simulates a basic weather monitoring system using a temperature sensor and a gas sensor on the IoT simulation software, TinkerCAD. The data obtained from the sensors is also visualize on the ThingSpeak dashboard.
Sensors Used:
- TMP 36: This temperature sensor is a low voltage, centigrade temperature sensor which provides a linear output. It can provide ±1°C for temperature up to 25°C and around ±2°C for temperature ranges over -40°C and +125°C. The output voltage is 750mV from a 2.7V supply.
- Gas sensor: TinkerCAD does not offer a specific gas sensor but the MQ series of gas sensors can be used based on the concentration of gas that you wish to measure (To know more about the MQ range of sensors visit the given link https://playground.arduino.cc/Main/MQGasSensors/ ). When the concentration of the gas being measured is found using a voltage divider. The conductance of the sensor is low in clean air which increases with the rise of concentration of the target gas in its atmosphere.
- ESP8266: The ESP8266 is a user-friendly SOC with TCP/IP protocol stack to provide internet connectivity. The board can both work as an access point and as a station which makes it easy to fetch data. The module works with 3.3V. The module has now been discontinue from TinkerCad but it can be source from an existing project.
Hardware Connections:
The Arduino UNO pin connections for all the sensors use in the project are list below.
TMP36 Sensor Pins | Description | Arduino Connection |
Vs | Positive supply pin | 5V |
Vout | Output voltage pin | A0 |
GND | Ground pin | GND |
The gas sensor has six pins in which four of them use to fetch signals and two are use to provide heating current. Most of the MQ sensors commercially available have a breakout board which can reduce the configuration from 6 pins to 4 pins as shown below.
Gas Sensor Pins | Description | Arduino Connection |
Vcc | Positive supply pin | 5V |
GND | Ground pin | GND |
Digital Out | Used to monitor the digital switching from HIGH to LOW when a set threshold is reached. | GND |
Analog Out | Outputs a voltage proportional to the concentration of gas | A1 |
The pin configuration for the third element, the WiFi module ESP8266 is mention below. To know more about the details of the pin connection and the module visit the link:
https://components101.com/wireless/esp8266-pinout-configuration-features-datasheet
ESP8266 Pin Configuration | Description | Arduino Connection. |
Ground | Connection to the ground of the circuit | GND |
TX | Connected to Rx pin of the programmer to upload the programme | 0 / RX |
GPIO-2 | General-purpose input and output | – |
CH_EN | Chip Enable – Active High | 3.3V |
GPIO-0/Flash | General-purpose input and output. | – |
Reset | Resets the module. | – |
RX | Connected to the TX pin of the Arduino. Used to receive programmes from the microcontroller. | 1 / TX |
Vcc | Positive supply pin | 3.3V |
The final connections are shown in the given circuit diagram (connected on TinkerCAD )
Setting up the WiFi Module using TinkerCAD: (Check Here)
The code begins with declaring the required variables where
- Sensor → Gas sensor reading
- SensorValue → Converted value of the gas sensor input
- Vout and Vout1 → Converted temperature sensor values
Variables to set up the connection between the TinkerCAD circuit and ThingSpeak are also specified.
The function setupESP8266 helps establish the internet connection on the module.
After setting up the serial communication between the Arduino board and the serial monitor, the connection established can be checked by typing “AT”. If the response is “OK” then the connection has been set up successfully.
The number 115200 is the baud rate of the WiFi module. For convenience, the baud rate can be changed to 9600.
(Check out the link to know more about configuring the ESP8266 https://create.arduino.cc/projecthub/user16726/configuring-the-esp8266-using-an-arduino-0ab2e6)
The code inside the void setup is only run once as soon the programme starts running. The setup for the ESP8266 is initialized and pinMode for the sensors and LED are initialized.
Collecting Sensor Data and Sending Data to ThingSpeak | TinkerCAD
As given on their website, ThingSpeak is an IoT analytics platform that allows the user to aggregate, visualize and analyze live data streams in the cloud.
The function postData is used to send the data from the Arduino board to the ThingSpeak platform using the ThingSpeak API.
The void loop() runs infinitely after starting the programme. It is used to actively control the Arduino board.
A LED is used to warn the user in case the temperature crosses a given threshold value.
The whole structure of the code is given below:
ThingSpeak Dashboard
To create a channel on ThingsSpeak, you first need to have a MathWorks account.
After creating an account, go to “Channels” and create a new channel. You can customise the fields that you want to add in a channel (There is an option to add widgets too!)
The write API KEy can be obtained from the “API keys” section.
The circuit and dashboard can be improvised to obtain more factors to monitor the weather. If you found the project useful do let us know in comments below.
Written by Suchitra Srinivasan.
Reviewed by Batta Pruthvi.