Pico Environment Sensor

From Waveshare Wiki
Jump to: navigation, search
Pico Environment Sensor
Pico Environment Sensor





The Pico-Environment-Sensor gives Raspberry Pi Pico the ability to collect environmental data like temperature & humidity, air pressure, ambient light intensity, VOC, UV rays, etc. It can also be used to build a robot that can detect motion and orientation.


  • Standard Raspberry Pi Pico header, supports Raspberry Pi Pico series.
  • Onboard TSL25911FN digital ambient light sensor, for measuring IR and visible light.
  • Onboard BME280 sensor, for measuring temperature, humidity, and air pressure.
  • Onboard ICM20948 motion sensor, accelerometer, gyroscope, and magnetometer.
  • Onboard LTR390-UV-1 sensor, for measuring UV rays.
  • Onboard SGP40 sensor, for detecting ambient VOC.
  • I2C bus allows retrieving data by just using two wires.


I2C address 0 x 29
Effective range 0~88000 Lux
I2C address 0 x 76
Temperature detection -40 ~ 85℃ (0.01℃ resolution, ±1℃ accuracy)
Humidity detection 0~100%RH (0.008%RH resolution, ±3%RH accuracy, 1s response time, ≤2%RH delay)
Air presure detection 300~1100hPa (0.18Pa resolution, ±1hPa accuracy)
I2C address 0 x 68
Accelerometer resolution 16-bit
Accelerometer range (configurable) 2, ±4, ±8, ±16g
Gyroscope resolution 16-bit
Gyroscope range (configurable) ±250, ±500, ±1000, ±2000°/sec
Magnetometer resolution 16-bit
Magnetometer range ±4900µT
I2C address 0 x 53
Response wavelength 280nm - 430nm
SGP40 VOC Sensor
I2C address 0 x 59
Measuring range 0 ~ 1,000 ppm ethanol equivalent
Limit condition < 0.05 ppm ethanol equivalent OR < 10 % preset concentration point (the larger one should prevail)
Response time < 10 s (tau 63 %)
Start time < 60 s
On-chip humidity compensation support

How to Connect

As shown below: directly connect to the GPIO headers of the Jetson Nano. Pico-Environment-Sensor-spec09.jpg

Onboard Resource



Ambient Light Sensor

The TSL2591 is an optical intensity digitizer based on IIC bus communication. The sensor combines a broadband photodiode (visible and IR light) and an IR-responsive photodiode on a single CMOS integrated circuit capable of providing near-light adaptive response over an effective 16-bit dynamic range (16-bit resolution). Two integral ADCs convert the photodiode current to a digital output representing the irradiance measured on each channel. This digital output can be fed to a microprocessor, which uses an empirical formula to derive an illuminance (ambient light level) in lux to approximate the human eye response.
The sensor address is 0X29.
The following points need to be noted when using this sensor:

  1. The default is turned on the interrupt, if you do not need to comment out the corresponding code;
  2. The default range of the demo is limited, if the light suddenly changes a lot, please increase the range;
  3. There is a difference with the light intensity reader on the market, those are added to the lens.

Temperature, Humidity, and Ari Pressure Sensor

BME280 is for temperature, humidity, and air pressure sensors with the characteristics of low power consumption, high accuracy, and stability. It is suitable for environmental monitoring, weather prediction, altitude monitoring, and Internet of Things application scenarios.
Sensor address: 0 x 76.
Measuring range:
Temperature range: 40~85°C (resolution is 0.01°C, error ±1°C).
Humidity range: 0~100%RH (resolution is 0.008%RH, error ±3% RH)
Pressure range: 300~1100 hPa (resolution is 0.18Pa, error ±1 hPa)

  1. The measuring range should not exceed the measuring range, or it may be inaccurate.
  2. The pressure measured is atmospheric pressure, which normally fluctuates around the standard atmospheric pressure (1.013x 10^5 = 1013hPa).
  3. The measured temperature may be biased to the temperature above the jetson nano. If possible, fans can be added to avoid this situation during use.
  4. The higher the air temperature is, the lower the air pressure is. Because the higher the air temperature is, the air near the ground will expand and rise due to heat, resulting in a decrease in air density and air pressure. Instead, the pressure rises.
  5. Atmospheric pressure decreases with altitude, but there is no proportional relationship. The higher the altitude, the slower the decrease.
  6. The relationship between atmospheric pressure and altitude is as follows: as altitude increases, atmospheric pressure decreases. Theoretically, within the range of 3000M, atmospheric pressure decreases by 1mmHg, or about 133Pa, for every 12M increase.

9-axis Sensor

MPU9250 is a multi-chip module with 9-axis motion tracking, 3-axis acceleration, 3-axis gyroscope, and 3-axis magnetometer, and a built-in digital motion processing engine to reduce complex fusion algorithm data and reduce the load on the processor.
Sensor address: 0x68
Accelerometer characteristics:

  • Resolution: 16-bit
  • Measurement range (Optional): ±2, ±4, ±8, ±16g
  • Operating current: 450uA

Gyroscope characteristics:

  • Resolution: 16 bit
  • Measurement range (Optional): ±250, ±500, ±1000, ±2000°/sec
  • Operating current: 3.2mA

Magnetometer characteristics:

  • Resolution: 16 bit
  • Measurement range: ±4900µT
  • Operating current: 280uA


  1. Acceleration (LSB, convert to g)
  2. Gyroscope angle velocity (LSB, convert to °/second)
  3. Magnetic electronic compass angle (°)

UV Sensor

The LTR390-UV-01 is a multifunctional optical measurement module with a focus on measuring ultraviolet light. The sensor supports the measured ambient light intensity.
The sensor address is: 0X53
The use of this sensor requires attention to the following points.

  1. The principle of operation is actually a pair of diodes, one sensitive to normal light and one sensitive to ultraviolet light, and the result is obtained by the calculation of both.
  2. The value readout is the original ADC data, if you want to calibrate can refer to the manual formula and combine it with the actual light intensity value, UV for correction.
  3. The data can be set differently by gain, which needs to be set according to the actual application environment.
  4. The manual does not specify the detection range, the actual measurement in the sun has a better effect or the best effect with a UV pen in 50cm thought.

VOC Sensor

SGP40 Sensirion's new digital VOC (Volatile Organic Compounds) sensor, easily integrated into air handling devices and air quality monitors, features a temperature-controlled miniature heating plate and a humidity-compensated indoor air quality signal that provides a complete sensor system on a single chip.
The sensor address is: 0X59
The following points need to be noted when using this sensor.

  1. The default Python demo outputs the VOC-processed algorithm value.
  2. The sensor work needs to be stabilized within 1 minute, as the internal is slowly heating up.
  3. Can be fed back to the SGP40 by measuring the current temperature and humidity so that the accuracy of the output will be higher.
  4. The sensor measurement range of 0 to 1,000 ppm ethanol equivalent.


C/C++ Development Environment Installation


  • Click here to download the demo, unzip it and enter the folder of Pico-Environment-Sensor-code\c.
  • After entering Pico-Environment-Sensor-code\c, you can open the project with vs code.

1.28inch Touch LCD pico.jpg

  • Choose the Compiler.

1.28inch Touch LCD pico2.jpg

  • Start to compile.

1.28inch Touch LCD pico3.jpg

  • Finish.

1.28inch Touch LCD pico4.jpg

  • Copy the Pico_Environment_Sensor.uf2 in build to Pico, and then it can automatically run the demo.

1.28inch Touch LCD pico5.jpg

In Raspberry Pi

  • Open the Raspberry Pi and run:
sudo apt-get install p7zip-full
cd ~
sudo wget https://files.waveshare.com/upload/f/f9/Pico-Environment-Sensor-code.7z
7zr x Pico-Environment-Sensor-code.7z -r -o./Pico-Environment-Sensor-code
cd ~/Pico-Environment-Sensor-code
cd c/build/

Demo Use

  • Please operate the following tutorial on Raspberry Pi, due to the multi-platform and portable nature of CMake, it can also be compiled successfully on a PC, but the operation is slightly different and requires your own judgment.
  • To perform the compilation, make sure that in the c directory:
cd ~/Pico-Environment-Sensor-code/c/

Create and enter the build directory, and add the SDK: ../../pico-sdk is the directory of your SDK. There is a build in our sample application, just enter it directly.

cd build
export PICO_SDK_PATH=../../pico-sdk
(Note: Be sure to write the right path to your own SDK)

Execute cmake to automatically generate the Makefile file:

cmake ..

Execute make to generate the executable file, you may wait for a long time as it is the first time to be compiled.

make -j9

After compiling, the uf2 file will be generated. Press the button on the Pico board, Pico can connect to the USB port of the Raspberry Pi via a Micro USB cable, and then release the buttons. After connecting, Raspberry Pi will automatically identify a movable disk (RPI-RP2), and copy main.uf2 in the build file to the recognizable movable disk (RPI-RP2).

cp Pico_Environment_Sensor.uf2 /media/pi/RPI-RP2/



  1. Download the demo.
  2. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer via the Micro USB cable and release the button when the computer recognizes a removable disk (RPI-RP2).
  3. Copy the pico_micropython_20221125.uf2 file from the UF2 directory to the recognized removable disk (RPI-RP2).
  4. Open the Thonny IDE (note: use the latest version of Thonny, otherwise there is no support package for Pico, the current latest version for Windows is v3.3.3).
  5. Click Tools -> Settings -> Interpreter, and select Pico and the corresponding port as shown in the picture.


6. After connecting to Pico, save all the downloaded code to Pico, then run test.py, Thonny will print the sensor data as follows:
(1) Find the path of your downloaded program in the Thonny IDE.
(2) Upload all the Python to Pico.
(3) After uploading, open test.py for module testing.
(4) No save and the output value is normal, then the function is OK.

Raspberry Pi

  • Demo download:
sudo apt-get install p7zip-full
cd ~
sudo wget  https://files.waveshare.com/upload/f/f9/Pico-Environment-Sensor-code.7z
7z x Pico-Environment-Sensor-code.7z -o./Pico-Environment-Sensor-code
cd ~/Pico-Environment-Sensor-code

1. The process of flashing the firmware is the same as on Windows, you can choose to copy the pico_micropython_20210121.uf2 file into pico on your PC or Raspberry Pi.
2. Open the Thonny IDE in Raspberry Pi Mountain (click Raspberry logo -> Programming -> Thonny Python IDE), you can check the version information in Help -> About Thonny.
To make sure your version has the Pico support package, also you can click on Tools -> Options... -> Interpreter to select MicroPico. -> Interpreter to select MicroPython (Raspberry Pi Pico and ttyACM0 port).
As shown in the image:
If your current Thonny version has no Pico support package, you should enter the following commands to update Thonny IDE:

sudo apt upgrade thonny

3. Click File -> Open... -> test.py, and run the script.



Demo Codes

Development Software

Pico Quick Start

Download Firmware

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Video Tutorial

  • Pico Tutorial I - Basic Introduction

  • Pico Tutorial II - GPIO

  • Pico Tutorial III - PWM

  • Pico Tutorial IV - ADC

  • Pico Tutorial V - UART

  • Pico Tutorial VI - To be continued...

MicroPython Series

C/C++ Series

Arduino IDE Series

Install Arduino IDE

  1. Download the Arduino IDE installation package from Arduino website.
    RoArm-M1 Tutorial II01.jpg
  2. Just click on "JUST DOWNLOAD".
    Arduino IDE Pico.png
  3. Click to install after downloading.
    RoArm-M1 Tutorial II02.gif
  4. Note: You will be prompted to install the driver during the installation process, we can click Install.

Install Arduino-Pico Core on Arduino IDE

  1. Open Arduino IDE, click the File on the left corner and choose "Preferences".
    RoArm-M1 Tutorial04.jpg
  2. Add the following link in the additional development board manager URL, then click OK.

    RoArm-M1 Tutorial II05.jpg
    Note: If you already have the ESP8266 board URL, you can separate the URLs with commas like this:

  3. Click on Tools -> Dev Board -> Dev Board Manager -> Search for pico, it shows installed since my computer has already installed it.
    Pico Get Start 05.png
    Pico Get Start 06.png

Upload Demo At the First Time

  1. Press and hold the BOOTSET button on the Pico board, connect the Pico to the USB port of the computer via the Micro USB cable, and release the button when the computer recognizes a removable hard drive (RPI-RP2).
    Pico Get Start.gif
  2. Download the demo, open arduino\PWM\D1-LED path under the D1-LED.ino.
  3. Click Tools -> Port, remember the existing COM, do not need to click this COM (different computers show different COM, remember the existing COM on your computer).
    UGV1 doenload02EN.png
  4. Connect the driver board to the computer with a USB cable, then click Tools -> Ports, select uf2 Board for the first connection, and after the upload is complete, connecting again will result in an additional COM port.
    UGV1 doenload03EN.png
  5. Click Tool -> Dev Board -> Raspberry Pi Pico/RP2040 -> Raspberry Pi Pico.
    Pico Get Start02.png
  6. After setting, click the right arrow to upload.
    Pico Get Start03.png
    • If you encounter problems during the period, you need to reinstall or replace the Arduino IDE version, uninstall the Arduino IDE needs to be uninstalled cleanly, after uninstalling the software you need to manually delete all the contents of the folder C:\Users\[name]\AppData\Local\Arduino15 (you need to show the hidden files in order to see it) and then reinstall.

Pico-W Series Tutorial (To be continued...)

Open Source Demo


Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 AM GMT+8 (Monday to Friday)