Building a Solar Powered Raspberry Pi Weather Station - GroveWeatherPi (Updated March 12, 2017) - See Update In Next Section

Software and Hardware Update March 12, 2017

The Raspberry Pi is a fabulous device to on which to build your projects. The GroveWeatherPi project is designed to show the capabilities of this computer while remaining accessible to a diverse Maker community.

The key to keeping this project accessible to many people is to minimizing the need for complex wiring and soldering. In this tutorial, we are showing how to build Raspberry Pi based Weather Station in two parts (actually 13 steps). The first major part is building the GroveWeatherPi station itself. This can be done with no soldering. The second part of the tutorial is outfitting your GroveWeatherPi with Solar panels. This can be done with a very minimal amount of soldering to produce a fully solar powered Raspberry Pi based weather station.

(Update: Grove Sunlight Sensor - SI1145 now supported - measures visible light, IR and UV)


What is GroveWeatherPi?

GroveWeatherPi is a Solar Powered Raspberry Pi WiFi connected weather station designed for Makers by SwitchDoc Labs ( www.switchdoc.com). This is a great system to build and tinker with. All of it is modifiable and all source code is included.

This tutorial for building your own Solar Powered Weather Station based on the Raspberry Pi consists of 13 steps.


The most important functions are:

  • Detects Lightning!
  • Senses 20 different environmental values
  • Optionally Solar Powered
  • Has a full database containing history of the environment (MySQL)
  • Monitors and reports lots of data on the solar powered system - great for education!
  • Self contained and monitored for brownouts and power issues
  • Can be modified remotely
  • Download your data to crunch it on your PC or Mac
  • Can be modified to do CWOP, SMS (Text) messaging, Twitters, webpages and more
  • Has an iPad Based Control Panel
  • Easy to connect to Twitter, WeatherUnderground, etc

This chapter will show you how to build a WiFi Solar Powered Raspberry Pi Weather Station. This project grew out of a number of other projects, including the massive Project Curacao ( www.switchdoc.com/project-curacao-introduction-part-1/), a solar powered environmental monitoring system deployed on the Caribbean tropical island of Curacao. Project Curacao was written up in an extensive set of articles in MagPi magazine (starting in Issue 18 and continuing through Issue 22) as well as issues of Raspberry Pi Geek Magazine.

Educational Objectives

The GroveWeatherPi Solar Powered Weather Station is an excellent education project. There are many aspects of this project that can be looked at and analyzed for educational purposes:

  • How do solar power systems behave? Limitations and advantages
  • Temperature, Wind and Humidity data analysis.
  • Shutting down and starting up small computers on solar power
  • Add your own sensors for UV, dust and pollen count and light color
  • Follow along on updates to the GroveWeatherPi story on www.switchdoc.com

What You Will Be Building

You will building a Raspberry Pi based Weather Station using the new standard for easily prototyping and building electronics and software projects, the Grove Connection System. Then you will be adding a solar power to the Weather Pi.

What is the Grove Prototyping System?

Grove is a modular, standardized connecter prototyping system. Grove takes a building block approach to Figure2assembling electronics. Compared to the jumper or solder based system, it is easier to connect, experiment and build and simplifies the learning system, but not to the point where it becomes dumbed down. Some of the other prototype systems out there takes the level down to building blocks. Good stuff to be learned that way, but the Grove system allows you to build real systems. It requires some learning and expertise to hook things up.

The Grove system consists of a base unit (stem) and various modules (twigs) with standardized connectors. The people originating the Grove system (Seeedstudio) have tried to use “stems” and “twigs” as part of the Grove lexicon. After a short period of consideration, We are dropping those names. They just aren’t needed and just confuse the issue.

The Base unit, generally a microprocessor, allows for easy connection of any input or output from the Grove modules. and every Grove module typically addresses a single function, such as a simple button or a more complex heart rate sensor.

You don’t need a Base unit to connect up to Grove modules. You an use a cable (Grove to Pin Header Converter) to run from the pins on the Raspberry Pi or Arduino to the Grove connectors. We use the Pi2Grover Grove to Raspberry Pi Interface in the GroveWeatherPi project.

Here is our full Grove Tutorial.

So what is a Grove Connector?


A Grove connector is a four pin standardized size connector used to plug into base units and Grove modules. The Figure4picture above shows the male Grove Connector. The male connectors come in flat 90 degree versions and vertical versions as in Figure 2. Seeedstudio has the exact dimensions in this specification ( http://www.seeedstudio.com/http://www.seeedstudio.com/wiki/images/6/69/3470130P1.pdf). These standardized connectors (common to all types of Grove Connectors) are the key to making this system work. They are keyed to prevent plugging them in backwards, and the four types of connectors (see below) are all designed so that if you plug the wrong type of device into the wrong type of base unit, there is no problem. They just won’t work. This is a good thing.

The one exception would be if you plugged in a 3.3V I2C Grove module that is non-5V tolerant into a 5V I2C Grove connector you could fry the device.

Description of the Weather Pi Project

Figure5GroveWeatherPi Block Diagram

The GroveWeatherPi Block Diagram looks a lot more complicated than it actually is.

The first thing to notice that the dashed lines are individual boards (Weather Board and SunAirPlus) which contain a lot of the block diagram and the second thing is that all of the sensors to the left of the diagram plug into the Weather Board board which simplifies the wiring. Don't be intimidated!

Virtually all of these wires are based on Grove Connectors.

The Subsystems

The Sensor Subsystem of GroveWeatherPi uses a WeatherBoard as the base unit and then plugs in a bunch of optional sensors such as wind speed, direction and rain and lightning detection (how cool is that!), inside and outside temperature and humidity as well as barometric pressure.

The Software Subsystem of GroveWeatherPi runs in Python on the Raspberry Pi. It collects the data, stores in in a MySQL database, builds graphs and does housekeeping and power monitoring.

The Solar Power Subsystem of GroveWeatherPi uses a SunAirPlus Solar Power Controller which handles the solar panels, charging of the battery and then supplies the 5V to the Raspberry Pi and the rest of the system. It also contains sensors that will tell you the current and voltage produced by the Solar Panels and consumed by the batteries and the Raspberry Pi. Gather that Data! More Cowbell! It also contains the hardware watchdog timer and the USB PowerControl that actually shuts off the power to the Raspberry Pi during a brownout event (after the Pi shuts gracefully down under software control).

If you are not building the optional Solar Power system, then you can just plug in a normal Raspberry Pi power supply and then you have a fully functional powered weather station.

The GroveWeatherPi Sensor Suite

The GroveWeatherPi Sensor Suite senses the following environmental values:

  • Wind Speed
  • Wind Direction
  • Rain
  • Outside Temperature
  • Outside Humidity
  • Lightning Detection
  • Barometric Pressure (and Altitude)
  • Inside Box Temperature
  • Inside Box Humidity

You can add more to the I2C bus and Analog to Digital Converter such as UV, dust counts, light color (sensing some types of pollution) and more! It's a great platform for expansion.

The sensor suite is built on the Weather Board board but there are several similar boards out there on the market.

Step 1: What Are All the Sensors on the Grove Weather Pi?

The GroveWeatherPi has 16 different environmental sensors built into the project. The system is designed to be expandable so you can add many more sensors.

The sensor list:

  • Lightning Detection
  • Outside Temperature
  • Outside Humidity
  • Inside Temperature
  • Barometric Pressure
  • Inside Humidity (optional - requires soldering)
  • Battery Voltage
  • Solar Panel Voltage
  • Raspberry Pi Power Voltage
  • Battery Current
  • Solar Panel Current
  • Raspberry Pi Current
  • Wind Speed
  • Wind Gust
  • Rain Amount
  • Wind Direction

The GroveWeatherPi is heavily based on Grove I2C Sensors.

What is an I2C Bus and What is On the Bus?

An I2C bus is often used to communicate with chips or sensors that are on the same board or located physically close to the CPU. It stands for standard Inter-IC device bus. I2C was first developed by Phillips (now NXP Semiconductors). To get around licensing issues, often the bus will be called TWI (Two Wire Interface). SMBus, developed by Intel, is a subset of I2C that defines the protocols more strictly. Modern I2C systems take policies and rules from SMBus sometimes supporting both with minimal reconfiguration needed. The Raspberry Pi is one of these devices.

I2C provides good support for slow, close peripheral devices that only need be addressed occasionally. For example, a temperate measuring device will generally only change very slowly and so is a good candidate for the use of I2C, where a camera will generate lots of data quickly and potentially changes often.

I2C uses only two bi-directional open-drain lines (open-drain means the device can pull a level down to ground, but can not pull the line up to Vdd. Hence the name open-drain. Thus a requirement of I2C bus is that both lines are pulled up to Vdd. This is an important area and not properly pulling up the lines is the first and most common mistake you make when you first use an I2C bus. More on pullup resistors later in the next section. The two lines are SDA (Serial Data Line) and the SCL (Serial Clock Line). There are two types of devices you can connect to an I2C bus. They are Master devices and Slave devices. Typically, you have one Master device (The Raspberry Pi in our case) and multiple Slave devices, each with their individual 7 bit address ().

When used on the Raspberry Pi, the Raspberry Pi acts as the Master and all other devices are connected as Slaves.


The I2C protocol uses three types of messages:

  • Single message where a master writes data to a slave;
  • Single message where a master reads data from a slave;
  • Combined messages, where a master issues at least two reads and/or writes to one or more slaves.

Lucky for us, most of the complexity of dealing with the I2C bus is hidden by drivers and libraries from the user.

Pullups on the I2C Bus

One import thing to consider on your I2C bus are pullup resistors. The Raspberry Pi has 1.8K ohm (1k8) resistors already attached to the SDA and SCL lines, so you really shouldn't need any additional pullup resistors. However, you do need to look at your I2C boards to find out if they have pullup resistors. If you have too many devices on the I2C bus with their own pullups, your bus will stop working. The rule of thumb from Phillips is not to let the total pullup resistors in parallel be less than 1K (1k0) ohms. The GroveWeatherPi has build in pullup resistors on all the I2C buses.

The I2C Bus on Weather Pi

At SwitchDoc Labs, we love data. And we love I2C devices. We like to gather the data using lots of I2C devices on our computers and projects. Project Curacao has a total of 12, GroveWeatherPi has 11 devices and SunRover (a solar powered rover under development at SwitchDoc - you will see it in 2017) will have over 20 and will require one I2C bus just for controlling the motors. We are always running into conflicts with addressing on the I2C device. Since there are no standards, sometimes multiple devices will have the same address, such as 0x70 and you are just out of luck in running both of them on the same I2C bus without a lot of jimmy rigging.

To get around this addressing problem (and our conflict with an INA3221 on SunAirPlus and the Inside Humidity Sensor) we added an I2C Bus Multiplexer to the design which allows us to have many more I2C devices on the bus, irregardless of addressing conflicts. Here is our current list of I2C devices in GroveWeatherPi including which I2C bus the devices is on in the GroveWeatherPi design:


Note that GroveWeatherPi only uses Bus 0, Bus 1 and Bus 2.

Here is what the I2C bus looks like on the Raspberry Pi after assembling the GroveWeatherPi project. This is the output from the example code with the I2C 4 Channel Mux (hence there are 4 independent busses shown for the I2C bus).

I2C Mux

4 Channel Grove I2C Mux

Test SDL_Pi_TCA9545 Version 1.0 - SwitchDoc Labs

Sample uses 0x73
Program Started at:2016-08-03 21:50:40

-----------BUS 0-------------------
tca9545 control register B3-B0 = 0x1
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0x0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- 77                         


-----------BUS 1-------------------
tca9545 control register B3-B0 = 0x2
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0x0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         


-----------BUS 2-------------------
tca9545 control register B3-B0 = 0x4
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0x0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         


-----------BUS 3-------------------
tca9545 control register B3-B0 = 0x8
ignore Interrupts if INT3' - INT0' not connected
tca9545 control register Interrupts = 0x0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- 73 -- -- -- --                         

<p>Boy, the Pi3 really takes the power, so I would add another battery of the same size for a total of 13200mAh. Depending on your location, you may have to add more panels that 3 for the Pi3.</p><p>Best,</p><p>SDL</p>
<p>Just found this article from adafruit about wiring batteries together: <a href="https://learn.adafruit.com/li-ion-and-lipoly-batteries/multi-battery-packs" rel="nofollow"> https://learn.adafruit.com/li-ion-and-lipoly-batt...</a></p><p>Suggests that you don't wire together two batteries.</p>
<p>Hey SDL,</p><p>Can you clarify what you mean by &quot;add another battery&quot;? Do you mean wire the two batteries together? Or are there multiple connections on the board for attaching multiple batteries?</p><p>Thanks,</p><p>Tim</p>
<p>The battery needs to be a 3.7V LiPo battery. Here is a link that discusses cells and how they are wired.</p><p>http://www.rcaces.org/RC%20Aces%20News%20Letter/A_Guide_to_LiPo_Batteries.pdf</p>
<p>Here's the recommended battery from the parts list: <a href="https://www.adafruit.com/products/353" rel="nofollow"> https://www.adafruit.com/products/353</a></p><p>Does the battery need to be 3 cells?</p>
<p>Hello,</p><p>I just bought the bundle and had a question on the LiPo. I'm not using the solar option yet.</p><p>* PKCELL Lithium Ion (LiPo) Battery Pack &ndash; 3.7V 6600mAh. I'm using the Pi 3, should I use this battery of something larger? Also, when I upgrade to use the solar panels, will I need a different battery?</p><p>Thanks,</p><p>Tim</p>
<p>Hi!</p><p>I am new to this and getting ready to order parts to start my build, Am I able to use a Rasp Pi3? and where can i find the code to program all the sensors into the pi</p><p>Thanks</p>
Donovan,<br><br>You can use a Raspberry Pi 3 with no problem. That is what we do our development on in the lab.<br><br>The software can be found at:<br>https://github.com/switchdoclabs/SDL_Pi_GroveWeatherPi<br><br>Best,<br>SDL
<p>Thanks, i have my pi, do i need the rest of the hardware before i do all the software installs? is it like and auto detect? </p><p>i am new to all of this and seems that im way lost.</p>
<p>Hello SDL,</p><p>I'm getting ready to buy the GROVEWEATHERPI PRODUCT BUNDLE....</p><p>I have no experience with the Raspberry Pi or weather stations and had a couple questions:</p><p>* Using the code on github ( <a href="https://github.com/switchdoclabs/SDL_Pi_GroveWeatherPi" rel="nofollow"> https://github.com/switchdoclabs/SDL_Pi_GroveWeat...</a> ), is it possible to modify it so that I can take the information from the sensors (temp, wind speed, etc.) and post it to my own server in the cloud via an http call? I assume so but not sure to what extend I can modify this code and also no experience with python.</p><p>* Assuming I can do the above, can you recommend a device that will work with the Raspberry Pi that'll give me access the internet? For example, something like this: <a href="http://sixfab.com/product/3g-4glte-base-shield/" rel="nofollow"> http://sixfab.com/product/3g-4glte-base-shield/</a></p><p>Thanks for your help!</p><p>Tim</p>
Hi Tim,<br><br>Yes, you can modify the software to do just exactly what you want. You can add additional sensors. You will have to learn Python, but hey, that is what the project is for.<br><br>Yes, I think that shield will work. Remember, once you are connected to a network, everything works just the same as if you plugged into a router. But slower. :)<br><br>SDL
<p>Thanks! Just bought the bundle</p>
<p>It would be great if we could use Adafruit&rsquo;s Weatherproof TTL Serial JPEG Camera with NTSC Video and IR LEDs.</p><p><a href="https://www.adafruit.com/products/613">https://www.adafruit.com/products/613</a></p>
<p>my weather station will suddenly stop reporting after about 3 hours. Sometimes it fixes itself, but most times I have to reboot the pi. Was able to verify the network, or the pie losing connection to the Internet.</p>
<p>Wiring the components for the system raises this question:</p><p>Using the grove cable with the female pin headers I've connected to scl, sda, vdd, and gnd on the SuAirPlus now I'm looking for grove connector labeled JP5 on the 4 chan I2C muxer but what I find is a pin header labeled JP5 with an adjacent grove connector labeled j4. Is j4 the right connector for this cable?</p>
<p>You are correct. It is J4. Wiring list updated.</p>
<p>I still don't have this wired right. Here is a picture:</p><p><a href="http://sullyatvf.net/electronics/sdl_weatherpi/" rel="nofollow">http://sullyatvf.net/electronics/sdl_weatherpi/</a></p><p>I<br> have the SunAirPlus wired with a grove cable-female ends from J4 on the<br> 4chan muxer to the four pins vdd, gnd, scl, sda on SunAirPlus. With <br>the SunAir in the system, the program runs for ~5min then stops with an <br>io error #5. It seems to pat the dog but never blinks the led on the <br>SunAir. Nothing is pushed to the database.</p><p>If I remove the SunAir<br> from the system it seems to operate normally with data to the database <br>and drawing graphs,etc. I haven't seen about 30mn or 48hr events but <br>even if they aren't working that would be another problem.</p><p>I'm confused by the wire list for the SunAirPlus. First four &quot;from&quot; entries read &quot;SunAirPlus - From Computer / SCL&quot; </p><p>Last entry reads &quot;Grove Connector (Previous 4 Items)&quot; ??? To &quot;4 Chan 12CMux / Grove J4 - Bus 2&quot;.</p><p>Seems it has to be something about the wiring of the SunAirPlus even though it does read the current/voltage data.</p><p>I just saw that the Pi is rebooting about (not sure about exact time) every 2hr and 23 min. What's this about? Checking it out.</p><p>Thanks. I love the project and am learning a lot.</p><p>TS</p>
<p>I put a revised copy of this comment on SDL Site on the Projects section of the Forum.</p>
<p>Do you see SunAirPlus on the TCA test? put the results in a reply.</p><p>i2cdetect and the TCA test won&rsquo;t pick up the AM2315 because of the funky way it works.</p><p>From the AM2315 product page:</p><p>If you don&rsquo;t see it on your i2cdetect on the Raspberry Pi or I2C scanner on the Arduino, remember the following two things:</p><p>1) Check your wiring. Note that the colors aren&rsquo;t a reliable guide to what wire goes where. Make sure you read the label on the wires. I&rsquo;m sure you have done this, but check it again. The colors vary from batch to batch.</p><p>2) The AM2315 Outdoor temperature sensor is at address 0x5C. The manufacturer of the device puts the sensor into a sleep mode except when it is going to be used to avoid self heating of the sensor. That makes sense, however, it means you have to go through a funny sequence to make sure the device is awake and responding. It doesn&rsquo;t respond to an Arduino I2C scan nor a Raspberry Pi I2C scan, i2cdetect.</p><p>You can run the i2cdetect -y 1 twice quickly and it will often pick the sensor up on the second run.</p><p>The best thing to do to determine if it is actually there is run the test software and see if you are getting data. That is how we detect if it is present.</p><p><a href="https://github.com/switchdoclabs/Pi_AM2315">https://github.com/switchdoclabs/Pi_AM2315</a></p><p>If you are reading the current voltage from SAP, it&rsquo;s hooked up correctly.</p><p>Send us the output of the TCA test and let me see all of the buses.</p><p>I&rsquo;m wondering if you have the TCA I2C mux wired up correctly.</p><p>Post your picture on the SDL forum. We will copy this reply to the instructable for everyone else.</p><p>Best,SDL</p>
<p>Very nice project. Kudos to the entire team! Very tempted to start building it. Will it work with RPI2s or RPi3?</p>
<p>Thank you! We are pleased with the results. It will work with a RPI2 or RPI3. We developed it on a RPI3 and then move to a PiZero when we deployed it.</p><p>SDL</p>
<p>Looks good! Did you manage to get the wind vane working accurately? Boy was that thing a PITA! </p><p>How does this connect to wifi if it's away from the house?</p>
<p>Pretty well really. We use a 16 bit ADC which helps a great deal. Makes the system much more resident to noise.</p><p>We are using our solar powered WXLink system which will go about 600 meters.</p><p><a href="http://www.switchdoc.com/2016/08/raspberry-pi-datalogger-update-wxlink-now-supported/">http://www.switchdoc.com/2016/08/raspberry-pi-data...</a></p><p>We just finished a kickstarter for this project and are now furiously writing the documentation.</p><p>We have some LoRa boards but we haven't tried those yet. Soon, soon!</p><p>SDL</p>
<p>This is my system here: </p><p>https://www.instructables.com/id/Arduino-GPRS-Weather-Station-Part-1/</p><p>Part 2 coming this winter with pro wind sensors.</p>
<p>Very Cool system. Love your solar panel!</p><p>SDL</p>
<p>Have you considered integration with weather software such as WeatherDisplay?</p>
<p>Haven't done that one yet. However, I think you can use our WeatherUnderground data interface to connect up to WeatherDisplay</p><p>SDL</p>
<p>What was the total cost for this project?</p>
<p>Around $250 or so depending on what you buy.</p><p>SDL</p>
I have a question. I power the pi and the led on the as in the pi to Grove light up but the Grove weather board and the rest of the components that have led does not. Do I need to do something else or what? Thanks
<p>Joreg,</p><p>We saw your request over on <a href="http://www.switchdoc.com"> www.switchdoc.com</a></p><p>Post a picture of your setup so we can look at your wiring. You have wired something wrong.</p><p>SDL</p>

About This Instructable




Bio: SwitchDoc Labs, LLC is a software and hardware engineering company producing specialized products and designs for the small computer industry maker movement (Raspberry Pi, Arduinos ... More »
More by SwitchDocLabs:GroveWeatherPi - Solar Raspberry Pi Based Weather Station - No Soldering Required (Updated October 24, 2016) Build a Solar Powered ESP8266 Using XML on the Raspberry Pi with Python 
Add instructable to: