Tuesday, August 30, 2016

How to make digital weather station with wireless outdoor sensors


Fig. Block diagram of a weather station


1. Sensors


I used 3 sensor modules which can be acquired via ebay or aliexpress. It seems they are cheap Chinese clones of well known sparkfun/adafruit modules. Also I made a simple sensor to monitor battery voltage. (Someone should keep a Li-ion battery above 3V level.) You can easily find arduino libraries for these modules. So modules can be used at once. But keep in mind a "chinese clone" sensor can use a different I2C address. So you may need to run an arduino script that called I2C scanner to identify these addresses and then change a device I2C address constant in a library header file to guarantee correct work the library with the module. 

I used the following devices




1) SHT21 Digital Temperature And Humidity Sensor Module (GY-21)


Fig.1.1  side A and side B of SHT21 module

Fig.1.2 Schematic of SHT21 module


2) BMP280 Pressure Sensor Module (GY-BM)

 Fig.1.3 side A and side B of BMP280 module

Fig.1.4 schematic of BMP280 module





3)  MAX44009 Ambient Light Sensor Module (GY-49)


Fig.1.5 schematic of MAX44009 module



 Fig.1.6 Pinout of MAX44009 chip


Found schematics for the modules tell us that sht21 sensor module and max44009 GY-49 module have 3V3 LDO regulators. So they tolerate 5V. But BMP280 module has neither LDO regulator nor level converters.

So I connected the LDO 3.3V output from my max44009 module to the power pin of my BMP280 module.


4)To make a battery sensor you should follow the instructions here. (It's just a simple voltage divider connected to ADC port of an arduino.)

"Measuring and Reporting Battery Level"
https://www.mysensors.org/build/battery

Here you can download an arduino sketch to test your sensors ("SensorsTest").

SHT21, max4009, BMP280 are connected via I2C bus to A4,A5 pins of the arduino (SDA,SCL for arduino nano/mini).




1.1 nrf24l01+ mod


Solder 1uF or 10uF capacitor between GND and PWR pins of nrf24l01+  Then probably you should run simple two pair example from RF24 library (I used RF24 library by TMRh20) to check if your nrf24l01+ modules have the stable connection.

Fig.1.1.1 nrf24l01+ module with a soldered 1uF smd capacitor.


I think someone should buy nrf24l01+ in pairs and from one seller - to maximize probability that you will get devices from one party with comparable parameters. Keep in mind these could be not original Nordic transceivers but rather a Chinese copy of the chip ...

2. nrf24l01+ arduino pro mini + sensors + battery (outdoor sensors module)


This "outdoor" part of the weather station acquires information from the sensors and sends this information to an "indoor" part of the weather station.



The part consists of the sensors which share a common I2C bus and sit on one board with battery sensor. As mentioned above the max44009 module shares the power pin with the BMP280 module (You can see a white wire in photo).


An arduino pro mini gets data from sensors and sends it via nrf24l01+.
To minimize consumed power the arduino goes to power down mode between data sending. The watchdog wakeups the arduino pro mini after 8 seconds and the loop continues.


To minimize power loses I unsoldered leds and cut off LDO on the arduino board. Here you can find guide how to do so. "Power safe mode"
https://www.mysensors.org/build/battery

How long does a battery last? I have a 400mAh battery which lasts about 2 weeks. Of course there can be done some further power safe improvements.

 2.1 how to connect




NRF24 pins Arduino Nano/mini pins
1 GND
2 3.3V
3 7
4 8
5 13
6 11
7 12


SHT21, max4009, BMP280 are connected via I2C bus to A4,A5 pins of the arduino (SDA,SCL for arduino nano/mini). The battery sensor is connected to A0 pin of the arduino.

Arduino mini pro was programmed through an external serial-to-USB module (I used a CP2102 based chip) In this case, for uploading sketch to Arduino the connections should be as usual (TX,RX,GND) but keep in mind you need manually reset arduino when you see the progress bar in Arduino IDE at the end. If you don't want manually reset arduino every time as you reflash(reprogram) it then you need an additional wire to connect the serial-to-USB module DTR pin to the arduino DTR pin. 


Here is a program for this module. ("OutdoorSensors")


3. Indoor parts 

An indoor part receives information from the outdoor part then displays, stores  or transforms the received data in some way. The indoor part can be constructed in different ways. In this article I consider 1) arduino & nrf24l01+ module; 2)Raspberry pi & nrf24l01+ ; 3) esp8266 & nrf24l01+. Your choice depends on your goals.


3.1. nrf24l01+ arduino nano (arduino "receiver")
It's a cheapest way to get data on PC. For example you can write a python script on your PC to open a comport then grab, parse and process data from an arduino.

Here is a program for this module. ("Arduino_nano_receiver")


How to connect (table)
NRF24 Arduino Nano
1 GND
2 3.3V
3 7
4 8
5 13
6 11
7 12


3.2 Thingspeak "cloud" service
Thingspeak gives you an opportunity to view (and share) data from your sensors as a bunch of nice plots in a browser window. Thingspeak is cloud based which means you can access it from anywhere as long as you have access to the Internet. After you sign up, you will get an unique identifier (API key) for updating sensors status via the http protocol. This key should be copied and inserted in a special formed string of http-request. The request is issued every time when you want to update information at Thingspeak.



3.3 nrf24l01+ Raspberry pi (RPi"receiver")


If you want to make a standalone weather server, you probably should use a RPi.
However in my project I have an example that also prints and sends data to Thingspeak. But keep in mind that a Rpi can easily handle displaying data through its own web server.




Install nrf24 RPi library. Follow instructions here (Don't forget to enable SPI interface on RPi)
http://tmrh20.github.io/RF24/RPi.html



I used libcurl to make HTTP POST request to thingspeak. To install libcurl you can type "sudo aptitude install libcurl4-openssl-dev" into Raspbian command line.

A program for RPi you can find here.("RPi")
Make subdirectory in the nrf24 library installation folder and move the program there. So, the full path will be something like "~/rf24libs/RF24/myRF24". Type make to compile the program. And then you can run the program (just type "sudo ./gettingstarted" ).

How to connect


PIN NRF24L01 RPI RPi -P1 Connector
1 GND rpi-gnd (25)
2 VCC rpi-3v3 (17)
3 CE rpi-gpio22 (15)
4 CSN rpi-gpio8 (24)
5 SCK rpi-sckl (23)
6 MOSI rpi-mosi (19)
7 MISO rpi-miso (21)
8 IRQ --




3.4. nrf24l01+ esp8266 ( esp8266 indoor "receiver")
Probably It's the best cloud solution if you have a Wi-Fi router.




You can buy a devboard for esp8266 (NodeMCU consists of all needed components) or you can make your own esp8266 devboard.

Follow the instructions here to setup Arduino IDE for esp8266.
https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide

A program for ESP8266 can be found here. ("esp8266")

How to connect:
Connect pins of esp8266 and nrf8266 according to the table below

ESP8266 GPIO Pin Namenrf24l01 PIN
GPIO12 MISO 7
GPIO13 MOSI 6
GPIO14 CLOCK5
GPIO15 CSN4
GPIO2 CE 3
VCC 3V3 2
GND GND 1







 


Links

The weather station on Thingspeak https://thingspeak.com/channels/117167



2 comments:

  1. شركة متخصصة فى الخدمات المنزلية بالمملكة العربية السعودية
    شركة سما المثالية 0535609607
    تقدم لكم شركة سما المثالية خدمات داخل المملكة العربية السعودية بالرياض والدمام والاحساء والقصيم
    الخبر القطيف الجبيل راس تنورة سيهات صفوى

    شركة تنظيف منازل بسيهات

    شركة تنظيف منازل بصفوى

    شركة تنظيف منازل براس تنورة

    ReplyDelete
  2. I learn some new stuff from it too, thanks for sharing your information. l shaped gaming desk

    ReplyDelete