0% found this document useful (0 votes)
14 views

Microcontroller Based Embedded System

weather station

Uploaded by

anshgarg061120
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Microcontroller Based Embedded System

weather station

Uploaded by

anshgarg061120
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Weather Station Parts and Their Interfacing

1. SHT-45 Sensor (Temperature and Humidity)


 The SHT45 sensor probe is a high-accuracy, ultra-low-power, 16-bit
relative humidity and temperature sensor probe for measuring relative
humidity and temperature at different environmental conditions.

 The sensor communicates via I2C interface, ensuring easy integration with
microcontrollers like the ESP32.

 The SHT45 offers a typical accuracy of ±0.1°C and humidity measurement


accuracy is ±1.0% RH.

Connections:

 Power Supply:

VCC (SHT45) to 3.3V (ESP32)

GND (SHT45) to GND (ESP32)

 I2C Communication Lines:

SDA (SHT45) to GPIO 21 (ESP32 SDA)

SCL (SHT45) to GPIO 22 (ESP32 SCL)

Figure 1

Page 1 of 16
Code for SHT- 45

 The code interfaces an ESP32 with an SHT45 sensor via I2C.


 Custom SDA (pin 33) and SCL (pin 32) pins are defined.
 The ArtronShop_SHT45 library is used for sensor operations.
 Initializes the Wire library with the specified pins during setup.
 Attempts to connect to the SHT45 sensor, printing "SHT45 not found!" if
unsuccessful.
 In the loop, it reads temperature and humidity data every second.
 Prints the temperature and humidity values to the Serial Monitor.
 Displays "SHT45 read error" if data reading fails.

Page 2 of 16
2. Anemometer (Wind Speed)

 An anemometer typically has three arms with scoops that catch the wind,
causing the arms to spin.

 A small magnet is attached to the underside of the anemometer, which


influences a reed switch.

 The reed switch forms a closed circuit each time the magnet passes,
allowing the number of signals to be used to calculate the spin speed.

Connections

 Connect the VCC and GND Pin of Anemometer to external VIN & GND.

 Connect GPIO34(ADC) with reading pin.

 Connect a pull up resistor of 10K with GND

Figure 2

Page 3 of 16
Code for Anemometer

 Setup: Initializes serial communication at 115200 baud rate in the setup()


function.
 Measurement Function (measure()): Uses an interrupt to count pulses on
SensorPin (pin 34) over RecordTime seconds to determine wind speed.
 Serial Output: In the loop() function, continuously calls measure() and
prints the calculated wind speed in kilometers per hour (km/h) and meters
per second (m/s) to the serial monitor.
 Interrupt Handler (countup()): Increments InterruptCounter each time the
sensor detects a pulse.
 Serial Output: Continuously calls measure() in loop() to update and
display wind speed readings in km/h and m/s on the serial monitor.

Page 4 of 16
3. Rain Gauge Sensor

Figure 3

 Used to measure the amount of precipitation over a period of time

 Tipping bucket rain gauges use a bucket mechanism that tips when filled with
rainwater, activating a magnet near a reed switch.

 The reed switch's closure creates a circuit change detected by the ESP32,
which counts these closures as tips.

Connections

 Pull-up Resistor: Connect 10kΩ resistor between GPIO 33 and 3.3V pin.

 Power Supply: Connect ESP32 3.3V pin to rain gauge’s 3.3V input.

 Ground Connection: Connect ESP32 GND pin to rain gauge ground


terminal.

Figure 4

Page 5 of 16
Code for Rain Gauge

 rainPin Definition: Defines the GPIO pin (pin 33) connected to the rain gauge
sensor.
 rainCount Variable: Tracks the number of rain gauge tip events using an
interrupt-driven approach.
 rainISR Function: Interrupt Service Routine (ISR) called when the rain gauge
tips, incrementing rainCount with debounce handling to avoid multiple counts
from a single event.
 Setup Function: Configures serial communication, sets up rainPin as an input
with pull-up resistor, and attaches an interrupt to rainISR triggered on a falling
edge (tip of the rain gauge).
 Loop Function: Periodically calculates and prints the total rainfall based
on rainCount, converting the count to millimeters using a conversion factor
of 0.2794 per tip, ensuring accurate measurement over time.

Page 6 of 16
4. Wind Vane

 Wind vanes determine wind direction by rotating a vertical blade in response to


wind force, aligning with the direction of least resistance. This alignment
indicates the wind's incoming direction, not its outgoing path.

 Utilizes reed switches and a magnet. As the vane rotates, the magnet's position
changes relative to the reed switch, creating electrical signals that indicate the
wind direction.

 Connects to electronic circuits or microcontrollers (like the ESP32) to


process signals and provide real-time wind direction data, crucial for
weather monitoring and analysis.

Connections

 Pull-up Resistor: Connect a 10kΩ resistor between GPIO 35 and 3.3V


pin.

 Power Supply: Connect ESP32 3.3V pin to Wind Vane’s 3.3V input.

 Ground Connection: Connect ESP32 GND pin to Wind Wane’s ground


terminal.

Figure 5

Page 7 of 16
Code for Wind Vane

 The code sets up an analog pin to read the voltage from a wind vane.

 Converts the voltage reading to a digital value. The digital value is then used to
determine the wind direction.

 Maps the digital value to a wind direction. For example, a digital value between
675 and 1100 corresponds to a north wind.

 It prints the wind direction to the serial monitor. The serial monitor is a tool that
can be used to view the output of the code.

Page 8 of 16
5. Particulate Matter 2.5

 Measures the concentration of fine particulate matter (≤2.5


micrometers) in the air, which is important for assessing air quality and
potential health risks such as respiratory and cardiovascular issues.

 Works using laser scattering: a laser beam is directed at air particles,


and the scattered light is detected by a photodetector. The intensity and
pattern of the scattered light are analyzed to determine the
concentration and size of the particles.

 Provides real-time data on PM2.5 levels, typically displayed in


micrograms per cubic meter (µg/m³), which can be used to monitor and
improve air quality in both outdoor and indoor environments.

Figure 6

Connections

• Connect the VCC and GND pins of the PM2.5 sensor to the 3.3V and GND
pins of the ESP32.
• Connect the UART TX pin of the PM2.5 sensor to the RX pin (GPIO16) of the
ESP32.
• Connect the UART RX pin of the PM2.5 sensor to the TX pin (GPIO17) of the

Figure 7
ESP32.
Page 9 of 16
Code for PM2.5

 Initializes UART communication on ESP32 GPIO pins.


 Configures UART settings (baud rate, data bits, etc.).
 Reads data continuously from UART RX buffer.
 Parses incoming data to extract PM2.5 concentration values.
 Utilizes parsed data for display, logging, or triggering actions.
 Implements error handling for communication reliability.
 Runs continuously to monitor real-time PM2.5 levels.

Page 10 of 16
6. 4G Module
The 4G module is a wireless communication device that uses the fourth
generation of mobile communication technology, namely LTE (Long Term
Evolution). Through the 4G module, users can quickly and stably achieve
wireless connections around the world and enjoy high-speed, high-quality data
transmission services.

Figure 8

Connections

● RX(16) PIN OF ESP32 CONNECTED WITH TX PIN OF A7670C


● TX (17) PIN OF ESP32 CONNECTED WITH RX PIN OF A7670C
● VCC PIN OF ESP32 TO VCC OF A7670C
● GND PIN OF ESP32 TO GND OF A7670C

Page 11 of 16
Figure 9

IoT Application For Data Showcasing

Figure 10

ThingSpeak is an IoT platform that allows you to collect, visualize, and analyze data
from sensors or devices in real-time. It provides tools for data logging, charting, and
data analysis, making it easy to monitor and understand trends from your connected
devices or sensors. ThingSpeak is often used for applications such as environmental
monitoring, smart agriculture, and industrial IoT projects due to its simplicity and
integration capabilities with various hardware and software platforms.

Important Features-

 Real-time Data Collection: Collects data from sensors and devices in real-
time.
Page 12 of 16
 Visualization Tools: Provides tools for creating charts and graphs to
visualize data trends.
 Data Analysis Capabilities: Includes built-in features for analyzing
collected data.
 Integration with IoT Devices: Integrates easily with a wide range of IoT
devices and platforms.
 API Access: Offers APIs for easy integration and programmable access
to data.

Conclusion

Our weather station project is designed to provide comprehensive environmental


monitoring by integrating a variety of sensors. The SHT45 sensor measures
temperature and humidity, the PM2.5 sensor monitors air quality, and additional
sensors include a rain gauge, wind vane, and wind speed sensor. Data collected from
these sensors is transmitted via a 4G module and displayed on ThingSpeak for real-
time visualization and analysis, ensuring a robust and reliable system for tracking
weather conditions.

Key components of our system include the use of high-precision sensors and advanced
communication technology. The SHT45 and PM2.5 sensors provide accurate
measurements of temperature, humidity, and air quality, while the rain gauge, wind
vane, and wind speed sensors offer detailed insights into weather patterns. The
integration of a 4G module ensures continuous data transmission, and ThingSpeak
serves as the platform for data visualization. Future enhancements include the addition
of a Peltier module to control the system's temperature and an SD card for local data
storage, ensuring the system's resilience and reliability.

Looking ahead, the second phase of our project will focus on implementing ICA
algorithms to analyze the collected data more deeply. By applying these algorithms, we
aim to uncover hidden patterns and relationships within the data, providing more
insightful and actionable information. This advanced analysis will enhance the
functionality of our weather station, enabling it to not only monitor but also predict
environmental changes more accurately.

References
Page 13 of 16
 1. Weather Shack. (2002). Ed tipping bucket rain gauge. Retrieved from
[https://www.weathershack.com/static/ed-tipping-bucket-rain-gauge.html]

 2. Raspberry Pi Foundation. (2016). Build your own weather station.


Retrieved from [https://projects.raspberrypi.org/en/projects/build-your-
own-weather-station/8]

 3. Circuit Digest. (2018). Getting started with ESP32 using the Arduino
IDE. Retrieved from
[https://circuitdigest.com/microcontroller-projects/getting-started-with-
esp32-with-arduino-ide]

 4. How2Electronics. (2023). Measure wind speed with anemometer on


ESP32 with TFT display. Retrieved from
[https://how2electronics.com/measure-wind-speed-with-anemometer-on-
esp32-tft-display/]

 5. Central Electronics Engineering Research Institute. (1953). Retrieved


from [https://www.ceeri.res.in/]

Page 14 of 16
Glossary

 Arduino IDE: Integrated Development Environment used for programming


microcontrollers like the ESP32, providing a user-friendly platform for
writing and uploading code.
 I2C (Inter-Integrated Circuit): A communication protocol that allows multiple
chips to communicate with each other using two wires.
 ICA (Independent Component Analysis): A computational method for
separating a multivariate signal into additive, independent components,
used for uncovering hidden patterns in data.
 IoT (Internet of Things): A network of physical devices that communicate
and exchange data over the internet, enabling remote monitoring and
control.
 Analog-to-Digital Converter (ADC): A device that converts an analog signal
(such as voltage) into a digital signal that can be processed by a
microcontroller.
 Baud Rate: The rate at which information is transferred in a communication
channel, measured in bits per second (bps).
 Debounce: The process of eliminating noise from a digital signal, ensuring
accurate readings by ignoring fluctuations that occur during a transition.
 HTTP Protocol: The Hypertext Transfer Protocol used for transmitting data
over the web, enabling communication between devices and servers.
 Reed Switch: An electrical switch operated by an applied magnetic field,
used in instruments like anemometers and rain gauges for detecting
motion or presence.
 UART (Universal Asynchronous Receiver-Transmitter): A hardware
communication protocol used for serial communication between devices.

Page 15 of 16
VCC

Anemometer

VCC
Wind Vane
GPIO21
ESP32
SHT 45
GPIO22
RX2 TX2

PM2.5

Rain Gauge

Page 16 of 16

You might also like