This is an example of building a weather station using a few components, that clicks together with no need for wiring or soldering.Step 1: Ready the Raspberry Pi
- Download Raspbian Lite and unzip
- Download Etcher and install
- Insert the Micro-SD card into your computer
- Run Etcher using Raspbien Lite as input and the Micro-SD card as output
- Create a empty file called '
ssh
' on the root of the Micro-SD card. On a Mac that is easiest done by opening a terminal window and type:
cd /Volumes/boot
touch ssh
- Now eject the Micro-SD card from your computer.
Assemble the Raspberry Pi with the ☒CHIPs as illustrated in the "video" at the top.
- Click the IR02 into the Raspberry Pi with the header connected to the pins closest to the Micro-SD card end of the Pi
- Click a XC10 connector into the IR02
- Click the SW01 into the connector. Make sure the sensor is facing up (the SW01 name is facing up, similar to the IR02 name), and make sure the ☒CHIPs are aligned. Only 2 of the sides of the SW01 will fit into the IR02.
- Insert the Micro-SD card into the Raspberry Pi
- Connect an Ethernet cable from your router to the Pi
- Connect a Micro-USB power source to your Pi
- Connect to your Raspberry Pi using
ssh
. From a Windows computer, you have to install assh
program such as PuTTY, but from a Mac you simply open a terminal window, and type:
ssh pi@raspberrypi.local
The default password is 'raspberry'.
Once you are logged in, type this:
sudo raspi-config
That opens a configurations program where you:
- Choose:
5 Interfacing Options
- Then choose:
P5 I2C
- Then answer "Yes" to "Would you like the ARM I2C interface to be enabled?"
Then we need to install a bit of software:
sudo apt-get update
sudo apt-get install i2c-tools python-pip
sudo pip install RPi.bme280
Let's just check that we can see the Weather sensor, type:
i2cdetect -y 1
And see if you get this:
pi@raspberrypi:~ $ 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
pi@raspberrypi:~ $
Step 4: Program and runCopy the 5 line program below into a file. Let's call it test.py
, just cut and paste the following into you terminal
echo '
import smbus2
import bme280
bus = smbus2.SMBus(1)
bme280.load_calibration_params(bus, 0x76)
print(bme280.sample(bus, 0x76))
' > test.py
Now run the code:
python test.py
...and you should see this:
pi@raspberrypi:~ $ python test.py
compensated_reading(id=7c98f6f7-a677-4766-92dd-8b5def7c038a, timestamp=2017-10-09 21:03:46.202243, temp=27.583 °C, pressure=1023.24 hPa, humidity=38.52 % rH)
pi@raspberrypi:~ $
Comments