Introduction: Handheld Weather Station
Proper handheld weather stations is expensive and normally have moving parts (a fan) to measure wind speed. Devices that can measure wind speed, temperature, humidity, barometric (atmospheric) pressure, altitude and the dew point is hard to find and expensive. This raspberry pi based device will be able to measure all the above at a fraction of the cost.
The device will be useful for:
· Heating, Ventilation and Air-conditioning (HVAC) specialists
· Outdoor enthusiasts
· Education (Electronics and Science, illustration of Bernoulli’s equation, Venturi tubes)
· Farming
· Boats
· Electronic hobbyists
· Boy and Girl Scouts camps
· Hunting
· Anybody with an interest in their surroundings.
This Project futured in the RaspbarryPI Foundation's weekly newsletter www.raspberrypi.org/weekly/weatherproof
Step 1: HARDWARE REQUIREMENTS
1)Any Raspberry pi (I used a model 3b)
2) LCM1602C LCD screen (Optional, to make the device portable. Other LCD screens or touch screens may work, prefarable from Adafruit.). You can also use a 10 k ohms pot to set screen contrast.
3) Sensirion SDP810-125 PA (Differential Pressure/Micro Thermal Flow Sensor). The SDP810-500 PA will also work, but the python code provided will require modification.
4) Bosch BME 280 Temperature, Humidity and Barometric Pressure sensor (Preferable on the Adafruit breakout board, others will probably work but may have different i2c addresses.)
5) iOs or android phone or tablet with VNC or SSH(Optional, if you do not use the LCM1602C LCD or other screen)
6) Battery for Raspberry pi or a power bank (Optional, to make the device portable)
7) 2 x 10 K ohms resistors
8) Large bread Board, one small breadboard and PI cobbler
9) Some jumper (35 male to male and 10 male to female) cables.
10) Some Python skills will help, although all code is provided.
11) 2 Aquarium (Fish tank tubes) with inside diameter of 4mm. You will also need 2 nozzles, but can 3d print them. The hole in the nozzle must preferable be the same size as the holes in the pipes of the SDP810. I used two suction pipes from a cheap vacuum pick and place pump. A pitot tube may also fit on the fish tank tubes, but will only allow one direction wind measurement and re calibration.
12) 3D Printer (Optional, to print a cover and the nozzles)
13) A handheld anemometer may be required for calibration,
Before continuing, I must say something about the hardware and its extreme high quality. I belief the Raspberry pi is well known and does not require any introduction. The two sensors (Bosch BME280 and Sensirion SDP810-125 PA) used in this project is probably the best in its class for affordable hobby use. It is however extremely precise and produced for precision like in the medical environment. Read the respective datasheets at https://www.bosch-sensortec.com/bst/products/all_products/bme280 and https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/0_Datasheets/Differential_Pressure/Sensirion_Differential_Pressure_Sensors_SDP8xx_Digital_Datasheet.pdf
Step 2: CONNECTING THE HARDWARE
Remember to switch off your raspberry pi when working on the GPIO pins or connecting / disconnecting the cobbler.
Connect the Sensirion SDP 810 like in the diagram and images above on breadboards. Remember to use the two 10 k ohms pull up resistors between Vdd and SDA and Vdd and SCL. Also connect the BME280 (Does not require pull up resistors). Since the two sensors have different i2c addresses, you can connect them parallel to the same i2c bus. I used colour coding Red=V, Green=SDA/SDI and Red=SCK/SCL
Make sure i2c is enabled on your system (Go to Application Menue, Preferences, Raspberry PI configuration, Interfaces)
Connect your circuit, switch on the raspberry pi. Open a terminal window and run sudo i2cdetect –y 1. The result should indicate the 2 devices on address 0x25 (SDP810) and x76 or x77 (BME280).
Connect the LCM1602C. I followed the adafruit instructions (https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/overview), however, adafruit modified the pinouts in the code, so rather follow the following instructions:
Wire up the LCD to your breadboard as
follow:
Pin #1 of the LCD goes to ground (black wire)
Pin #2 of the LCD goes to +5V (red wire)
Pin #3 (Vo) connects to the Signal of the potentiometer (orange wire). Connect the remaining pot pins to +5v and GND like in the image. If you do not want to have a variable screen contrast, connect Pin 3 of the LCD to +5V
Pin #4 (RS) connects to the Cobbler #25 (GPIO 25) (yellow wire)
Pin #5 (RW) goes to ground (black wire)
Pin #6 (EN) connects to Cobbler #24 (GPIO 24) (green wire)
Skip LCD Pins #7, #8, #9 and #10
Pin #11 (D4) connects to cobbler #23 (GPIO 23) (blue wire)
Pin #12 (D5) connects to Cobbler #17 (GPIO 17) (violet wire)
Pin #13 (D6) connects to Cobber #21 (GPIO 21) (gray wire)
Pin #14 (D7) connects to Cobber #22 (GPIO 22) (white wire)
Pin #15 (LED +) goes to +5V (red wire)
Pin #16 (LED -) goes to ground (black wire).
Adafruit ialso provides the following warning:
Before wiring, check that your LCD has an LED backlight, not an EL backlight. LED backlights use 10-40mA of power, EL backlights use 200+ma! EL backlights are often cheap to get but are not usable, make sure you don't use one or you will overload the Pi. Some cheap LCDs that have LED backlights do not include a resistor on the LCD module for the backlight, if you're not sure, connect a 1Kohm resistor between pin 15 and 5V instead of connecting directly. All Adafruit LCDs have LED backlights with built in resistors so you do not need an extra resistor!
You can now switch on your raspberry pi. The screen will light up. If it does not look like the screen on the provided photo, check your connections. If the screen lights up, but you can not see the blocks, turn the pot. If added the 1 k ohms resister, you may have to remove it to make the blocks visible.
Step 3: PREPARING THE RASPBERRY PI SOFTWARE
My code is tested on the latest Raspbian Stretch.
Make sure your system is up to date
Open a terminal and run:
$ sudo apt-get update
$ sudo apt-get upgrade
Also make sure that the following packages are installed. They probably are already installed.
$ sudo apt-get install python-dev
$ sudo apt-get install python-setuptools
$ sudo easy_install -U distribute
$ sudo apt-get install python-pip
$ sudo pip install rpi.gpio
$ sudo pip install rpi.gpio
Now you need to install the adafruit modules for the BME280 and the LCM1602C. They are available on Github
First install git to enable the cloning of directories on github. Run
$ sudo apt-get install git
Move to the directory where you want to install the modules. I suggest you use your puthon directory. Run:
$ cd mkdir /home/pi/python
$ cd /home/pi/python
Clone the Adafruit_Python_CharLCD directory with:
$ git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git
Move to the Adafruit_Python_CharLCD directory
$ cd Adafruit_Python_CharLCD
Run the following to register the module:
$ sudo python setup.py install
The LCM1602 python module is now available to all python apps by using:
Import Adafruit_CharLCD as LCD in your python editor
You can test the LCD by running the attach LCD_Hello_world.py. The examples on github (Available in the examples directory) will not work if you do not modify your pinouts in the python according to the physical pinouts (Corrected in the attach LCD_Hello_world.py and all my scripts provided). If the screen does not show hello world, check your pinouts, connection, turn the potentiometer. If this doesc not work and you added the 1 k ohs resister, remove it.
You also need to install the BME280 modules. Move to your python directory with the following shell command.
$ cd /home/pi/python
Run the following commands:
$ git clone https://github.com/adafruit/Adafruit_Python_BME280.git
$ cd Adafruit_Python_BME280
$ sudo python setup.py install
The adafruit BME280 module will now be available to all python scripts by importing the Adafruit_BME280 module.
Before running your first script, make sure the BME280 is on i2c address 77 (Other BME280 Boards may be on 76) by running
$ sudo i2cdetect –y 1
If your BME280 is using i2c address 76, modify the file Adafruit_BME280.py line 30 to BME280_I2CADDR = 0x76
The BME280 can be tested with the attach Reading_BME280.py example.
The Sensirion SDP810 micro thermal flow sensor does not require any special modules and can communicate via the smbus protocal (a subset of the i2c bus protocal). I struggled to find python examples for the SDP810 on the net and had to figure out its workings the hard way and using its datasheet. The results is available on Github at https://github.com/JJSlabbert/Sensirion_SDP810_125PA.
Step 4: RUN THE WEATHER STATION SOFTWARE
Currently I have two python scripts available:
weather_log_and_display.py will read all sensors, print the readings to your raspberry pi screen (If attached), log the data in data.txt and print the readings to the LCD screen.
anemometer.py reads wind speed data very fast.You can increase/decrease the reading interval in the Python script. According to the datasheet of the SDP810, a new reading is available every 0.5 ms. This is way to fast for the python and the LCD screen. This script also shows the minimum and maximum readings and is ideal to detect wind gust
You may also use your smartphone /tablet to monitor the weather station via VNC. More info at https://www.raspberrypi.org/magpi/vnc-raspberry-pi/. Check the app stores for vnc viewers.
If you need to run a script automatically at startup, add the line
@python /home/pi/python/Portable_Weather_Station/weather_log_and_display.py
To /home/pi/.config/lxsession/LXDE-pi
Note on altitude calculation:
Altitude is calculated as a function of local atmospheric pressure, temperature and pressure at see level. The real pressure at see level is fluctuating frequently around 1013,25 hPa. I used 1013,25 hPa in my Python script. The altitude calculated by the Python script is therefore just an estimate.
Note on wind speed calculation
The information at https://projects.knmi.nl/hydra/faq/press.html is very handy in transforming the wind pressure (measured by the SDP810) to wind velocity. The diameter of the tubes and pipes used also have an influence on the shape factor in the Bernoulli equation. I used a homemade wind tunnel to calibrate my anemometer against an of the shelf anemometer (MAJ MT947) and a sparkfun cup anemometer. The results was amassing. If you do not use the exact tubes and pipes I used, you will have to determine your own Bernoulli equation (Shape factor) to calculate wind velocity. My Shape factor was 0.72. Also remember that many anemometers will only pick up wind speeds above a certain level. The MAJ MT947 started to read om 0.8m/s. You may need to correct the readings. 1 m/s therefore is actually 1.8ms. My calibration results is in anemometer.xls
Enjoy your outdoor experience. Feel free to contribute.