Code Monkey home page Code Monkey logo

circuitpython-pi-pico-w-bmp180-influxdb's Introduction

A CircuitPython Pi Pico W BMP180 InfluxDB Example

A CircuitPython example using asyncio cooperative multitasking for the Raspberry Pi Pico W which sends data from a BMP180 sensor to an InfluxDB v2 server.

Requirements

  • Raspberry Pi Pico W running CircuitPython 8.2.x (tested on 8.2.6)
  • BMP180 sensor
  • InfluxDB v2 server with configured bucket and API key
  • The following CircuitPython libraries are used:
    • board
    • digitalio
    • wifi
    • socketpool
    • bmp180
    • adafruit_ntp
    • time
    • asyncio
    • supervisor
    • os
    • busio
    • adafruit_requests
    • ssl
    • usyslog

Notes

This example was developed using the asyncio cooperative multitasking method in order to allow several tasks to function independently and at different loop intervals. Basic UDP syslog functionality is incorporated as well for the purposes of being able to allow troubleshooting without having the serial cable connected. The syslog functionality can be enabled or disabled.

These tasks are:

  • Reading the BMP180 sensor
  • Connect to the WiFi
  • NTP time sync
  • Send data to InfluxDB

Loading the various settings at runtime is achieved by the settings.toml file method. The following are the settings:

ssid = "SSID_HERE"
psk = "PSK_HERE"
INFLUXDB_URL = "https://example.fqdn.com/api/v2/write"
INFLUXDB_ORG = "ORG"
INFLUXDB_BUCKET = "CircuitPythonTest"
INFLUXDB_TOKEN = "INFLUX_TOKEN_HERE"
SYSLOG_SERVER = "10.0.0.10"
SYSLOG_SERVER_ENABLED = "FALSE"
SYSLOG_PORT = 514

WiFi reconnection is also incorporated and the WiFi task automatically checks to determine if it the device is still connected and if not, attempts to reconnect to the specified network.

HTTP POST is used for getting the metrics to the InfluxDB v2 server.

Disclaimer

This example is probably unstable and full of bugs. Like everything else on the internet, run/use at your own risk.

circuitpython-pi-pico-w-bmp180-influxdb's People

Contributors

ageagainstthemachine avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.