Project tutorial
How To Make An Mini IOT Weather Station

How To Make An Mini IOT Weather Station © CC BY-NC-SA

Let's make a little portable IoT weather station for under $20 using Arduino and the Blynk library!

  • 6,724 views
  • 4 comments
  • 18 respects

Components and supplies

Apps and online services

About this project

Let's make a little portable IoT weather station for under $20 using Arduino and the Blynk library! It uses the 433Mhz transmitter so if you want you can use multiple clients like a LCD screen in your living room and another in your kitchen. I made the code simple enough that most people can hack it to do whatever they want... Lets get started making!

You will need the following parts:

  • 433Mhz Tx and Rx
  • Arduino Uno
  • Arduino Ethernet Shield
  • Arduino Nano
  • DHT11
  • 4x AAA battery pack
  • Wires

Step 1: Prep the battery pack

We're going to make the battery easy to remove so we can change the batteries. I soldered a connector directly to the battery pack so there wouldn't be much slack.

Step 2: Add a antenna to the TX 433mhz chip

The length doesn't matter. The longer it is the further it can transmit, to an extent. I used a 4" solid piece of wire.

Step 3: Program the Arduino Nano

Download the code or view it here:

#include <VirtualWire.h> //Download Here#include "DHT.h"DHT dht(2, DHT11);int Sensor1Data;
int Sensor2Data;
char Sensor1CharMsg[4];
char Sensor2CharMsg[4];void setup()
{
  vw_set_ptt_inverted(true);  // Required by the RF module
  vw_setup(2000);            // bps connection speed
  vw_set_tx_pin(3);         // Arduino pin to connect the receiver data pin  //Serial.begin(9600); //uncomment to debug
  dht.begin();
  Serial.println();}void loop()
{
  Serial.println("\n");  Sensor1Data = dht.readTemperature(true);
  Sensor2Data = dht.readHumidity();
  delay(2000);
  // Convert integer data to Char array directly
  itoa(Sensor1Data, Sensor1CharMsg, 10);
  itoa(Sensor2Data, Sensor2CharMsg, 10);  Serial.print("Read sensor: ");  char astr[4] = {'t', 'e', 'm', 'p',};
  char bstr[4] = {'h', 'u', 'm', 'i',};
  Serial.print("Humidity (%): ");
  Serial.println((float)dht.readHumidity(), 2);  Serial.print("Temperature (oC): ");
  Serial.println((float)dht.readTemperature(true), 2);  delay(1000);  //Message to send:
  digitalWrite(13, true); // Turn on a light to show transmitting
  vw_send((uint8_t *)astr, 4);  
  vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));
  vw_send((uint8_t *)bstr, 4);
  vw_send((uint8_t *)Sensor2CharMsg, strlen(Sensor2CharMsg));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, false); // Turn off a light after transmission
  delay(9000);
}

Step 4: Print the sun cover

I scaled the files down by 50% but you don't need to. When assembling it make sure to run the wire through early so it doesn't add to much stress on it.

Download the files here in the stl folder.

Step 5: Solder the wires on to the Arduino Nano

  • The DHT11 - (Power goes to 5v on the Nano, GND goes to GND on the Nano, and signal goes to D2 on the Nano)
  • The 433 TX - (Power goes to 5v on the nano, GND goes to GND on the Nano, and Data goes to D3 on the Nano)
  • The Battery Pack connects to Vin and GND

Step 6: Pack it up

I found a 'REALLY USEFUL BOX' at my local Staples that fit it perfect I put every thing inside (power on) and closed it up then connected the Sun Shield to it with duck tape.

Step 7: Setup the receiver UNO

Download the Blynk Library. Download VirtualWire Library from Here. Download the Code from Here or view the code below:

#include <SPI.h>#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <VirtualWire.h>
#include <Wire.h>int TEMP;int tempurature;
int humidity;char auth[] = "9bb52b5cfa6b4c4bbcde617a64886ed5";void setup()
{
  Serial.begin(9600);
  vw_set_rx_pin(2);
  vw_setup(2000);
  vw_rx_start();
  Blynk.begin(auth);
}void loop()
{
  Blynk.run();
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {    int i;
    char c;
    String input;
    for (i = 0; i < buflen; i++)
    {
      c = ((char)buf[i]);
      input += ((char)buf[i]);
      //Serial.print((char)buf[i]);
    }
    if (c == 'p') {
      Serial.print("TEMPURATURE CHECK");
      TEMP = true;
    }
    if (c == 'i') {
      Serial.print("HUMIDITY CHECK");
      TEMP = false;
    }
    if (c != 'p' && c != 'i') {
      if (TEMP == true) {
        tempurature = input.toInt();
        if (tempurature != humidity) {
          Blynk.virtualWrite(V12, tempurature);
        }
        Serial.print(tempurature);
      }
      else {
        humidity = input.toInt();
        if (tempurature != humidity) {
          Blynk.virtualWrite(V13, humidity);
        }
        Serial.print(humidity);
        /*double celsius = (tempurature - 32) * 5/9;
          double a = 17.271;
          double b = 237.7;
          double temp2 = (a * celsius) / (b + celsius) + log(humidity*0.01);
          double Td = (b * temp2) / (a - temp2);
          Td = ((Td*9) / 5) + 32;
          Blynk.virtualWrite(V14, Td);
        */
      }
    }    Serial.println();  }
}

Step 8: Test out everything

If you open the RX serial port you should see something like what is shown in the first picture, if now check your wiring. On the Blynk app you should see the same data as what is coming through the serial port.

IF YOU WANT TO COPY THE LAYOUT CLICK HERE.

I hope you liked this project it took over 3 weeks for me to make, if you have any questions leave them in the comments and I will try to answer them!

Code

Code snippet #1Plain text
#include <VirtualWire.h> //Download Here#include "DHT.h"DHT dht(2, DHT11);int Sensor1Data;
int Sensor2Data;
char Sensor1CharMsg[4];
char Sensor2CharMsg[4];void setup()
{
  vw_set_ptt_inverted(true);  // Required by the RF module
  vw_setup(2000);            // bps connection speed
  vw_set_tx_pin(3);         // Arduino pin to connect the receiver data pin  //Serial.begin(9600); //uncomment to debug
  dht.begin();
  Serial.println();}void loop()
{
  Serial.println("\n");  Sensor1Data = dht.readTemperature(true);
  Sensor2Data = dht.readHumidity();
  delay(2000);
  // Convert integer data to Char array directly
  itoa(Sensor1Data, Sensor1CharMsg, 10);
  itoa(Sensor2Data, Sensor2CharMsg, 10);  Serial.print("Read sensor: ");  char astr[4] = {'t', 'e', 'm', 'p',};
  char bstr[4] = {'h', 'u', 'm', 'i',};
  Serial.print("Humidity (%): ");
  Serial.println((float)dht.readHumidity(), 2);  Serial.print("Temperature (oC): ");
  Serial.println((float)dht.readTemperature(true), 2);  delay(1000);  //Message to send:
  digitalWrite(13, true); // Turn on a light to show transmitting
  vw_send((uint8_t *)astr, 4);  
  vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));
  vw_send((uint8_t *)bstr, 4);
  vw_send((uint8_t *)Sensor2CharMsg, strlen(Sensor2CharMsg));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, false); // Turn off a light after transmission
  delay(9000);
}
Code snippet #2Plain text
#include <SPI.h>#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <VirtualWire.h>
#include <Wire.h>int TEMP;int tempurature;
int humidity;char auth[] = "9bb52b5cfa6b4c4bbcde617a64886ed5";void setup()
{
  Serial.begin(9600);
  vw_set_rx_pin(2);
  vw_setup(2000);
  vw_rx_start();
  Blynk.begin(auth);
}void loop()
{
  Blynk.run();
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {    int i;
    char c;
    String input;
    for (i = 0; i < buflen; i++)
    {
      c = ((char)buf[i]);
      input += ((char)buf[i]);
      //Serial.print((char)buf[i]);
    }
    if (c == 'p') {
      Serial.print("TEMPURATURE CHECK");
      TEMP = true;
    }
    if (c == 'i') {
      Serial.print("HUMIDITY CHECK");
      TEMP = false;
    }
    if (c != 'p' && c != 'i') {
      if (TEMP == true) {
        tempurature = input.toInt();
        if (tempurature != humidity) {
          Blynk.virtualWrite(V12, tempurature);
        }
        Serial.print(tempurature);
      }
      else {
        humidity = input.toInt();
        if (tempurature != humidity) {
          Blynk.virtualWrite(V13, humidity);
        }
        Serial.print(humidity);
        /*double celsius = (tempurature - 32) * 5/9;
          double a = 17.271;
          double b = 237.7;
          double temp2 = (a * celsius) / (b + celsius) + log(humidity*0.01);
          double Td = (b * temp2) / (a - temp2);
          Td = ((Td*9) / 5) + 32;
          Blynk.virtualWrite(V14, Td);
        */
      }
    }    Serial.println();  }
}

Comments

Similar projects you might like

Personal Weather Station (Arduino+ ESP8266 + Thingspeak)

Project tutorial by Jayraj Desai

  • 71,450 views
  • 34 comments
  • 141 respects

Arduino MKR1000 Weather Station

Project tutorial by Tadeas Dvoracek

  • 11,082 views
  • 4 comments
  • 26 respects

$10 Portable Arduino Weather Station (AWS)

Project tutorial by Prajjwal Nag

  • 37,616 views
  • 6 comments
  • 74 respects

Mobile IoT Weather Station with UV Index

Project showcase by Carlos Orts

  • 10,515 views
  • 15 comments
  • 41 respects

Arduino Wireless Weather Station

Project tutorial by Nick Koumaris

  • 69,875 views
  • 16 comments
  • 144 respects

Mobile Weather Station Being Powered by Solar Energy

Project tutorial by Kutluhan Aktar

  • 4,650 views
  • 0 comments
  • 16 respects
Add projectSign up / Login