Skip to main content

Wireless Weather Station

Wireless weather station using Arduino 

Dear friends welcome back! Today we are going to build a wireless weather station project using Arduino.Without any further delay, let’s get started!  A Wireless Weather Station with a big 3.2” Color TFT display.

The project is up and running,and it displays the current date and time, the indoor temperature and humidity, and the outdoor temperature and humidity. The readings of the outdoor sensor are updated every second in order to demonstrate that we have a reliable communication link established with the transmitter which is outside at a distance of 5m. The readings of the indoor sensor are updated once every minute. The heart of the project is the fast Arduino Due, there is no flickering of the screen when the values are updated. Let’s now see the transmitter. 

The transmitter is much simpler. It consists of an Arduino Nano, a DHT22 sensor and the NRF24L01 wireless transceiver module. The transmitter reads the temperature and the humidity every second, and sends them to the receiver via the NRF24L01 module. This is a one way communication link, we don’t know if the receiver actually receives the data, but we send new data every second, so in case we miss a package we are going to receive another one soon. Let’s now see how to build this project.

 The parts needed for this project are these:
• An Arduino Due or a Mega
 • An Arduino Nano
• A 3.2” Color TFT display
 • 2 DHT22 sensors
• A DS3231 RTC module 
• 2 NRF24L01 Wireless transceiver modules
• 2 Breadboards 
• Some header pins
•some wires 
The cost of the project is around 40$. You can lower the cost of the project by 5$ if you use the Arduino Mega instead of the Arduino Due. I haven’t tested it, but it should work fine as well but it will be much slower.Let’s now connect all the parts together. Before we start I highly recommend you to have knowledge of electronics. That’s a difficult project for beginners, there are many things that can go wrong, so it requires some experience.

 Let’s first build the transmitter. It is very simple. We connect the output pin of the sensor to digital pin 4 of the Arduino Nano. We connect the Ground and Vcc and we are ready. All we have to do now is to connect the NRF24L01 wireless module. Please see the NRF24L01 tutorial before going forward in order to see how to connect it. The receiver part is a bit trickier. We have to use 7 header pins and bend them like that. Then we have to place them at the following pins. We need one to Ground and one to 3.3V. We need two at the I2C pins. We need the remaining 3 to digital pins from 6 to 8. We also have to solder three wires to the hardware SPI pins of the Arduino Due pins. We need MOSI, MISO and SCK. 
Connections:

  • Connecting the DS3231

  1. VCC pin on Arduino’s 3.3V output
  2. GND pin to Arduino’s GND 
  3. SDA (Serial Data Line) pin to Arduino’s SDA pin 
  4. SCL (Serial Clock Line) pin to Arduino’s SCL pin                        

  • Connecting the DHT22 Sensor

  1. VCC pin on Arduino’s 3.3V output
  2. GND pin to Arduino’s GND and
  3. output pin to Arduino's digital pin 8

  • Connecting the NRF24L01 module
  1. GND pin to Arduino’s GND
  2. VCC pin to Arduino 3.3V
  3. 3rd pin to Arduino's digital pin 6
  4. 4th pin to Arduino's digital pin 7
  5. 5th pin to SCK pin 
  6. 6th pin to MOSI pin 
  7. 7th pin to MISO pin 

Check the diagram carefully.We can’t use female wires since the display won’t fit with the wires attached. We connect the wires to the header pins and we are ready to attach the display.We connect GND and 3.3V to the breadboard. Next we connect the GND and VCC of the DHT22 module and the DS3231 module to the breadboard GND rail and Vcc rail. Next we connect the I2C pins of the Real Time clock to I2C wires and the output pin of the DHT22 sensor to digital pin 8. That’s it, all we have to do now is to connect the NRF24L01 module.The first pin is GND, so it goes to breadboard GND. The next pin is Vcc so it goes to the breadboard Vcc. Be careful though, the module will be destroyed if you connect it to 5V so be sure that you are providing 3.3V to breadboard rail. The next pin goes to digitalpin 6. The fourth pin goes to digital pin 7. The fifth pin goes to the hardware SCKpin that we have soldered earlier. The 6th pin goes to MOSI, and the 7th to MISO. The last pin stays unconnected! That’s it, we are now ready to power up both the transmitter and the receiver! If everything went well, we are going to see live data on the display. Cool, everything works fine! It wasn’t that difficult, was it?

 Let’s now see the code of the project. The transmitter code is very simple. Please, be sure to use the correct library for the NRF24L01 module. Let’s now see the receiver code (All codes are attached below). We need 4 libraries. I now use a different library for the display which works great!  After downloading the library you have to open the User_Setup.h file comment line 13 and uncomment line 14 because the display we have is using the HX8357C driver. Now we can continue with the 3 other libraries. We need one library for the Real Time clock, one for the DHT22 sensor and lastly one for the Wireless module. Let’s see the code now. The first thing we have to do is to set the time to the real time clock module if it is not already set.In order to do it, enter the current date and time in this line of code, uncomment this line of code here and upload the program to Arduino. Now the time is set. But, then we have to comment this line of code again and upload the program to Arduino once more.The code of the receiver works like this. In the setup function we initialize all the sensors and the modules and we print the User Interface. Then at the loop function we continuously check for new wireless data. If there is new data we save that data in variables and print them on the display. We read the temperature and the humidity once a minute and we only update the display if there is a change in the values. This way we reduce flickering of the display even more! I have also prepared a version of the code with the temperature displayed in degrees Fahrenheit. As always you can find the code of the project in a link in the description of the video. As you can see, this project is a great demonstration of what open source hardware and software is capable of. Within a few hours one can build such an impressive project! Of course, this is a just the beginning. We can add many more features to the project. I will soon add a button, so we can display graphs, andhave different modes. We can also add more sensors, data logging, internet connection and so on. We are using the Arduino Due, so we have plenty of memory to implement many more things.

Code:

  • Arduino outdoor unit code:
  1. #include <SPI.h>
  2. #include <nRF24L01.h>
  3. #include <RF24.h>
  4. #include <dht.h>
  5. #include <LowPower.h>
  6. #define dataPin 8 // DHT22 data pin
  7. dht DHT; // Creates a DHT object
  8. RF24 radio(10, 9); // CE, CSN
  9. const byte address[6] = "00001";
  10. char thChar[32] = "";
  11. String thString = "";
  12. void setup() {
  13. radio.begin();
  14. radio.openWritingPipe(address);
  15. radio.setPALevel(RF24_PA_MIN);
  16. radio.stopListening();
  17. }
  18. void loop() {
  19. int readData = DHT.read22(dataPin); // Reads the data from the sensor
  20. int t = DHT.temperature; // Gets the values of the temperature
  21. int h = DHT.humidity; // Gets the values of the humidity
  22. thString = String(t) + String(h);
  23. thString.toCharArray(thChar, 12);
  24. // Sent the data wirelessly to the indoor unit
  25. for (int i = 0; i <= 3; i++) { // Send the data 3 times
  26. radio.write(&thChar, sizeof(thChar));
  27. delay(50);
  28. }
  29. // Sleep for 2 minutes, 15*8 = 120s
  30. for (int sleepCounter = 15; sleepCounter > 0; sleepCounter--)
  31. {
  32. LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  33. }
  34. }
  • Arduino indoor unit code:
  1. #include <SPI.h>
  2. #include <nRF24L01.h>
  3. #include <RF24.h>
  4. #include <dht.h>
  5. #include <DS3231.h>
  6. #include <U8g2lib.h>
  7. #include <Wire.h>
  8. #define dataPin 8 // DHT22 sensor
  9. dht DHT; // Creats a DHT object
  10. DS3231 rtc(SDA, SCL);
  11. U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
  12. RF24 radio(10, 9); // CE, CSN
  13. const byte address[6] = "00001";
  14. char text[6] = "";
  15. int readDHT22, t, h;
  16. String inTemp, inHum, outTemp, outHum;
  17. String rtcTime, rtcDate;
  18. int draw_state = 0;
  19. unsigned long previousMillis = 0;
  20. long interval = 3000;
  21. #define Temperature_20Icon_width 27
  22. #define Temperature_20Icon_height 47
  23. static const unsigned char Temperature_20Icon_bits[] U8X8_PROGMEM = {
  24. 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00,
  25. 0xc0, 0xe1, 0x00, 0x00, 0xe0, 0xc0, 0x01, 0x00, 0x60, 0x80, 0xf9, 0x03,
  26. 0x60, 0x80, 0x01, 0x00, 0x60, 0x80, 0x01, 0x00, 0x60, 0x80, 0x79, 0x00,
  27. 0x60, 0x80, 0x01, 0x00, 0x60, 0x80, 0x01, 0x00, 0x60, 0x80, 0xf9, 0x03,
  28. 0x60, 0x80, 0x01, 0x00, 0x60, 0x80, 0x01, 0x00, 0x60, 0x8c, 0x79, 0x00,
  29. 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0xf9, 0x03,
  30. 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x79, 0x00,
  31. 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0xf9, 0x03,
  32. 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x01, 0x00, 0x60, 0x9e, 0x01, 0x00,
  33. 0x70, 0x9e, 0x03, 0x00, 0x38, 0x1e, 0x07, 0x00, 0x18, 0x3e, 0x0e, 0x00,
  34. 0x1c, 0x3f, 0x0c, 0x00, 0x0c, 0x7f, 0x18, 0x00, 0x8c, 0xff, 0x18, 0x00,
  35. 0x8e, 0xff, 0x38, 0x00, 0xc6, 0xff, 0x31, 0x00, 0xc6, 0xff, 0x31, 0x00,
  36. 0xc6, 0xff, 0x31, 0x00, 0x8e, 0xff, 0x38, 0x00, 0x8c, 0xff, 0x18, 0x00,
  37. 0x0c, 0x7f, 0x1c, 0x00, 0x3c, 0x1c, 0x0e, 0x00, 0x78, 0x00, 0x06, 0x00,
  38. 0xe0, 0x80, 0x07, 0x00, 0xe0, 0xff, 0x03, 0x00, 0x80, 0xff, 0x00, 0x00,
  39. 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  40. };
  41. #define Humidity_20Icon_width 27
  42. #define Humidity_20Icon_height 47
  43. static const unsigned char Humidity_20Icon_bits[] U8X8_PROGMEM = {
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
  45. 0x00, 0x70, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00,
  46. 0x00, 0xdc, 0x01, 0x00, 0x00, 0x8e, 0x01, 0x00, 0x00, 0x86, 0x03, 0x00,
  47. 0x00, 0x06, 0x03, 0x00, 0x00, 0x03, 0x07, 0x00, 0x80, 0x03, 0x06, 0x00,
  48. 0x80, 0x01, 0x0c, 0x00, 0xc0, 0x01, 0x1c, 0x00, 0xc0, 0x00, 0x18, 0x00,
  49. 0xe0, 0x00, 0x38, 0x00, 0x60, 0x00, 0x30, 0x00, 0x70, 0x00, 0x70, 0x00,
  50. 0x30, 0x00, 0xe0, 0x00, 0x38, 0x00, 0xc0, 0x00, 0x18, 0x00, 0xc0, 0x01,
  51. 0x1c, 0x00, 0x80, 0x01, 0x0c, 0x00, 0x80, 0x03, 0x0e, 0x00, 0x80, 0x03,
  52. 0x06, 0x00, 0x00, 0x03, 0x06, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x07,
  53. 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
  54. 0x63, 0x00, 0x00, 0x06, 0x63, 0x00, 0x00, 0x06, 0x63, 0x00, 0x00, 0x06,
  55. 0xe3, 0x00, 0x00, 0x06, 0xc7, 0x00, 0x00, 0x06, 0xc6, 0x01, 0x00, 0x07,
  56. 0x86, 0x03, 0x00, 0x03, 0x0e, 0x1f, 0x00, 0x03, 0x0e, 0x1e, 0x80, 0x01,
  57. 0x1c, 0x00, 0xc0, 0x01, 0x38, 0x00, 0xe0, 0x00, 0x78, 0x00, 0x70, 0x00,
  58. 0xf0, 0x00, 0x38, 0x00, 0xe0, 0x07, 0x1f, 0x00, 0x80, 0xff, 0x0f, 0x00,
  59. 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
  60. };
  61. void setup() {
  62. radio.begin();
  63. radio.openReadingPipe(0, address);
  64. radio.setPALevel(RF24_PA_MIN);
  65. radio.startListening();
  66. u8g2.begin();
  67. rtc.begin();
  68. }
  69. void loop() {
  70. if (radio.available()) {
  71. radio.read(&text, sizeof(text)); // Read incoming data
  72. outTemp = String(text[0]) + String(text[1]) + char(176) + "C"; // Outdoor Temperature
  73. outHum = String(text[2]) + String(text[3]) + "%"; // Outdoor Humidity
  74. }
  75. unsigned long currentMillis = millis();
  76. if (currentMillis - previousMillis > interval) {
  77. previousMillis = currentMillis;
  78. u8g2.firstPage();
  79. do {
  80. switch (draw_state ) {
  81. case 0: drawDate(); break;
  82. case 1: drawInTemperature(); break;
  83. case 2: drawInHumidity(); break;
  84. case 3: drawOutTemperature(); break;
  85. case 4: drawOutHumidity(); break;
  86. }
  87. } while ( u8g2.nextPage() );
  88. draw_state++;
  89. if (draw_state > 4) {
  90. draw_state = 0;
  91. }
  92. }
  93. }
  94. void drawDate() {
  95. String dowa = rtc.getDOWStr();
  96. dowa.remove(3);
  97. rtcDate = dowa + " " + rtc.getDateStr();
  98. u8g2.setFont(u8g2_font_timB14_tr);
  99. u8g2.setCursor(0, 15);
  100. rtcTime = rtc.getTimeStr(); // DS3231 RTC time
  101. rtcTime.remove(5);
  102. u8g2.print(rtcDate);
  103. u8g2.setFont(u8g2_font_fub30_tf);
  104. u8g2.setCursor(8, 58);
  105. u8g2.print(rtcTime);
  106. }
  107. void drawInTemperature() {
  108. readDHT22 = DHT.read22(dataPin); // Reads the data from the sensor
  109. t = DHT.temperature; // Gets the values of the temperature
  110. inTemp = String(t) + char(176) + "C";
  111. u8g2.setFont(u8g2_font_helvR14_tr);
  112. u8g2.setCursor(24, 15);
  113. u8g2.print("INDOOR");
  114. u8g2.setFont(u8g2_font_fub30_tf);
  115. u8g2.setCursor(36, 58);
  116. u8g2.print(inTemp);
  117. u8g2.drawXBMP( 0, 17, Temperature_20Icon_width, Temperature_20Icon_height, Temperature_20Icon_bits);
  118. }
  119. void drawInHumidity() {
  120. h = DHT.humidity; // Gets the values of the humidity
  121. inHum = String(h) + "%";
  122. u8g2.setFont(u8g2_font_helvR14_tr);
  123. u8g2.setCursor(24, 15);
  124. u8g2.print("INDOOR");
  125. u8g2.setFont(u8g2_font_fub30_tf);
  126. u8g2.setCursor(36, 58);
  127. u8g2.print(inHum);
  128. u8g2.drawXBMP( 0, 17, Humidity_20Icon_width, Humidity_20Icon_height, Humidity_20Icon_bits);
  129. }
  130. void drawOutTemperature() {
  131. u8g2.setFont(u8g2_font_helvR14_tr);
  132. u8g2.setCursor(12, 15);
  133. u8g2.print("OUTDOOR");
  134. u8g2.setFont(u8g2_font_fub30_tf);
  135. u8g2.setCursor(36, 58);
  136. u8g2.print(outTemp);
  137. u8g2.drawXBMP( 0, 17, Temperature_20Icon_width, Temperature_20Icon_height, Temperature_20Icon_bits);
  138. }
  139. void drawOutHumidity() {
  140. u8g2.setFont(u8g2_font_helvR14_tr);
  141. u8g2.setCursor(12, 15);
  142. u8g2.print("OUTDOOR");
  143. u8g2.setFont(u8g2_font_fub30_tf);
  144. u8g2.setCursor(36, 58);
  145. u8g2.print(outHum);
  146. u8g2.drawXBMP( 0, 17, Humidity_20Icon_width, Humidity_20Icon_height, Humidity_20Icon_bits);
  147. }
You can directly copy this code to implement it foryour project.That is it for todays blog,see you in the next one.And I would love to hear your opinion on this project. How do you want to see it evolve? Please post your comments or ideas in the comments section below! Thank you! On this Blog I post a DIY projects every Alternative day. I love making things and I believe that anyone can make things, anyone can become a maker. That’s why I created this Blog, in order to share my knowledge with the community and learn from the community. I hope you will join us back. Until than, Read, Learn, Build! 

Comments

Post a Comment

If you have any doubts ,Please let me know.

amazon banner

Popular posts from this blog

Motion Detector Camera

Motion Detector With Photo Capture Camera   Hello friends!! Welcome to This Blog. In this Blog, we will make a motion sensor detector with photo capture using ESP32CAM and the PIR module. The logic behind is when the PIR sensor detects any motion, the ESP32CAM will start taking the pictures. So you can use this project as a security camera. In thisblog, I will share the circuitdiagram, Arduino sketch, and the component list, so after reading the complete article you can easily make this project. Now ESP32 CAM is a small camera module that has ESP32S chip on the back and some GPIO pins to connect peripherals and it also has a micro-SD card slot, where you can insert the micro-SD card and store the pictures. Now before going to the circuit diagram and Arduino sketch, let me give you a quick overview of this project.  Components Required ESP32-CAM  PIR Motion Sensor Module BC547 NPN Transistor 220ohm, 1k, 10k Resistor. LED 5-mm FTDI 232 USB to Serial Interface board 5 volt DC supply  The

Bidirectional Visitor Counter

Bidirectional Visitor Counter using Arduino A bidirectional visitor counter using Arduino may be a reliable circuit that takes over the task of counting variety of Persons/Visitors within the Room very accurately. if somebody enters into the space then the Counter is incremented by one and also leaves it might be incremented. MATERIALS REQUIRED: Arduino IR Module 16*2 LED 5V Relay Resistor(1K,220 ohm) Breadboard Jumper Wires The total number of persons inside the space is Shows on the 16X2 LCD module. The microcontroller does the work it receives the signals from the sensors, and this signals operated under the control of software which is stored in EPROM of Arduino. There are two IR Modules are used. first, one are often wont to count the amount of persons entering a hall within the up mode at the doorway gate. and therefore the other can count the amount of persons leaving the hall by decrementing the count at the exit gate. In this Project will helps to Wastage of electricity. In ou

Obstacle Avoiding Robot

Obstacle Avoiding Robot using Arduino and Ultrasonic Sensor A simple project on Obstacle Avoiding Robot is meant here. Robotics is a stimulating and fast growing field. Being a branch of engineering, the applications of robotics are increasing with the advancement of technology.The concept of Mobile Robot is fast evolving and therefore the number of mobile robots and their complexities are increasing with different applications. There are many kind of mobile robot navigation techniques like path planning, self – localization and map interpreting. An Obstacle Avoiding Robot may be a sort of autonomous mobile robot that avoids collision with unexpected obstacles. In this project, an Obstacle Avoiding Robot is supposed. It's an Arduino based robot that uses Ultrasonic range finder sensors to avoid collisions.  Components Required Arduino NANO or Uno  🛒 HC-SR04 Ultrasonic Sensor  🛒 LM298N Motor Driver Module  🛒 5V DC Motors  🛒 Battery  🛒 Wheels 🛒 Chassis  🛒 Jumper Wires  🛒 Circ