Skip to content

electronf99/BTPico2BME280

Repository files navigation

README.md

MicroPython BME280 Environment Sensor BLE Service for Raspberry Pi Pico

This project uses MicroPython on a Raspberry Pi Pico to advertise a BME280 Environment sensor BLE service. It includes logic to monitor BLE activity and automatically restart the BLE service if no activity is detected for 30 seconds. Instead of rebooting the device, the script reinitializes the BLE logic to maintain continuous operation.

It handles a lack of connections by restartin the service periodically. This ensures that if connection is closed the ble service will restart.

Setup Instructions

  1. Flash MicroPython firmware to your Raspberry Pi Pico.
  2. Connect to the Pico using Thonny or another MicroPython IDE.
  3. Upload and run getBTMac.py and record the MAC for use on the Linux code. (Or figure out how to get advertising name working and log a PR)
  4. Upload the BLE service script to the Pico as main.py.
  5. Upload PiicoDev_BME280.py and PiicoDev_Unified.py to the Pico

Usage

You can run the file manually however as this is main.py once powered on, the Pico will begin advertising a BLE service named 'PicoBLE'. If a central device connects, the connection is tracked and activity is monitored. If no connections or BLE activity are detected for 30 seconds, the BLE service is restarted automatically.

Demo

Use the LinuxClientDemo.py from the repo. You will need the BT Mac because I couldn't get adevertising name working. It should return the environmental values.

Customization Tips

  • • Modify the _RESTART_TIMEOUT_MS constant to change the inactivity timeout duration.
  • • Change the advertised name by editing the name variable in _start_advertising().

About

Pico2 BlueTooth BME280 Device

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages