Stargate Logo  Secured by phpPhobos

  Login  - No Account?  Create One   
Thursday, 9 July 2020  -
News FeedRSS Feed
rss rdf  
    Site Documentation 
    About me 
  Legal Notice 
    Web Links 
    RC Models 
    RC Batteries 
    Build blogs 
    DNS Blacklist 
 Registered Bloggers 
  Blog de Maiwenn 
  Blog de Morgane 
  Joerg's Blog 
 Gallery [Listing]
  > Diving 
  > Martinique 
  > Steampunk 
  > RC Planes 
  > FPV Drones 
  > Indy travels 
  > Budapest 
 FAQ  [ Topics  ]
 Common Linux problem... 
 Routerboard RBxxxAH 
 Apple Mac-mini 
 PHP Phobos 
 Stargate's Backup sc... 
 eBook Reader / PRS-5... 
 RC Models 
 Server in SolLan 
 System Stats [ Index ]
  > Gateway 
  > Stargate 
  > Halley 
  > RemPi 
 Weather Station
  > WeatherPI 
Build blog - export: raw
Documentation TitleTitle of this documentation entry
  Weather Station  
Document AuthorPerson who wrote this entry
  Jörg Mertin  
StatusStatus for this entry
CategoryCategory/Type of this entry
Document languageLanguage this document has been written
Entered dateEntered date
  External links:    
  Parent:   3 - Cleanup the Raspberry PI OS: Raspbian
Main document

Raspberry PI Based Weather Station

Front view
Rear view

The Station is mounted on the roof-top, about 10m above ground.
I had to abandon using Solar power as the region barely provides enough solar energy in Winter to power the Raspberry PI inside for 2 hours. Even doubling the panel to 16W Total would not help. Reason I used the old Antenna installation and power the stations through the existing Coax TV Cable. Note that on roughly 20m length, the voltage drop is around 2V (which honestly is huge). I have to power the installation at my basement with 7.15V to have a stable non crashing Weather station.
So the below blog stays with the Solar array documentation etc. as it could help others for the sizing and more. However the current setup has had all solar-equipement stripped out.

Ordered Hardware

  • SkyWeather - Raspberry PIU based Weather Station Kit for the Cloud
  • Skyweather Lightning Pylon, Air quality Housing and Quarz Window Frames/Base sets
  • Raspberry PI Zero W (Amazon).
  • Amazon: PENG USB Femelle Prise Prise Adaptateur de Montage sur Panneau connecteur étanche
  • Amazon: Aexit Couvercle de joint de boîtier de jonction étanche 240mmx170mmx120mm avec cadre
  • Amazon: 2 BQLZR RJ45 Jack vers Jack Interface M20 Ethernet/LAN en Nylon AP Panel Mount connecteur étanche IP68
  • EBay - 3x Double Side Polished JGS1 Fused Silica Quartz Glass Sheets Plate 30x 30 x 1mm
  • Sourcingmap® 10 pcs 5.5 Mmx2.1 mm male Plug DC Power Jack
  • HSeaMall adaptater connector jack female
  • Transformer AC-DC (120-240V / 12V) 0.83W
  • Power Buck - DC-DC Convert 12V / 5V 3A

Differences to the official project

  • The OS running on the Raspberry PI will be based the Raspbian light. All deails to get all software running correctly are in the Software Installation chapter.
  • The Raspberry PI Zero W is used. It drains a little bit more power (average 210mA with very short peaks at around 600mA) than the no W version, however using a USB WIFi Stick would draw more power even than that. Also - the builtin WiFi is well supported.
  • The system being run in Europe, we will not be using the "English/Imperial system" but the Metric system for all units (Honestly, the English Imperial system is causing more trouble and is barely used by 7 countries on this planet).
  • As I have long experience with Raspberry PI's and the usual SD-Card wearing, I decided to use a different approach to store the collected data. The OS will take advantage of Ram-Filesystems whenever possible to reduce the number of write onto the card. All regular data will be stored off-site. in this case, as the Weather Station is running at Home (roof of my house), and the PI Board has built-in WiFi, I modified the scripts to actually store the data on my Server's mysql Database.
  • I'll write my own UI to display my weather data. Eventually, I'll also send it to Weather Underground if they want it.
  • Using a 12V power supply to power the Weather Station. A DC/DC converter inside the power station will make sure 5V really each the Weather station.
    The long cable causes a too high power loss (around 80m / 1.2V - probably an old cable, but that's what is there) which is not compensated by regular power supplies.

Abandonned due to Solar Array not providing enough power - even while doubling the panel surface

  • SkyWeather Solar Extender Kit
  • Using a 5.6v Zener Diode 10W to limit the power output from the Solar Array to the SunControl board. It has proven that without the Zener Diode, the Suncontrol board was cutting power as soon as the temperature/voltage was too high.
  • Battery Li-Ion NX 1S3P ICR18650-26J + PCM (28Wh) UN38.3 3.6V 7.8Ah Battery Specification
    The used Battery is a 7.8Ah model. So we'll have a batter margin for sun darkness.

Preparing the Raspberry PI Zero W / Software side

Performed a minimal Raspbian installation on the Raspberry PI Zero W by following instructions of the Cleanup the Raspberry PI OS: Raspbian guide.

Optional components.

Not yet known if this will be required, but for documentation purposes: SkyWeather Adding a fan Tutorial

Software installation

Pre-required packages as provided by raspbian.

~# sudo apt update && sudo apt dist-upgrade && sudo apt install git python-smbus python-setuptools python-pip libi2c-dev pigpio python-numpy python-matplotlib python-mpltoolkits.basemap build-essential python-mysqldb mariadb-server mariadb-client python-pigpio python-requests python-apscheduler python-futures python-funcsigs python-picamera fonts-freefont-ttf

Some other packages need to be downloaded from the required sources:

~# cd ~
~# git clone
~# git clone
~# cd Adafruit_Python_GPIO
~# sudo python install
~# SDL_Pi_SkyWeather/Adafruit_Python_SSD1306
~# sudo python install

Activate the required module

Note that the missing bits are that the i2c, GPIO and camera drivers are not activated by default. So start raspi-config, go to Interface options and activate all 3:

  • P1 Camera
  • P5 I2C
  • P8 Remote GPIO

reboot the PI and you're done.

Configure root access for MySQL

By default, mysql-user will not have a password set, not even for the root-user. Execute mysql_secure_installation to do the job for you, and follow the instructions.

~# sudo mysql_secure_installation

Once that is done, create the required Database for the SkyWeather system

~# mysql -u root -p
MariaDB [(none)]> create database SkyWeather;
Query OK, 1 row affected (0.003 sec)
MariaDB [(none)]> quit
~# mysql -u root -p SkyWeather < ./SkyWeatherSQL/WeatherPiStructure.sql
Enter password:

Now you'll be able to use the DB.

Some fine-tuning

When the PI reboots, it tends to loose time. If it is offline for a long time, even the external real-time clock won't be able to keep the time correctly. Hence - let's add ntpdate to the rc.local to load the time correctly.
Add the below lines of code to /etc/rc.local

# Setting system time (after a reboot)
systemctl stop ntp 
ntpdate [NTP Date server IP or Hostname (FQDN)]
systemctl start ntp

This will make sure the time is always set before starting the weather PI software.

To reduce the write operations of the PI, we have already reduce the write operations to Disk by shifting all writes to a ram-disk, and syncing once every 3 hours the data to the SD-Card in one write operation.

One other trick is to make sure the software runs smooth. Then redirect all regular output to /dev/null, and all error messages to a log-file. Do this with in replacing the startup entry in /etc/rc.local with:

#1 Weatherpi running here
cd /home/pi/SDL_Pi_SkyWeather

# We send regular output to /dev/null, and errors to the actual Log-file.
nohup python >/dev/null 2> /var/tmp/log/nohup_errors.log &

The /var/tmp/log/nohup_errors.log will be moved to /var/log every 3 hours, or upon regular reboot.

Power usage adaptations

The raspbian OS performs various tasks controlled through the crontab. Of course, we want to execute these tasks when the SUN helps us at its max, so we'll move the cronjobs from early-morning/midnight to happen at plain mid-day.
Change the /etc/crontab to:

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 12   * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 12   * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 12   1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

Hardware - test the setup

This is to test the electronics, all sensors are working etc. Once completed, go over to the Software testing chapter of the official documentation Skyweather initial testing. This will confirm that all components work as expected, and the PI is able to recognize all connected sensors.

I2C Connections

Connect This part Cable ==> To this part
1. PI Weather Board / Computer I2C Grove] 20cm ==> I2C Connector / PI 2 Grover Board
2. PI Weather Board / Bus 3 20cm ==> I2C Grobe Plug / TSL2591 Sunlight Sensor
3. PI Weather Board / Bus 0 20cm ==> Any I2C Port / 6 Port Hub
4. 6 Port Hub / Any Port 20cm ==> In Grove Connector / Grove PowerSave #1
5. AM2315 Temperature/Humidity Sensor ==> Out Grove Connector / Grove PowerSave #1
6. AS3935 ThunderBoard / Grove I2C Port 50cm ==> Any I2C Port / PI 2 Grover Board

GPIO Connections

Connect This part Cable ==> To this part
7. PI 2 Grover Board / D6/D12 20cm ==> Control Grove Connector / Grove PowerSave #1
8. Grove PowerSave #2 / Out Grove Connector ==> Air Quality Dust Sensor
9. Grove PowerSave #2 / Control Grove Connector 20cm ==> D26 / PI 2 Grover Board
10. Grove PowerSave #2 / In Grove Connector 20cm ==> D16/D19 / PI 2 Grover Board
11. AS3935 ThunderBoard / Grove Digital 50cm ==> D19/D20 / PI 2 Grover Board
12. PI Weather Board / Anemometer/J5 Input 20cm ==> D20/D21 / PI 2 Grover Board
13. PI Weather Board / J6 Rain Bucket Plug 20cm ==> D13/D16 / PI 2 Grover Board

RJ45 Connectors

Connect the RJ45 cables from the Anemometer and from the Rain Bucket into their respective sockets on the PI Weather Board.

Connecting the Solar panels

Connect This part Cable ==> To this part
14. PI Weather Board / IC2 Bus 2 20cm ==> IC2 Connector / SunControl Board

For the inclination of the Solar panels, The latitude will play a role, and depending on the Season, Optimal inclination will be different.
A good source for calculating the inclination can be found here: Solar Angle Calculator
For my latitude, it would be in Winter: 18° angle, Spring/Autumn 41° angle and Summer 64° angle.

Note: The pictures linked to the connection-tables below are with courtesy of

The way it is built and implanted into the box after the successful connection testing.


Preliminary sensor report:

The following shows when running the weather collector prograem

SkyWeather Weather Station Version 055 - SwitchDoc Labs

Program Started at:2020-01-20 10:31:51

I2C Mux - TCA9545:              Present
BME680:                 Present
BMP280:                 Not Present
SkyCam:                 Present
DS3231:                 Not Present
HDC1080:                Not Present
SHT30:                  Not Present
AM2315:                 Present
ADS1015:                Present
ADS1115:                Not Present
AS3935:                 Present
OLED:                   Not Present
SunAirPlus/SunControl:                  Present
SolarMAX:               Not Present
SI1145 Sun Sensor:              Not Present
TSL2591 Sun Sensor:             Present
DustSensor:             Present
WXLink:                 Not Present
Dual SolarMAX/WXLink:                   Not Present

UseBlynk:               Not Present
UseMySQL:               Present
Check WLAN:             Present
WeatherUnderground:             Not Present
UseWeatherStem:                 Not Present

The Raw data values written into the DB will show like this.
For the PowerSystem table:

batteryVoltage: V
batteryCurrent: mA
solarVoltage: V
solarCurrent: mA
loadVoltage: V
loadCurrent: mA
batteryPower: W
solarPower: W
loadPower: W
batteryCharge: %

For the Sunlight Table:

Visible: Lux
IR: Lux
UVIndex: N/A

For the WeatherData Table:

as3935LightningCount: Counter
currentWindSpeed: Kph
currentWindGust: Kph
currentWindDirection: °
currentWindDirectionVoltage: ?
totalRain: mm
bmp180Temperature: °C
bmp180Pressure: hPa / milli bars
bmp180Altitude: m
bmp180SeaLevel: hPa / milli bars
outsideTemperature: °C
outsideHumidity: %
insideTemperature: °C
insideHumidity: %
AQI: µg/m³

Putting it all in the box

as the box I got is way smaller than the one anticipated by SwitchDoc Labs, I had to trick a little with space.
In fact, it can hold everything even though I got some cable length wrong. Should not have followed the instructions to the letter while cabling it the first time. So - for the openings:

Camera and Light Sensor mounts
Camera and Light Sensor mounts

Holes for temp and humidity Sensor
Holes for temp and humidity Sensor

Holes for RJ11 plugs
Note that I did add a 3rd hole for the Solar-Panel power cable.
Holes for RJ11 plugs

Holes for AQI sensor
This one will be mounted inside of the box. As it needs a certain position so the internal resistor can heat up the air and cause a air-flow for the measurement period.
Holes for AQI sensor

Burn-In (Software)

For the Burn-in and Fine-Tuning Period, the system is in my basement. Also, as in Winter it can get quite cold and dark, I am unsure if the Solar-Array and Battery will be able to cope with the energy demand required by the entire weather station. For this, I decided to add a external jack/connector to connect an external 5V power supply. From my RC_Planes, I have plenty of step-up/down converters available, so I can hook up a LiPo battery and plug it in for enough time to power-charge the built-in battery of the Weather station.

This is how it looks like, and how I connected it to the PowerBoard mini-USB port.
Holes for AQI sensor Holes for AQI sensor
The connection layout given to me by a member of the switchdoc-labs forum: mini-USB connector pinout

The charge-cable is currently just a long USB Cable where I soldered the red and black wires to the jack plug, so it charges the Weatherstation battery pack.

Solar Panels

it took me a while to actually think about how to fix the actual solar panels on a back-plate, and how to weather proof these. In the end, it was quite simple. What I needed was 2 things:

  1. A glue that does allow the thermal dilation of different materials and remains flexible over time
  2. A glue that is UV resistent

Having had some experience over time with normal Silicon glue, I opted for the Sikaflex 521 UV (You can find some on Amazon). It is used by most RV drivers in europe to glue their solar-panels on the roofs of their trucks. If that holds, it definitely is good enough for my usage!

So - after preparing the aluminium plate to be held by the fixations, I glued it all together:
Solar Panel
and made sure I had a waterproof box to receive all cables. Of course, all water-profing was done with the Sikaflex 521 UV glue.
The back-Side looking like this:
Solar Panel electric wiring

Air Quality Sensor

The air Quality Sensor intake posed a different challenge. In fact, it sucks in Air, and measures it through laser interference to look for particles in the air that go through. As the holes are placed on the side and not under the entire box, I used two plastic bottle caps glued on with Epoxy to prevent rain from getting in.
Air Quality Sensor Water profing
That should be sufficient to prevent any water from coming in. I don't think rain will fall in from below ;)

Will need to check the details and adapt the graphs according to:

  • Write UI to present the data/results (Partly done).

  • Validate the Solar array provides enough power.

  • Battery can't be shipped to Europe -> Lithium Ion Battery Pack - 3.7V 6600mAh. Had to find local alternative.
  • Using the Grove Connectors everywhere has its advantage to make tests etc. In the end however, this requires a decent cable-management that would have been avoided when soldering the cables straight. But then again, not everyone has a decent soldering equipment at hand :}
  • Looks like the Solar Array does not provide enough power on rainy days. Will have to add a second one. Even with 2 panels, it will probably not be enough to handle the required power supply. Changing approach.
  • Solar panel won't work. Calculation has shown that a 100W Panel would be require to power the Raspberry PI in Winter. Wouldn't know what to do with the excess power in Summer however.
  • Fri June 26 2020: Validated the correct power for Weather station to 7.1V (Power drop due to Coax TV Cable length).
  • Sat Jun 20 2020: Mounted the Weather Station onto the roof.
  • Sat Mar 7 2020: Validate Weather proofing is good (Mount it outside)
  • Sun Mar 1 2020: Weather tighten the Box
  • Sun Mar 1 2020: Glue Solar panels on big plate and weather tighten these
  • Sat Feb 29 2020: Glue all parts together (ePoxy)
  • Web Feb 12 2020 @ 21h: Added charging jack for backup power
  • Sat Feb 1 2020: Put all into the Box
  • Sat Jan 18 2020: Integrate Solar panels/Battery and make sure it works as expected
  • Sat Jan 18 2020: Test Suncontrol board
  • Sat Jan 18 2020: Perform Software/Connectivity
  • Sat Jan 11 2020: Connected all components together
  • Sat Jan 11 2020: Solder the Hat connector onto the Raspberry PI Zero W
  • Sat Jan 11 2020: Solder the JST-PH connector onto the Battery Pack.
  • Sat Jan 11 2020: Raspberry PI Zero W Raspbian installation and OS cleanup
  Last change:     2020-06-27 14:30:42  
    Back Back    

Problems to  root(-AT-)solsys(-DOT-)org  - best viewed @ 1920bpp
This site is powered by phpPhobos v2.0b446
© J. Mertin smurphy(-AT-)solsys(-DOT-)org 
Icons - Copyright Breeze artists GPL 2+