How to Make a Raspberry Pi Pico Wi-Fi capable?

INTRODUCTION

Raspberry Pi Pico is a microcontroller board designed by the Raspberry Pi Foundation. It features the RP2040 microcontroller chip, which contains two ARM Cortex-M0+ cores clocked at 133 MHz, 264KB of RAM, and 2MB of onboard Flash memory for code storage. The Pico also includes 26 GPIO pins, which can be used for a variety of purposes such as controlling sensors, motors, and other external devices. Additionally, the board supports various interfaces such as I2C, SPI, and UART, making it easy to connect to other devices. The Pico is a great option for hobbyists and professionals alike who are looking for a powerful, yet affordable microcontroller board.

While this microcontroller is versatile and can be used in a variety of projects, it does not have a built-in Wi-Fi chip. As a result, users often choose the Raspberry Pi Pico W or ESP series instead.

THE PLAN

In this post, we will use ESP01 and AT commands to connect the Raspberry Pi Pico to our Wi-Fi. We will then start a simple web server. Finally, to make it more useful, we will use a BME680 sensor to monitor the room temperature and humidity in a web browser (such as Google Chrome).

To get started, we need to make sure that the ESP01 module is properly connected to the Raspberry Pi Pico. Once the connection is established, we will use AT commands to configure the ESP01 module to connect to our Wi-Fi network.

After that, we will start a simple web server on the Raspberry Pi Pico by using the MicroPython `http.server` module. This will allow us to serve a web page that displays the temperature and humidity data from the BME680 sensor.

To read temperature and humidity data from the BME680 sensor, we will use the bme680 library in MicroPython (can be downloaded from SemFio GitHub account and link will be provided at the end of this post). This library provides an easy-to-use interface for reading data from the sensor. Once we have the data, we will use it to update the web page that is being served by the Raspberry Pi Pico.

Finally, we will use a web browser (such as Google Chrome) to view the web page and monitor the temperature and humidity in the room.

By the end of this tutorial, you will have a basic understanding of how to connect the Raspberry Pi Pico to the internet, how to serve a web page, and how to read data from a sensor.

TOOLS

AT COMMANDS

AT commands are a series of commands used to control and configure modems and other communication devices. They are commonly used in cellular communication modules to control the modem and establish a communication link with a network.

UART

UART (Universal Asynchronous Receiver/Transmitter) is a type of serial communication interface that allows for asynchronous communication between two electronic devices over short distances. It is commonly used in microcontrollers like the Raspberry Pi Pico to communicate with other devices such as sensors or other microcontrollers. The UART interface typically uses two pins: TX (transmit) and RX (receive). The transmitting device sends data to the receiving device on the TX pin, while the receiving device receives data on the RX pin.

In the context of your project, you can use the UART interface to communicate between the Raspberry Pi Pico and the BME680 sensor. The BME680 can send temperature and humidity data to the Pico over the UART interface, allowing you to use this data in your project.

ESP01

ESP01 is a low-cost Wi-Fi module that is based on the ESP8266 chip. It can be used to add Wi-Fi functionality to a wide range of projects, including Internet of Things (IoT) devices and home automation systems.

BME680

BME680 is a 4-in-1 sensor that can detect temperature, humidity, gas, pressure, and volatile organic compounds (VOCs). It is commonly used in air quality monitoring applications, as well as in indoor air quality monitoring systems. The BME680 is designed with low power consumption in mind and can be used in battery-powered devices. It can communicate with a microcontroller via I2C or SPI interfaces.

SETUP

Before looking at the code, let’s look at the hardware.

To begin the project, the first step is to connect all elements together following the diagram below:

SCRIPT EXPLANATIONS

In order to illustrate the fact that the Raspberry Pico is connecting to the Wi-Fi, we have built a sample script.

The script will perform the following tasks:

  1. BME680 communicates with the Raspberry Pi Pico using an I2C connection through the SDA and SCL pins.
  2. Although gas, pressure, temperature, and humidity are measured, only temperature and humidity are chosen for simplicity’s sake.
  3. An AT command is used to set up a Wi-Fi connection, and UART is used to create a web server and send BME680 parameters.
  4. The LED light on the board is only for troubleshooting. It blinks every time there is a data query.
  5. When the [main.py](http://main.py/) script runs, it shows the obtained IP address.
  6. Once “WebServer is About to Start…” appears on Thonny’s shell, open a browser and type the IP address.

RESSOURCES

The following link includes the mandatory library for bme680, a sample script for measuring room elements with the sensor, and the main script.

Source: https://github.com/semfionetworks/RaspberryPiPico_Wi-Fi

Note: Don’t forget to replace your SSID and password in line 61 of main.py

Post by Amin Sedighfar

guest
0 Comments
Inline Feedbacks
View all comments