Skip to content

mtiessen1175/pico-scd4x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pico-scd4x

Raspberry Pi Pico W and SCD4X sensor

Connecting a SCD4X sensor (temperature, humidity, CO2)* to a Rpi Pico 2W and publish the measurements to an MQTT broker. I used the MicroPython_SCD4X driver from peter-l5, which is based on the adafruit_scd4x.py.

Steps:

  1. Download the .uf2 firmware from MicroPython
  2. Connect the Pico via USB and drag .uf2 to RPI-RP2 drive (flashes the firmware and reboots the Pico)
  3. Access Pico via CLI (or use an IDE like Thonny).
    • On Linux OS: apt install picocom
    • picocom /dev/ttyACM0 -b 115200 to start the MicroPython REPL on the Pico
    • Check if install works:
      >>> import machine
      >>> led = machine.Pin("LED", machine.Pin.OUT)
      >>> led.toggle()
  4. Upload the MicroPython MQTT client library simple.py and robust.py
    • via Thonny:
      1. Open the Files pane (View → Files).
      2. Navigate to the Pico device.
      3. Right-click → New Directory → name it: "umqtt"
      4. Upload simple.py and robust.py into that folder
  5. Add a configuration file (config.py) and create variables for Wifi and MQTT connections:
    • wifi_ssid = local WIFI name
    • wifi_password = local WIFI password
    • mqtt_server = the server address running the MQTT broker
    • mqtt_topic = the MQTT topic to publish the sensor readings to
    • mqtt_username = MQTT user (optional, depending on MQTT setup)
    • mqtt_password = MQTT password -"-
  6. Connect the sensor to the Pico and upload the main.py to the device in order to read/publish the sensor data (via MQTT)

Useful resources:

Additional helper scripts:

* I used an SCD41 sensor from SEED-Studio

About

Raspberry Pi Pico W and SCD4X sensor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages