loading

Spurred on by the completion of my two previous projects, the Compact Camera and Portable Games Console, I wanted to find a new challenge. The natural progression was an outdoor remote system...

I wanted to build a Raspberry Pi weather station that was able to sustain itself off grid and send me the results through a wireless connection, from anywhere! This project really has had its challenges, but luckily powering the Raspberry Pi is one of the main challenges that has been made easy by using the PiJuice as a power supply with it's added solar support (complete with our revolutionary PiAnywhere technology – the best way to take your Pi off the grid!).

My Initial thought was to use the fantastic AirPi module to take readings. This however, had two main drawbacks; it requires a direct internet connection to upload the results and it needs to be connected directly to the GPIO on the Pi which means it can't be exposed to the air without also exposing the Raspberry Pi (not ideal if we want this weather station to last any length of time).

The solution... build my own sensing module! Using much of the AirPi for inspiration I was able to put together a very simple prototype using a few sensor I already had; temperature, humidity, light levels and general gases. And the great thing about this is that it's really easy to add more sensors at anytime.

I decided to use a Raspberry Pi a+ mainly due to its low power consumption. To send me the results I used the EFCom Pro GPRS/GSM module, which can send a text straight to my mobile phone with the results! Pretty neat right?

I'm glad to here of any ideas you have for other great solar or portable projects. Let me know in the comments and I'll do my best to create a tutorial!

Step 1: Parts

Step 2: Sensing Circuit

There's quite a few different elements to this project, so it's best to do everything in steps. First off I'm going to go through how to put together the sensing circuit.

It's a good idea to build this on a bread board first, just in case you make any mistakes, I have included a circuit diagram and step by step pictures, to be referred to.

  1. The first component to get wired up is this MCP3008 analogue to digital converter. This can take up to 8 analogue inputs and communicates with the Raspberry Pi via SPI. With the chip facing up, and the semi-circle cut away on the end furthest from you, the pins on the right all connect to the Raspberry Pi. Connect them up as shown. If you'd like to learn a little more about how the chip works here's a great guide to the MCP3008 and the SPI protocol.
  2. The pins on the left are the 8 Analogue inputs, numbered 0-7 from top down. We will only use the first 3 (CH0,CH1,CH2), for the LDR, the general gas sensor (TGS2600) and the temperature sensor (LM35). First connect the the LDR as shown in the diagram. One side to ground and the other to 3.3V via a 2.2KΩ resistor and CH0.
  3. Next, connect the "general gas sensor". This gas sensor is used for detection of air contaminants such as hydrogen and carbon monoxide. I haven't yet worked out how to get specific concentrations, so for now the result from this sensor is a basic percentage level, where 100% is fully saturated. With the sensor facing up (pins on the underside), the pin directly to the right of the small outcrop is pin 1 and then the numbers increase clockwise around the pin. So pins 1 and 2 connect to 5V, pin 3 connects to CH1 and ground via a 22KΩ resistor and pin4 connects straight to ground.
  4. The final analogue sensor to connect is the LM35 temperature sensor. This has 3 pins. Take the sensor so the flat side is closest to you, the left most pin connects straight to 5V (not marked on diagram, my bad!), the centre pin connects to CH2 and the right most pin connects straight to ground. Easy!
  5. The last component to connect is DHT22 humidity sensor. This is a digital sensor so can be connected straight to the Raspberry Pi. Take the sensor with the grid facing you and the four pins on the underside. Pins are ordered from 1 on the left. Connect 1 to 3.3V. Pin 2 goes to GPIO4 and 3.3V via a 10KΩ resistor. Leave pin 3 disconnected and pin 4 goes straight to ground.

That's it! The test circuit's been built. I'm hoping to add more components when I have the time. I'd really like to add a pressure sensor, a wind speed sensor and I'd like to get more intelligent data on gas concentrations.

Step 3: GSM Module

Now that the sensing circuits been built, there needs to be a way of receiving the results. That's where the GSM module comes in. We're going to use it to send the results over the cellular network in an SMS, once a day.

The GSM module communicates with the Raspberry Pi via serial using UART. Here's some great info on serial communication with the Raspberry Pi. In order to take control of the Pi's serial port we need to do some configuration first.

Boot up your Raspberry Pi with a a standard Raspbian Image. Now change the file "/boot/cmdline.txt" from:

"dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait"

to:

"dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait"

by removing the underlined section of text.

Secondly, you need to edit the file "/etc/inittab", by commenting out the second line in the following section:

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100"

So that it reads:

"#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100"

and reboot the Pi. Now the serial port should be free to communicate with as you wish. It's time to wire up the GSM module. Take a look at the circuit diagram in the previous step and the pictures above to see how this is done. Basically, TX is connected to RX and RX is connected to TX. On the Raspberry Pi TX and RX are GPIO 14 and 15 respectively.

Now, you probably want to check that module is working, so lets try to send a text! For this you need to download Minicom. It's a program that allows you to write to the serial port. Use:

"sudo apt-get install minicom"

Once it's been installed minicom can be opened with the following command:

"minicom -b 9600 -o -D /dev/ttyAMA0"

9600 is the baud-rate and /dev/ttyAMA0 is the name of the Pi's serial port. This will open a terminal emulator in which whatever you write will appear on the serial port, i.e. be sent to the GSM module.

Insert your topped up sim card into the GSM module and press the power button. After which a blue led should come on. The GSM module uses the AT command set, here's the documentation if you're really interested. Now we check that Raspberry Pi has detected the module with the following command:

"AT"

the module should then respond with:

"OK"

Great! Then we need to configure the module to send an SMS as text rather than binary:

"AT+CMGF = 1"

again the response should be "OK". Now we write the command to send an SMS:

"AT+CMGS= "44************* "", replace the stars with your number.

The modem with respond with ">" after which you can write you message. To send the message press <CTRL-Z> . That's it, and with any luck you've just received a text straight from the your Raspberry Pi.

Well now that we know the GSM module is working you can close minicom; we wont need it for the rest of the project.

Step 4: Download the Software and Dry Run

By this stage everything should all be wired up and ready to test for a dry run. I've written a pretty simple python program that will take readings from each sensor and then send the results to your mobile phone. You can download the whole program from the PiJuice Github page. Now could also be a good time to test with the PiJuice module. It just plugs into the Raspberry Pi's GPIO, all of the wires connected to the Pi just get plugged straight into the corresponding pin outs on the PiJuice. Easy as Pi. To download the code use the command:

"git clone https://github.com/pijuice/weatherstation.git"

This is set up to send data once a day. For testing purposes this isn't great, so you might want to edit the program. This is easily done; just open up the file; "sudo nano weatherstation.py". Near the top there's a "set delay" section. Comment out the line "delay=86400" and un-comment "delay=5". Now the results will be sent once every 5 seconds. You'll also want to change the program so that it contains your own mobile number. Find where it says "+44**********" and replace the stars with your own number.

Before you run the program you will just need to download a library for reading the DHT22 humidity sensor:

"git clone https://github.com/adafruit/Adafruit_Python_DHT.git"

And the library needs to be installed:

"cd Adafruit_Python_DHT"

"sudo apt-get update"

"sudo apt-get install build-essential python-dev"

"sudo python setup.py install"

Cool, now you can test the program.

"sudo python weatherstation.py"

As the program is running the results should be sent to your mobile but also printed in the terminal every 5 seconds.

Step 5: Build the Circuit.

Now that everything's working in practice, it's time to build the real thing. The pictures show the general idea of how the whole unit fits together. There are two separate housing units; one for the sensing circuit (which will have holes to allow air to circulate inside) and one for the Raspberry Pi, GPRS unit and PiJuice, (completely watertight) the solar panel will be wired into the computing unit with a water tight junction. The two units can then be easily detached so that either the sensor housing or the computing housing can be removed without having to take down the whole unit. This is great if you want to add more sensors or if you need your Raspberry Pi or PiJuice for another project.

You'll need to break the protoboard to fit inside of the smaller of the two junction boxes. This is where the sensing circuit is housed. The sensing circuit is now transferred from the breadboard to the protoboard. Now you will need to do some soldering. Make sure you are comfortable with using a soldering iron safely. If you are unsure, then ask for the help of somebody who is a competent solderer.

Many thanks to Patrick in the lab over here, who saved me from making a real hash of this circuit. He managed to knock it together in a matter of minutes! If, like me, you're not the best a building circuits, and you don't have a genius like Patrick ready to help you, then you could always leave the circuit on a breadboard, as long as it fits in your electrical box.

Step 6: Preparing the Housing Units

This part is where it gets really fun. You may have noticed the rings on each box. These are designed to be knocked out so that boxes can become junctions for electrics. We'll use them to connect between the sensing unit and the computing unit, for connecting to the solar panel and also as ventilation for the sensing unit to allow air circulation.

First knock out one hole on each box for connection between the two, as seen in the pictures. Knocking out the holes can be tricky to do neatly, but a rough edge doesn't matter. I found the best method is to use a screw driver to first pierce the indented ring around each hole, and then pry it off like a paint tin lid. The waterproof cable connector is then used to connect the two boxes.

Then you'll need to make another hole in the computing housing for the solar panel wire. This is hole is then plugged with one of your semi blind cable grommets. Before you put the grommet in pierce a hole in it for the cable to go through. This needs to be as small as possible to keep it watertight, then push the micro usb end through the hole (this is the end that connect to the PiJuice).

Finally an extra hole needs to made in the sensing unit to allow air in and out. I've decided to go for the whol directly opposite the junction between the two boxes. It may be necessary to add a second hole. I guess we'll find out after some time using the weather station.

Step 7: Wiring Up and Finishing the Weather Station

Right, nearly there. The final stage is to wire everything up.

Starting with the computing unit. In this box we have the Raspberry Pi, The PiJuice which connects onto the Raspberry Pi GPIO and the GSM module which connects into the GPIO breakout on the PiJuice via female to female jumper wires. Nice and snug! at this stage I would probably advise putting some sort of sealer around entry point for the USB cable for the solar panel. Some sort of resin, or superglue would probably work.

Then move onto the sensing unit. In the photo, from top to bottom, the wires are; grey, white, purple and blue are the SPI data lines, black is ground, orange is 3.3V, red is 5V and green is GPIO 4. You will need to find jumper wires to connect to these and then feed them through the waterproof cable connector as seen in the photographs. Then each wire can be connected to the corresponding GPIO and the connector can be tightened up. At this stage it's easy to see how the design could be improved; the LDR is not going to be exposed to a great deal of light (although may still be useful to know relative values, and knocking out an extra hole might help), I think it would be better to use the same size as the computing unit box for the sensing unit also, then it would be easier to fit the circuit board into the box and there would be room to play with different arrangements.

I've put it up out in the garden now, as you can see in the photos. Hopefully in the next few days i'll be able to post some results too! And like I said earlier, if you've got any ideas for some cool projects, let me know!

<p>hello, i need to build a lo-cost weather station with several sensors:</p><p>CO2, temp, hum, pressure, wind speed/direction and pluviometer.<br>it has to run off-grid for an unlimited amout of time, do you think your project fits my needs?</p><p>thanks</p>
Ok, here is my question. I want basically whay you've done but a few more sensors and ability to bluetooth or hotspot/connect my phone to it to pull readings and propagate certain programs. Can you point in the right direction?
<p>Wow! It looks very useful to gather the weather data!! Thanks you.</p>
<p>hello Sir. just wanna know if this project will work out. You're inspiring me to make this project. </p>
<p>Great project! I was wondering if it was possible to make a simple weather vane for RasPi B and log the data over months and maybe an emailed monthly summary?</p>
<p>Hi! Great instructable. I&acute;m looking for a solution that can monitor my local surf break. It has to be self sustained with solar power and be able to publish a low-res picture to an internet server via 3G GSM. Any ideas on this?</p><p>Such a solution I guess could be used for a number of different applications.</p>
<p>Hi Jonas, that's a great idea, and something I've been looking at doing myself. I think the solution would be to use a 3G or 2G module, such as the sparqee cell, or the Adafruit FONA. then once a ppp connection has been established it would be either be a case of uploading photos straight to the web or using FTP to transfer to a remote computer. As I say, I'm looking to do something very similar and I plan to put a guide soon.</p>
Hi again,<br><br>I&acute;m curious if you did try this out?<br>
<p>That sounds awesome! The Adafruit FONA looks promising. Combine that with the Raspberry Camera Module. OR maybe an external USB camera for more control of the pictures (zoom). Power the PiJuice Solar. And then finally write a software that takes a picture every 5 minutes and pushes it all to a Dropbox account or web server. </p><p>What a fantastic solution this would be! As I am a total newbie, I&acute;m looking forward to see this guide.</p>
<p>Hello<br><br>I liked your post and the points for not using airpi. The last thing I want on my network is yet another iot device which connects out to its C&amp;C somewhere like chinese cameras. <br><br>I wonder if it's possible to add an anemometer to your setup like:<br><br>http://www.adafruit.com/products/1733<br><br>Hooking it up to that ADC converter shouldnt be a problem. The datasheet says its going from 0.4 - 2V DC but it also needs some standby voltage. The page doesnt say how many mA does this consume but do you think I would need a bigger pijuice battery than the default?<br><br>Also I would like to know if I order the pijuice solar kit, does the solar panel waterproof so I can mount the whole thing up on a pole at the middle of the garden?<br><br>Where is the best way to put this weather station anyway? I guess putting it close to your heated homes wall is not the ideal place to get accurate readings.<br><br>Thank you!</p>
<p>Hi Iced2! Sorry for the late reply, been really busy! Anyway, adding a camera is certainly a possibility and easy to implement. </p><p>And anemometer would also be a great addition too, and the adafruit one with an ADC looks good. I think a bigger battery is sensible but not particularly for the anemometer but rather because of the nature of solar power; you'de want max capacity to store max energy during sunny periods so that when it becomes cloudy or night time you should have enough juice to last!</p><p>The solar panel provided is waterproof and yes I think putting it next to your house is not ideal. I would suggest a region that's exposed to sunlight, but not too exposed to driving rain, as although this &quot;weatherproof&quot; I wouldn't go as far as to say waterproof! </p><p>If you give it a go be sure to post an instructables! </p>
is there a schematic of the sensing circuit available?
<p>Hey, yeah the picture in step 2 should do the trick!</p>
<p>great work!</p>
<p>Thanks! </p>
<p>Hi! PiJuice...Is there a way to make this project with Arduino...if there is???..Please make an instructable on it...</p><p>Thanks a lot!!! </p>
<p>Hi Ritik,</p><p>I'm sure there's a a way to do something similar with arduino, and in some ways may be a little simpler. Unfortunately, you might find powering the arduino to be the trickiest part, since the PiJuice is designed for the Raspberry Pi only. </p>
Hi PiJuice,<br>Great article! Nice tidy solution! One small question, why do you take the temperature from the LM35 instead of the DHT22? I see you read the temperature from in in your code but dont use it.<br><br>Thanks!
<p>Hi. Glad you liked it. I believe the DHT22 is unable to measure temperatures below 0.</p>
<p>I think the datasheet states the DHT22 will measure between -40 and +80 deg C.</p><p>Not sure if that's any use for you :-)</p><p>Either way, great project! Thanks for replying to me.</p>
<p>Thanks, I'll look into it. </p>
Very nice, there is any possibility to download a compete PDF project? Tks ciao Roberto
<p>Thanks! I believe there's a link at the top of the page to get the tutorial as a PDF. Let me know if you can't see it. </p>
Add a anemometer and a wind vane to it!
<p>These would certainly be cool! </p>
Hi! it would be awesome to add a camera to this and be able to trigger mms with pictures. Great stuff!
<p>Hi Razool. Yes this is a great idea. I have a remote camera system and CCTV camera in the pipeline! </p>
<p>About how much did everything cost all together?</p>
<p>Hi Maxenvironment. I estimate the costs to be about &pound;120. That's including everything. Obviously it would depend on where you are ordering the parts from though. </p>
<p>You MUST enter this in the Pi/e Contest! Truly stellar work and documentation here. Wow! </p><p>www.instructables.com/contest/piedaycontest/</p>
<p>So glad you liked it! Thanks for the hint.:) </p>
<p>I really like what you've done here, and because of this post I went and pre-ordered a PiJuice. Though what is the point of putting an air quality sensor, inside an airtight container? Unless it's going to be monitoring internally for water leaks? Beyond this I find this REALLY great and can't wait to build something similar!</p>
<p>Hi _neckbeard. Glad you liked it, and thanks for pre-ordering! Actually the sensing unit is not sealed, there's a hole in the bottom which allows air to circulate. In contrast the computing unit is completely air tight, for obvious reasons. That's the point of the two seperate units. </p>
<p>Looks like a great project. How hard would it be to use a wifi connection to a website (or tweet) instead of using GSM?</p>
<p>Hey, thanks! I don't think it would be very hard. Perhaps look at using SFTP to transfer straight to your computer. I'm not sure of the best way to upload straight to a website using code, but I'm sure it's been done, so shouldn't be too hard to find a tutorial somewhere online. </p>
<p>I wondered how you'd managed to get the PiJuice to power the Weather Station... You are PiJuice! :)<br>Just backed it on <a href="https://www.kickstarter.com/projects/1895460425/pijuice-a-portable-project-platform-for-every-rasp" rel="nofollow">Kickstarter</a> With 2 hours to go! :)<br>I will be building one of these, Thanks!<br><br></p>
<p>wow, I missed it by like a night, so can't back it with kickstarter anymore :(</p>
<p>I am PiJuice! haha. Thanks for the backing Peter</p>
<p>You know it's a good tutorial when the only criticism is your grammar ;-)</p>
<p>Likewise, if they say you used the wrong typeface!!</p>
<p>Nice instructable thank you.</p><p>But you can get a ESP8266 off ebay for less than $3.00 to handle your WiFi with AT commands.</p><p>And then you can use LUA to use the onboard micro in place of the Pi to attach your sensors.</p><p>https://www.google.com/search?q=ESP8266&amp;rlz=1C1CHTX_enUS512US513&amp;oq=ESP8266&amp;aqs=chrome..69i57j69i60l3j69i65l2.5487j0j7&amp;sourceid=chrome&amp;es_sm=122&amp;ie=UTF-8</p>
<p>If I don't have (read, can't afford) the EFCom Pro GPRS/GSM Module right now, how much work is involved in using simple wifi to email or ftp a report to xyz.TLD at regular intervals?<br><br>Any sites you know of that would have this type of code already made up (read, I cant code for toffee)?<br></p>
<p>There's a good article on the Adafruit site at https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging which shows how to log results to Google Drive, which might help</p>
<p>hello,</p><p>Good work, I buy a pijuice for this project.</p><p>By cons, is that it is possible to store or otherwise disseminate data in a simple way? I would use it near a rj45 or wifi conexion</p>
<p>I was tempted to make these myself! Although I think I would add a webcam and use motion to send pictures.. given that would use a bit more power!</p>
<p>Hi there. Interested to hear a bit more about why the AirPi idea didn't progress. Was planning to combine that with PiJuice Solar and a camera in a DIY Stevenson screen box thing as a weather station/security camera combo. Would put the Pi/PiJuice in case with only the AirPi exposed within the box. Would a wifi dongle and a GPIO extension cable have solved the problem.</p>
<p>Hi handsomefish. The AirPi is a cool piece of kit, and I wouldn't advice you against using it. A wifi dongle and extension cable would solve the problem, but I didn't go that route for two reasons. Firstly, I wanted this weather station to be really remote. I.e. with the capability of transmitting results from areas without wifi, hence the use of the GSM cellular network. Secondly, to use the AirPi software without any manipulation, you need a &quot;Xively&quot; online account, from here you can access your results. Unfortunately there's a pretty long waiting list to get an account with Xively. It is possible to use the AirPi without Xively and there's a few tutorials on how to do it either with MySQL or straight to a .txt file I believe, but I thought that for the trouble it might be worth, it would be more fun the build my own circuit. </p>
It's great to know that there's no fundamental issue with the AirPi. I wouldn't have know where to start without my kit. I already have it up an running connected to another Pi, so am looking forward to getting my front-door online!<br><br>FYI for other budding weather stationeers, this project (https://github.com/haydnw/AirPi) has branched the AirPi software and provides several features over and above the original, including more output options, over and above xively.
<p>Quite a good tutorial indeed. But for my <br> taste I would have liked to see a Rain gauge (self emptying) , wind-speed and wind direction sensors <br> as well. But I suppose adding them myself would not be a problem.</p><p>I <br> wonder if can buy the above sensors that will not involve a <br> re-morgage - over here in Germany they seem to be quite expensive but are of high quality.</p><p> Maplin has one but will not ship to Germany. Post from the US is too high.</p><p>Anyone got any tips for me. I really like my own weather station!</p>
<p>Hi Bonzadog. Glad you liked it! Yes those would really be great additions. That's the idea of this project; it's pretty rough and ready and so could easily be adapted to your own needs. </p><p>I really like the idea of putting a pressure sensor on too. </p><p>I'm not sure how best to get the sensors in Germany, but you don't specifically need the ones that I've used. </p><p>If you wanted to get really adventurous you could try building your own rain gauge with some scales and a mechanical emptying mechanism, the wind speed sensor would probably be a little harder because I imagine you'd have to purchase a more expensive sensor in order to calibrate your home-made one anyway but perhaps something worth considering. </p><p>I'll keep an eye out for cheaper sensors that you might be able to get in Germany.</p>

About This Instructable

133,479views

1,192favorites

License:

Bio: PiJuice is a product from the company, Pi Supply. Pi Supply is a Maker emporium located in the UK that ships maker products worldwide!
More by PiJuice:Raspberry Portable Pi Laptop Raspberry Pi Solar Weather Station Raspberry Pi Portable Games Console 
Add instructable to: