Difference between revisions of "Open Source WiFi Weather Station"

From Microduino Wiki
Jump to: navigation, search
(Programming the Weather Station)
(Get and Configure Blynk)
Line 94: Line 94:
 
Next, we'll learn how Microduino interacts with Blynk through the configuration process of the Weather Station.   
 
Next, we'll learn how Microduino interacts with Blynk through the configuration process of the Weather Station.   
  
===Get Blynk Phone Client===
+
===Download the Blynk App===
*Please refer to [[https://www.microduino.cn/wiki/index.php/Microduino-Blynk_Getting_start/zh#.E5.88.9B.E5.BB.BA.E9.A1.B9.E7.9B.AE Get and Configure Blynk]]
+
 
 +
Visit the Google Play Store or the Apple App Store and download the '''Blynk''' app.
 +
 
 +
You'll need to setup an account with Blynk before proceeding. Please use a valid e-mail as your authentication tokens will be sent to that e-mail.
 +
 
 +
===Using the Blynk App==
 +
 
 +
On the main screen of the Blynk app. Click on the '''QR code scanner''' to scan the Weather Station app. Scan the QR code below.
 +
 
 +
[[image]]
 +
 
 +
Once the project has loaded, click on '''Project Settings''' (nut icon).  
 +
 
 +
Under Auth Tokens, click on '''Email all'''. This will send the authentication token to your registered e-mail. Make note of this, as you will need this token later.
 +
 
 +
Click back to return to the Weather Station app.
  
 
===Add Configuration Items ===
 
===Add Configuration Items ===

Revision as of 01:21, 19 December 2018

Outline

  • Project: Open Source WIFI Weather Station System.(ESP8266 connected to Blynk)
  • Objective: To get temperature, humidity, light intensity and PM2.5 at the weather station.
    • Note: PM2.5 refers to atmospheric particulate matter (PM) that have a diameter of less than 2.5 micrometers
  • Difficulty: Medium
  • Time-consuming: 2-Hour
  • Maker: Ray

Introduction:

  • Read temperature, humidity, light intensity and PM2.5 data and display those data on the screen.
  • Upload the data to Blynk.
  • View data on phone anywhere using the Blynk app.
  • Created by Microduino with Microduino components.

Bill of Material

Microduino Equipment

Note: Different revisions may contain different components.
Module Number Function
Microduino-Core+ 1 Core board (Arduino)
Microduino-USBTTL -OR- Microduino-USBTLL-C 1 Programmer for Core board
Microduino-WIFI(ESP) 1 WiFi communication module
Microduino-Sensorhub 1 Connector Hub to connect sensors
Microduino-Duo-h -OR- Microduino-Cube-S1 1 Extension board
Microduino-OLED 1 Display
Sensor Number Function
Microduino-Temp&Hum -OR- Sensor-Tem&Hum-S2 1 Digital temperature and humidity sensor
Microduino-Air Quality 1 Air quality detector
Microduino-Light 1 Light-sensitive sensor
GP2Y1010AU0F 1 PM2.5 sensor

Other Equipment

Equipment Number Function
Micro-USB cable 1 For program download and power supply
GP2Y1010AU0F 1 PM2.5 sensor
Screw 7 Fixate modules
Screwdriver 1 Fixate screws
Shell 1
WeatherStationMatiralAll.png
Note: Different revisions will contain different components.

Most noteable are:

  • Duo-V will be replaced with a Microduino-Cube-S1.
  • Humidity/TempSensor will be replaced with a Tem&Hum-S2.

Principle of the Experiment

This Weather Station can detect data including:


Other functions:

Get and Configure Blynk

Next, we'll learn how Microduino interacts with Blynk through the configuration process of the Weather Station.

Download the Blynk App

Visit the Google Play Store or the Apple App Store and download the Blynk app.

You'll need to setup an account with Blynk before proceeding. Please use a valid e-mail as your authentication tokens will be sent to that e-mail.

=Using the Blynk App

On the main screen of the Blynk app. Click on the QR code scanner to scan the Weather Station app. Scan the QR code below.

image

Once the project has loaded, click on Project Settings (nut icon).

Under Auth Tokens, click on Email all. This will send the authentication token to your registered e-mail. Make note of this, as you will need this token later.

Click back to return to the Weather Station app.

Add Configuration Items

    • You can scan the two-dimension code below to get Weather Station APP.
BlynkWeatherStationLink.png


  • Also, you can make your own one.
  • In this case, you can click the panel and call out WIDGET BOX, on which you can see many choices.
BlynkSetting3.png


  • Add Value Display item and name "temperature" to display Temperature value acquired.
  • Select V2 on INPUT; Choose PUSH on READING FREQUENCY, which indicates the temperature is sent from the Weather Station and the frequency is controlled by Microduino Client.
BlynkSetting4.png


The corresponding code at the Microduino Client is:

void senTempHumi() {
  am2321.read();
  float sensor_tem = am2321.temperature / 10.0;
  float sensor_hum = am2321.humidity / 10.0;
  Blynk.virtualWrite(V2, sensor_tem);
  Blynk.virtualWrite(V3, sensor_hum);

  oled(sensor_tem, sensor_hum, sensor_light, sensorPM25, Sensor_etoh); 
}


  • The setting of the humidity is similar with that of temperature; Set INPUT as V3 and send it through a timer function " senTempHumi()".
BlynkSetting5.png


  • The frequency of the timer can be achieved by codes below:
void senTempHumi() {
  SimpleTimer temHumtimer;
  temHumtimer.setInterval(2000L, senTempHumi);
}


  • Set PM2.5's INPUT as V6, READING FREQUENCY as 5s, which represents frequency of the acquired PM2.5 data.
BlynkSetting6.png



  • The corresponding code at the Microduino Client is:
BLYNK_READ(V6) {
  Blynk.virtualWrite(V6, sensorPM25);
}


  • Similarly, set the INPUT of the Light Sensor as V4 and the frequency is to get value every 3s.
BlynkSetting7.png



  • The corresponding code at the Microduino Client is:
BLYNK_READ(V4) {
  sensor_light = map(analogRead(A0), 0, 1023, 0, 255);
  Blynk.virtualWrite(V4, sensor_light);
}



  • The INPUT of the methane gas is V5 and the frequency is to get value every 5s.
BlynkSetting8.png



  • The corresponding code at the Microduino Client is:
BLYNK_READ(V5) {
  Sensor_etoh= map(analogRead(A2), 0, 1023, 0, 30);
  Blynk.virtualWrite(V5, Sensor_etoh);
}



  • Finally, your phone panel turns into this:
BlynkSetting12.png

Programming

Software Setup

Please follow the guide to ensure your software is correctly setup. The software is required to program the WiFi Weather Station.

Download the latest software for your operating system and follow the getting started guides:

Programming the Weather Station

  • Stack Microduino-Core+ and Microduino-USBTTL together.
  • Connect Microduino-USBTTL with a USB cable. Connect the other end to the PC being used.
  • Open the Arduino IDE for Microduino development environment. (Please refer to the #Software Setup section).
  • Configure the software to upload to the Core+ module as follows:
    • Tools > Board > Microduino/mCookie-device
    • Tools > Processor > Microduino/mCookie-Core+ (644pa)@16M,5V
    • Tools > Port > select the port (On MacOS, NOT the Bluetooth one).


  • Download the code for Weather Station here: File:ESP8266BlynkWeatherStationV2.zip
  • Unzip the file. Under the software (Arduino IDE), go to File > Open... and navigate to the unzipped folder and open the ESP8266BlynkWeatherStationV2.ino file.
  • The sketch with multiple files will open. Click on the userDef.h tab. You'll need to configure the WiFi connection (2.4GHz networks, non 5GHz) with SSID, PASS (WiFi password), and auth key as noted earlier in the Blynk app.
  • Click on the upload button (right arrow icon on the top left) to upload the program.
  • The program will compile and upload. Once completed a upload successful message will appear on the bottom left.

Hardware Buildup

Waetherstep1.jpg
  • Step2
    • Assemble Structure-B1~B5 with Structure-B6.
Waetherstep2.jpg
Waetherstep3.jpg
Waetherstep4.jpg
Waetherstep5.jpg
  • Step6
    • Complete the steps above, then fixate with Structure-B0 and plug in a USB cable. Congratulations! You just finished the buildup of the Weather Station.
  • Step7
    • You can see sensor data on Microduino-OLED after setting.
    • At the same time, you can also see uploaded data of the Weather Station on your phone Blynk.
BlynkSetting13.png

Notes

  • Please make sure the verification code is configured right.
  • Make sure your router runs normally, the SSID and password are correct.