Remote Controlled Weather Station
by TechnoFrost in Circuits > Arduino
673 Views, 6 Favorites, 0 Comments
Remote Controlled Weather Station
Today we’ll be creating a remote controlled satellite weather station using a Raspberry Pi, a temperature sensor and a RockBLOCK. The envisioned application would be a weather station in a really remote location (i.e. outside of mobile/cellular coverage) – maybe in the middle of the desert, the jungle, or even the arctic – sending its data back to some kind of central weather system.
We’ll keep it really simple, using just one temperature sensor, but additional sensors could be added very easily to expand the scope – to measure humidity, atmospheric pressure or light levels. The temperature sensor used is a Maxim DS18B20 digital thermometer which provides a reasonably accurate reading (+/- 0.5 degrees) over a wide temperature range (-55 to +125C)
The weather station application will periodically transmit its sensor readings using the RockBLOCK. For those of you who don’t know the RockBLOCK, it’s an awesome little module that enables small amounts of data to be sent/received via satellite from anywhere in the world. Ideal for creating all manor of remotely deployed projects, like the weather station! We’ll be utilising the excellent pyRockBlock library (excellent, because it’s written by me!) to take care communicating with the satellites via the RockBLOCK.
The temperature sensor selected operates on the 1-Wire bus, which means it can be connected directly into the GPIO pins on the RPi, and with a little bit of configuration, can very easily be interrogated by Python – without the need for any additional electronics!
Supplies
Raspberry Pi
Maxim DS18B20 digital thermometer
RockBLOCK by Rock 7
Wiring
The temperature sensor has three connections: positive, ground and signal – these should be connected to pins 1 (Blue), 4 (Yellow) and 7 (Green) respectively on the Raspberry Pi.
This module would normally require a pull-up resistor, but this can actually be configured with software with the Raspberry Pi, so no need to get your soldering iron out just yet! Be careful that you connect the sensor correctly, if for example you get the ground and positive mixed up, the sensor will get very hot very quickly!
There have already been many great tutorials on using the DS1B20 sensor with the RPi – but I initially struggled to see the sensor on the RPi. I thought, it’s got three wires, how hard could it be! I discovered, that there had been some changes made to Raspbian that required an additional configuration step to get it working correctly.
So on the RPi, using your favourite editor, edit /boot/config.txt to include the following line, just add it to the bottom of the file (make sure you edit the file as root/sudo).
1
dtoverlay=w1-gpio
Secondly, you’ll need to add the modprobe drivers for the 1-Wire system to the bottom of your /etc/modules file (again, running as root/sudo).
w1-gpio w1-therm
Restart your RPi – you should now see two additional items in your startup log:
[info] Loading kernel module w1-gpio
[info] Loading kernel module w1-therm
If you’ve wired everything correctly, and the drivers have been loaded correctly, you should now be able to interrogate the sensor. The system will create a handle for the sensor in /sys/bus/w1/devices/ – there should be a sub-directory called 28-XXXXXXXXXXXX (e.g. 28-0000049b5484) – this is the unique handle to your sensor. It’s important to remember that each sensor is programmed during manufacture with a unique handle. Therefore you should never hardcode this value, it will change if you use a different sensor – you’ve been warned!
To read the current temperature sensor run the following:
cat /sys/bus/w1/devices/28-0000049b5484/w1_slave
You should see an output that looks something like this:
2a 01 4b 46 7f ff 06 10 16 : crc=16 YES
2a 01 4b 46 7f ff 06 10 16 t=18625
We’re only interested in the second line, and specifically the string t=18625 (this is the temperature) – to get decimal degrees value, simply divide this by 1000 = 18.625°C.
Software
If you’ve not done so already, follow the Satellite communications with RockBLOCK project to getting your RockBLOCK up and running.
I’ve created a simple class (temperatureBot) to query the sensor, get the raw reading and convert the value correctly into decimal degrees. This snippet prints the temperature every 10 seconds. I would recommend reading the pyRockBlock project guide, this will explain the satellite transmission steps in more detail, including the various callbacks to denote success or failure.
So the complete Weather Station application would look like this:
import time import temperatureBot from rockBlock import rockBlockProtocol class Example (rockBlockProtocol): SLEEP_INTERVAL = 60 def main(self): tb = temperatureBot.temperatureBot(None) while(True): value = tb.obtain() self.emit(value) time.sleep( self.SLEEP_INTERVAL) def emit(self, value): rb = rockBlock.rockBlock("/dev/ttyUSB0", self) rb.sendMessage("T:" + str(time.time()) + ":" + str(value) ) rb.close() def rockBlockRxReceived(self,mtmsn,data): print "rockBlockRxReceived " + str(mtmsn) + "/" + data + "/" + str( len(data) ) #F = Update Frequency e.g. F100 = Update transmission if( str(data).startswith("F") ): #Parse interval newInterval = int( data[1:] ) #Frequency should be between 30 and 3000 seconds if(newInterval >= 30 and newInterval <= 3000): self.SLEEP_INTERVAL = newInterval print "New Interval " + str(newInterval) else: print "Unknown Command Received"
Sending/Receiving Data From Your Weather Station
Messages are sent/received to/from your RockBLOCK using the Rock 7 Core, or the accompanying web-service
For more detailed information on using the accompanying web-service, please check out the Rock 7 Core – Endpoints guide.