MicroPython on Raspberry Pi Pico with Thonny IDE

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.

Useful links:

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).

You may also like

ANAVI Gardening uHAT is now OSHWA certified

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.

You may also like

ANAVI Gardening uHAT

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.

We hope you’ll jump in and help us bring this entirely open source gardening project to life by supporting our new crowdfunding campaign at Crowd Supply.

You may also like

Add Capacitive Soil Moisture Sensors to Raspberry Pi

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

You may also like

Raspberry Pi & Microchip MCP3002 Analog-to-digital Converter (ADC)

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


You may also like

“Spiderman” Raspberry Pi with ANAVI Infrared pHAT

Jesús Figueres, a data scientist interested in artificial intelligence (AI), shared in Twitter his setup of Raspberry Pi and ANAVI Infrared pHAT. It is living upside down on his lab’s ceiling so he calls it “Spiderman”. No doubt this is a suitable name in this case!

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

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.

You may also like

Unifying Remote Controls with Infrared pHAT

Recently Michel submitted a very interesting Crowd Supply Field report about his awesome project with ANAVI Infrared pHAT. He used a Raspberry Pi Zero W and ANAVI Infrared pHAT to consolidate all the remote controls (TV, DVD, cable box, etc.) in his household to a single interface available on a tablet or smartphone.

Web interface for controlling remote controls over the web with Raspberry Pi, ANAVI Infrared pHAT and LIRC

Michel runs a local Apache2 web server on the Raspberry Pi Zero W and the Infrared pHAT can record and play back the infrared signals from any brand of remote control using the popular open source software Linux Infrared Remote Control (LIRC). He shared details in Crowd Supply and GitHub.

Furthermore Michel crafted a fantastic wooden box and shared with us a couple of photos!

Wooden box for Raspberry Pi Zero W and ANAVI Infrared pHAT
Inside the wooden box the two infrared LEDs have been carefully extended with appropriate wires

You may also like

Install Jitsi Meet on Raspberry Pi

This step by step tutorial explains how to install and configure the free and open source video conference software Jitsi Meet on Raspberry Pi with 64-bit Ubuntu Server 20.04. Although the Jitsi Meet installation is simple, the network configuration is not.

This tutorial is only for 64-bit Raspberry Pi models and versions, for example Raspberry Pi 4 or 3. It is recommended to use Raspberry Pi 4 with 4GB or more. Please note that Raspberry Pi 0, 2 and other older versions are 32-bit and this tutorial is NOT suitable for them.

Setup Network

To successfully run self-hosted Jitsi Meet on your Raspberry Pi at home and allow your friends and family to access it from anywhere you need to make several network configurations.

The network setup depends on your WiFi router and although the steps in general are the same they vary depending on the router model and version:

  • Dynamic DNS (DDNS) – the public IP of your WiFi router is provided by your ISP (Internet Service Provider) and in general may change over time. To avoid service downtime and hassle to remember IP address, it is highly recommended to setup DDNS. Some ASUS routers, like RT-AC68U, have this advanced service built-in. Alternatively you can use one of the many free or low-cost DDNS services.
  • SSL (Secure Sockets Layer) certificate – for secure communication over HTTPS. It is highly recommended to get a free certificate from the automated and open certificate authority Let’s Encrypt. You can do this through your WiFi router (if it supports it), manually or during the installation of Jitsi Meet.
  • Port Forwarding – two ports must be forwarded from the Raspberry Pi on which Jitsi Meet is running to the Internet through the configurations of the WiFi router. By default these ports are: 443/TCP for the HTTPS server and 10000/UDP for the video bridge of Jitsi Meet.

Install Jitsi Meet

Download and add Jitsi GPG key to the list of trusted keys. Once added you can remove the downloaded file.

wget https://download.jitsi.org/jitsi-key.gpg.key
sudo apt-key add jitsi-key.gpg.key
rm jitsi-key.gpg.key

Create Jitsi repository for downloading and installing appropriate packages:

echo "deb https://download.jitsi.org stable/" | sudo tee -a /etc/apt/sources.list.d/jitsi-stable.list

Obtain the Jitsi repository and after that install package jitsi-meet:

sudo apt update
sudo apt install jitsi-meet

During the installation jitsi-meet will ask you to either use your own SSL certificate or to create one for you.

You may also like

Getting Started with the open source JavaScript Internet of Things platform ioBroker

ioBroker is an open source Internet of Things platform written in JavaScript and using Node.js for the back-end. It is perfect to run on single board computers such as Raspberry Pi. The project started in 2014. The source code is hosted in GitHub and the core is available under MIT license. The creators and maintainers of ioBroker are from Germany and the project is very popular among the German open source community interested in home automation.

In this article you will learn how to get started with ioBroker by installing it on a Raspberry Pi and after that how to measure temperature and humidity from the built-in DHT22 sensor on ANAVI Thermometer through the machine-to-machine protocol MQTT.

ioBroker Installation Guide

Step by step video tutorial for installing ioBroker on Raspberry Pi

Only two steps are required to install ioBroker on GNU/Linux distributions, including on a Raspberry Pi with Raspbian:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sL https://iobroker.net/install.sh | bash -

After successfully installing ioBroker, open the web interface and complete the initial setup as explained in the video.

Monitoring Temperature and Humidity from DHT22 in ioBroker via MQTT

Integrating ANAVI Thermometer with DHT22 temperature and humidity sensor in ioBroker

ANAVI Thermometer is an open source hardware, Wi-Fi development board for measuring temperature that’s powered by an ESP8266 processor. It comes with a built-in DHT22/AM2302 temperature and humidity sensor and has slots for a mini OLED display, waterproof DS18B20 temperature sensor, and empty slots for up to three additional I2C sensor modules.  Out of the box, the open source firmware of ANAVI Thermometer, works with Home Assistant specification for automatic discovery and MQTT messages with JSON payload.

Although ioBroker is an alternative open source IoT platform, through an adapter it supports the Home Assistant specification. The process for using ANAVI Thermometer in ioBroker is straight-forward thanks to the adapters MQTT Client/Broker and HASS-MQTT.

Adapter MQTT Client/Broker can be configured either as MQTT broker or as a client mode and use an external broker. In the particular demonstration in the video the instance of ioBroker adapter MQTT Client/Broker has been configured as a broker, without username/password and with disabled publish check-boxes from the MQTT Settings tab.

Adapter HASS-MQTT is required to support the Home Assistant MQTT specification. It have to be installed separately and bound to the instance of adapter MQTT Client/Broker as shown in the video. Get the HASS-MQTT adapter from: https://github.com/smarthomefans/ioBroker.hass-mqtt

ANAVI Themometer reporting temperature and humidity to the open source IoT JavaScript platform ioBroker

After turning on the instances of both adapters in Home Assistant, ANAVI Thermometer must be configured to connect to the same MQTT broker. After that ANAVI Thermometer will be automatically detected and the data from DHT22 as well as from any other attached supported sensors will be automatically reported to ioBroker. You just need to configure how to display it in your preferred graphical user interface (ioBroker offers several of them). In the video I used the ioBroker visualisation adapter which requires activation through an unique key. The activation requires registration with a email and is not shown in the video. Adapter visualisation if free for personal use. The other adapters, MQTT Client/Broker and HASS-MQTT are free and open source without any limitations.

You may also like

ANAVI Smiley Add-on Board for Raspberry Pi

ANAVI Smiley is a simple open source hardware add-on board for Raspberry Pi. It is compatible with any Raspberry Pi model or version. ANAVI Smiley has educational purposes: it is useful for learning how to solder and how to program. The simplicity of the board makes the kit appropriate for beginner. Example application written in Python shows how to use it.

Closer look at ANAVI Smiley after soldering the kit

ANAVI Smiley combines open source hardware with free and open source software. It has been certified by the Open Source Hardware Association under UID BG000061. ANAVI Smiley is available as a soldering kit with through-hole components:

  • Printed Circuit Board (PCB)
  • 2 LEDs
  • 2 resistors
  • Tactile button
  • Female connector
ANAVI Smiley soldering kit with all components

The color of the LEDs may vary. The primary kit includes with one green and another red LED, but there is also a kit with 2 yellow LEDs.

ANAVI Smiley with red and green LED as well another unit with 2 yellow LEDs

Have a look at the video for the exact steps how to solder ANAVI Smiley and to use it with Raspberry Pi.

A photo of ANAVI Smiley a moment after the kit has been assembled.

The short leg of the LED must go to ground (GND), aka the hole marked with a square on the printed circuit board. It is recommended to solder 4-pin connector on the opposite side, as shown on the picture. This way ANAVI Smiley will fit better on the 40-pin header of Raspberry Pi.

Python3 script to use ANAVI Smiley on a Raspberry Pi is available at GitHub. It relies on gpiozero to control the LEDs and to read the state of the button. Gpiozero is a simple and convenient Python interface to GPIO devices with Raspberry Pi, started by Ben Nuttall and Dave Jones.

Please note that SW1 button on the PCB doesn’t have a resistor, therefore your application must use the internal pull-up resistor present on each Raspberry Pi GPIO, for example with gpiozero in Python and pin 26:

btn = Button(26, pull_up = True, bounce_time=0.1)
ANAVI Smiley PCB in KiCad

ANAVI Smiley has been designed with the free and open source software tool KiCad. The whole KiCad project is also in GitHub. The two layer printed circuit board is made in Plovdiv, Bulgaria.

You may also like