This project is a DeviceScript library that uses Adafruit.io REST APIs to upload data.
Requires a microcontroller with network connectivity such as the Adafruit QT Py C3.
Install this project to your DeviceScript project
npm install --save pelikhan/devicescript-adafruit-io#v...
where v...
is the current release
The APIs will read a default username, feed and key from the settings.
# env.defaults
IO_USERNAME=user
IO_FEED=feed
# env.local
IO_KEY=...
This extension uses the following settings:
- IO_KEY: (required) access key
- IO_FEED: feed name
- IO_USERNAME: io.adafruit.com user name
- IO_LAT: (optional) latitude (as a number)
- IO_LON: (optional) longitude (as a number)
- IO_ELE: (optional) elevation (as a number)
The createData function will upload a value to the Adafruit.io feed using the REST APIs and return the HTTP status code.
import { createData } from "devicescript-adafruit-io"
const value = await temperature.reading.read()
const status = await createData(value)
console.log({ status })
This API connects to the MQTT broker and let's you publish sensor data through the feed topics.
import {
publishData,
startAdafruitIOMQTTClient,
} from "devicescript-adafruit-io"
const client = await startAdafruitIOMQTTClient()
await publishData(client, 456)