If you're following along with a Raspberry Pi, Beaglebone or any other supported small linux computer, we'll use a special library called adafruit_blinka (named after Blinka, the CircuitPython mascot) to provide the layer that translates the CircuitPython hardware API to whatever library the Linux board provides. It's CircuitPython, on Pi!
If you haven't set up Blinka and/or the Adafruit IO Python Library yet on your Raspberry Pi, follow our guide before continuing with the steps on this page:
We "talk" to the Si7021 sensor over I2C. To do this, we'll need to set up our Pi's I2C interface. You only have to do this once per Raspberry Pi, the interface is disabled by default.
Once you're done with this and have rebooted, verify you have the I2C devices with the command:
sudo i2cdetect -y 1
The output from running this command should look like the following:
We'll need libraries to communicate with the Si7021 sensor. Since we're using Adafruit Blinka (CircuitPython), we can install CircuitPython libraries straight to our Raspberry Pi by using PyPi.
Enter the following command into your terminal to install the adafruit_circuitpython_si7021 library:
sudo pip3 install adafruit-circuitpython-si7021
To control our NeoPixels, we'll use the NeoPixel Library for CircuitPython.
Enter the following command into your terminal to install the Adafruit_CircuitPython_NeoPixel library:
sudo pip3 install Adafruit_CircuitPython_NeoPixel
The code for this guide is located on the Adafruit Learning Guides repository on GitHub under the IO House Series.
If you'd like to directly load this code on your Pi, type the following in your terminal and press enter:
git clone https://github.com/adafruit/Adafruit_Learning_System_Guides.git
Then, navigate to the directory where the code for this tutorial is located by typing the following into your terminal:
Let's check to make sure the python code is within that directory. To do this, type
ls into your terminal and hit enter. You should see
io_house_light_temp.py in this directory:
Before running the code, we need to set our Adafruit IO Key (
ADAFRUIT_IO_KEY) and Adafruit IO Username (
To do this, open the code in your text editor of choice (I'm using nano for this example) by entering the following into your terminal:
The code should open in the nano editor. Scroll down to the
Adafruit_IO_KEY variable and set it to the your Adafruit IO Key. Then, set the
Adafruit_IO_USERNAME to your Adafruit IO Username.
- If you do not have these values, navigate to your Adafruit IO Profile page and click ACTIVE IO KEY
When you're done editing the values, save the file by pressing control + x.
When prompted to save the modified buffer, type Y and press enter.
At the File Name to Write prompt, press enter and you should be directed back to the terminal.
Next, we're going to learn how the code works and run it from our Pi.