As I mentioned before, I got a Raspberry Pi Zero W to replace my Arduino MKR WIFI 1010 and ENV board in the bathroom. My Pimoroni Enviro Mini pHAT (or bonnet, as Adafruit calls them) finally arrived a few days ago, so I setup a git repository for my code. The Pimoroni git Enviro+/Enviro Mini repository has a one-line configuration, but I’d rather do things manually so I know what I’m doing and also so I can set up a proper requirements.txt in my Python venv.
- sudo apt install python3 venv
- In my development directory: python3 -m venv .
- activate the virtual environment: source bin/activate
- pip install enviroplus
- Enable I2C and SPI. Either use: sudo raspi-config interactively or their commands. I went for interactive.
- I’m not using the Enviro+ and air quality monitor, so I don’t need to enable the serial interface.
- install a few more dependencies: pip install numpy smbus setuptools Pillow Rpi.GPIO
That should give you a system that’s ready to work with the pHAT. So I cloned Pimoroni’s repo and ran the all-in-one-enviro-mini.py in the virtual environment. Turns out if you install numpy via pip and not apt, you’re missing a dependency. So you EITHER need to run
sudo apt install python3-numpy OR sudo apt install
I did the latter.
You will also need to run
sudo apt install python3-pil libopenjp2-7-dev
to make sure you have some dependencies on the system.
The all-in-one-enviro-mini script produces a graph on the screen. To change the graphs, cover the light sensor. It’s the demo that’s on the Adafruit site. It’s not quite what I wanted to base things on. But at least I knew it was now working. Note: Control-C will quite the program, but will not turn off the screen. It just stops updating.
After taking a look at the various examples they have on there, it looks like I’m going to want to base my code on weather-and-light.py. My goals will be to:
- add MQTT via the Paho library so it can communicate with Home Assistant (or anything else I hook up to MQTT)
- set it up to turn off the screen at night when we’re asleep (no need to burn out the LEDs if no one’s going to be looking)
- change the temperature to Fahrenheit
- set it up to start when the Raspberry Pi starts.