How to build an air quality monitor using Raspberry Pi Zero W + ANAVI Infrared pHAT
MH-Z19B is an intelligent infrared CO2 module which interacts with the Raspberry Pi using UART (universal asynchronous receiver-transmitter). Takuya uses the UART port on ANAVI Infrared pHAT to attach MH-Z19B. The rest of the sensor modules for his setup are included in ANAVI Infrared pHAT Advanced kit: HTU21D for temperature and humidity, BMP180 for barometric pressure and BH1750 for light.
By the way, initially we had published open source examples for using HTU21D, BMP180 and BH1750 in the C programming languages using the library wiringpi. Takuya also based his setup on wiringpi. However, wiringpi is now deprecated therefore we have replaced it with another library called libi2c-dev. Furthermore we added examples written in Python 3.
Earlier in January all ANAVI Gardening uHAT kits were delivered to the Crowd Supply warehouse and soon after that Crowd Supply team sent them to their final destination: our valuable and trusting crowdfunding backers! Thank you again for the support.
ANAVI Gardening uHAT Developer Kit
ANAVI Gardening uHAT is a versatile development board, so please follow the instructions below for safe use:
ANAVI Gardening uHAT should only be connected to a compatible Raspberry Pi with 40-pin header.
Do not expose it to water or moisture, and do not place it on a conductive surface whilst in operation.
Do not expose it to heat from any source; it is designed for reliable operation at normal room temperatures.
Take care while handling the board to avoid mechanical or electrical damage to the printed circuit board and connectors.
Avoid handling ANAVI Gardening uHAT while it is powered on. Only handle by the edges to minimize the risk of electrostatic discharge damage.
In the meantime, there is a work in progress going on the user’s manual which is available at GitHub. We will soon update it. As usual, GitHub pull requests with improvements and fixes to the documentation or the source code examples are always welcome.
At the beginning of January all ANAVI Gardening uHAT kits were shipped to the Crowd Supply warehouse. We are happy we managed to do it ahead of schedule. Even Tux, the mascot of the Linux kernel, helped out with the transportation.
In the coming weeks, the crowdfundng orders will be prepared for shipment to backers. A tracking number when the order ships.
ANAVI Gardening uHAT
Thanks for your patience and support for this open source hardware project! We hope you will enjoy and have a lot of fun with ANAVI Gardening uHAT!
We have good news regarding ANAVI Gardening uHAT! All boards have been received almost fully assembled from the local factory and we have sourced all required peripherals.
Recently, we received the last batch of assembled printed circuit boards from the local factory. As you can see on the photo, only the EEPROM is missing. We will flash and solder it in-house.
The winter is coming… Grab a ANAVI Gardening uHAT for your Raspberry Pi
We have also received additional peripherals, which will be included in ANAVI Gardening uHAT Starter, Advanced, and Developer kits. On the photo you can see the big packages with analog capacitive soil moisture sensor. Each kit will contain a couple of capacitive soil moisture sensors.
Capacitive Soil Moisture Sensor v1.2
The recyclable cardboard boxes for our eco-friendly packaging have also already been delivered. Another local company here in Plovdiv, Bulgaria will print all stickers for us. We expect them next week.
Our crowdfunding campaign recently ended very successfully but you can still order our open source Gardening uHAT for your Raspberry Pi and be among the very first owners!
Raspberry Pi Pico is a tiny and fast development board by the Raspberry Pi Foundation built using the brand new RP2040 32-bit dual ARM Cortex-M0+ microcontroller. The major advantage of Raspberry Pi Pico is the affordable price as it is available for about $4 (without taxes and shipping).
In this video tutorial you will learn how to get started with MicroPython using the open source Thonny IDE on Raspberry Pi Pico. Thonny runs on Mac, Windows and Linux distributions, in the video it is used on Ubuntu. The video includes Pico unboxing, MicroPython installation guide, blinking LED example, MicroPython REPL demo and conclusions.
The video tutorial was sponsored by PCBway which provide high-quality prototyping services. On the photo you can see prototypes of green printed circuit boards with white silkscreen following Raspberry Pi specifications for micro Hardware Attached on Top (uHAT).
A few days ago we received an official confirmation that ANAVI Gardening uHAT has been certified as open source hardware by the Open Source Hardware Association with UID BG000079.
The Open Source Hardware Association (OSHWA) is a non-profit organization that supports the open source movement and maintains an open source hardware certification registry. OSHWA Certification provides an easy and straight-forward way to quickly check if a product complies with a uniform and well-defined standard for open source hardware.
Open source hardware certification guarantees the sharing of knowledge and keeps prices fairly based on the bill of materials of the hardware’s components. ANAVI Gardening uHAT hardware design files are available under CC BY-SA 4.0, which allows you to remix, transform, and build upon the material for any purpose, even commercially.
In a nutshell, OSHWA certifies a project as open source based on public access to four elements:
Hardware – functional elements of the product
Software – code, firmware, or other software involved in the product’s functionality
Documentation – including design files, schematics, and instructions
Branding – brand names, product names, logos, and product design
The exact certified version of each product receives a unique UID, for example, ANAVI Gardening uHAT is with UID BG000079. The prefix is the country code. We make our open source hardware in Plovdiv, Bulgaria, so the country code is BG. The suffix is a sequential ID number. At the moment, there are 79 certified open source hardware products from Bulgaria. For a comparison, the United States is leading with the amazing 2052 certified products, followed by Germany with 116. Bulgaria comes in at the third place, primarily thanks to our awesome open source neighbors from Olimex.
As a very small company we are all proud to have contributed to the Bulgarian success in this field. Hopefully, the popularity of the open source hardware movement will continue to increase worldwide.
ANAVI Gardening uHAT is a low-cost, open source Raspberry Pi add-on board that helps you develop smart solutions for monitoring and growing plants.
ANAVI Gardening uHAT supports multiple sensors for soil moisture, temperature, humidity, barometric pressure, and light. Getting started is easy: just plug it into a Raspberry Pi with your bare hands and follow the instructions in the user manual. No soldering is necessary, and no tools are required.
Raspberry Pi is a famous series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in cooperation with Broadcom. This is a step by step tutorial for using Raspberry Pi and capacitive soil moisture sensor with Microchip MCP3002 analog-to-digital converter (ADC) and a Python script for detecting the soil moisture in percentage.
Capacitive Soil Moisture Sensor
Capacitive Soil Moisture Sensor v1.2 and v2.0 measures the volumetric content of water inside the soil and retrieves the moisture level by capacitive sensing rather than resistive sensing like other sensors. The benefit of using a capacitive soil moisture sensor is the lack of corrosion and longer lifespan.
Wiring
Unlike Raspberry Pi Pico, the recently released microcontroller, all versions and models of the Raspberry Pi single-board computers do not include an analog-to-digital converter (ADC). This tutorial explains how to use Microchip MCP3002 with Raspberry Pi.
Microchip MCP3002 is a 10-bit resolution, dual channel ADC with SPI hardware bus. It can be connected to any Raspberry Pi single board computer version and model, including Raspberry Pi 4 and Raspberry Pi 0. However, this tutorial is not for Raspberry Pi Pico microcontroller. For more details about the wiring of Microchip MCP3002 a Raspberry Pi single-board computer have a look at my previous tutorial.
Prototypes for Raspberry Pi add-on boards
Alternatively, the easier option without a breadboard an a bunch of cables, is to use a dedicated Raspberry Pi add-on board with built-in ADC. Using the free and open source tool KiCad we designed ANAVI Gardening uHAT exactly for this purpose. It has dedicated pins for connecting a couple of capacitive soil moisture sensors. The prototype has been created thanks to PCBWay. This is a lead-free prototype printed circuit board with 2 layers, green solder mask and white silkscreen. PCBway offers a huge variety of colors and even flexible PCB.
Software
Flash Raspberry Pi OS, the official Debian based GNU Linux distribution by the Raspberry Pi, on microSD card and boot it. On the Raspberry Pi, open a terminal and using the raspi-config tool enable SPI as shown in the video. Reboot the Raspberry Pi.
Python3 script for reading data from a couple of capacitive soil moisture sensors through Microchip MCP3002 ADC is available at the anavi-examples repository in GitHub. The script relies on popular Python libraries spidev and RPi.GPIO. Open a terminal and run the following commands to clone anavi-examples and run the script:
git clone https://github.com/AnaviTechnology/anavi-examples.git
cd anavi-examples/anavi-gardening-uhat/soil-moistore-sensors/python/
python3 soil-moistore-sensors.py
If you are reading this blog post, I am sure you are familiar with Raspberry Pi, the a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in cooperation with Broadcom. Unlike the recently released microcontroller Raspberry Pi Pico, all versions and models of the Raspberry Pi Linux computers do not include an analog-to-digital converter (ADC). If you need to read data from an analog device such as a potentiometer, sound or soil moisture sensor the solution is to use an external ADC, for example Microchip MCP3002.
Prototyping on a breadboard with Raspberry Pi 4, 10K potentiometer and Microchip MCP3002 ADC
Microchip MCP3002 ADC
Microchip MCP3002 is a 10-bit resolution dual channel ADC with SPI hardware interface for connecting to embedded devices such as Raspberry Pi. MCP3002 operates over a broad voltage range, from 2.7V to 5.5V. It is offered in 8-pin MSOP, PDIP, TSSOP and 150 mil SOIC packages. MCP3002 PDIP package is appropriate for prototyping on a breadboard.
Raspberry Pi and Microchip MCP3002 Wiring
Microchip MCP3002 has to be connected to the dedicated SPI pins (MISO, MOSI, SCL and SS) on the Raspberry Pi GPIO header. In the video a 10K potentiometer is connected to one of the two channels of the ADC for testing purposes. The potentiometer as well as Microchip MCP3002 are powered with 5V from the Raspberry Pi.
Microchip MCP3002 attached to Raspberry Pi 4 over SPI
Enable SPI
Boot Raspberry Pi OS, the official Debian based GNU Linux distribution by the Raspberry Pi, from a microSD card. Open a terminal and using the raspi-config tool enable SPI as shown in the video. After that reboot the Raspberry Pi and proceed to the next step.
Reading Data with Python
Python3 script for reading data from analog devices through MCP3002 is available at the rpi-examples repository in GitHub. The script relies on popular Python package RPi.GPIO. Open a terminal and run the following commands to clone rpi-example and run the script:
git clone https://github.com/leon-anavi/rpi-examples.git
cd rpi-examples/MCP3002/python
python3 adc.py
The potentiometer acts like a variable resistor. Rotate it and observe the output of the Python script. You will notice a change of the voltage between 0V and 5V depending on the position of the potentiometer.
ANAVI Garderning uHAT
Thanks to PCBway, the sponsor of this video, we can go to the next level and use a prototype of ANAVI Gardening uHAT as a Raspberry Pi add-on board with SOIC package of Microchip MCP3002. ANAVI Gardening uHAT follows the specifications of Raspberry Pi Foundation for HAT (hardware attached on top), including for an EEPROM with device-tree binary overlay configurations.
Prototypes of the new Raspberry Pi add-on board with Microchip MCP3002 ADC from PCBWay
This is my RasPi called "spiderman", which is living upside down on my lab's ceiling collecting sensor data and taking pics to all those numbers. I hope its @leonanavi's infrared hat will transmit orders every 10m from my energy efficiency algorithms running in the cloud 😛 pic.twitter.com/90qk6P4ccC
Jesús has attached various sensors for collecting data as we as a Raspberry Pi camera to take pictures of the room. He has developed energy efficiency algorithms running in the cloud which make decisions based on the data from the sensor and after that ANAVI Infrared pHAT takes care for transmitting commands as a stream of infrared signals to his air conditioner.
ANAVI Infrared pHAT
ANAVI Infrared pHAT is a low-cost open source hardware add-on board for Raspberry Pi with infrared receiver and transmitted. Furthermore it has slots for attaching up to 3 I2C sensor modules as well as convenient UART pins. We launched it in 2017 and it is one of our best-selling products. ANAVI Infrared pHAT is available at our distributors around the world and you can order it to build a similar home automation solution.