Introduction: Checking the Weather With the Wolfram Language + Raspberry Pi (Author: Arnoud Buzing)
This post shows how to use a weather station module with the Wolfram Language on a Raspberry Pi.
To recreate this experiment you will need the following hardware (in addition to the Raspberry Pi itself):
Step 1: Configure Your Raspberry Pi
First configure your Raspberry Pi for I2C interface support as described in the ReadMe.pdf from the manufacturer.
Step 2: Connect the Weather Station Board
Next turn off your Raspberry Pi and connect the Weather Station board to
the 26 pin interface.
Turn your Pi back on and check that the device is detected:
> sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4e --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- --
Step 3: Started Wolfram Language As Root
The Weather Station requires root privilege for access so the Wolfram Language or Mathematica needs to be started as root for this experiment.
In a terminal start the Wolfram Language using the following command (as root):
> sudo wolfram
Wolfram Language (Raspberry Pi Pilot Release)
Copyright 1988-2013 Wolfram Research
Information & help: wolfram.com/raspi
In[1]:=
Step 4: Open the Device
First we open the device:
In[1]:= obj = DeviceOpen["RaspberryPiWeatherStation"]
Out[1]= DeviceObject[{RaspberryPiWeatherStation, 1}]
Step 5: Measure Temperature
Next we can read the current temperature as measured by the board:
In[2]:= DeviceRead[obj, "Temperature"]
Out[2]= 25 degrees Celsius
Step 6: Measure Relative Humidity
Or the relative humidity:
In[3]:= DeviceRead[obj, "Humidity"]
Out[3]= 30 percent
Step 7: Measure Barometric Pressure
And also the barometric pressure:
In[4]:= DeviceRead[obj, "Pressure"]
Out[4]= 993 hectopascals