I work on Adafruit IO, and I've had this mischievous plan for a while to adjust my WipperSnapper no-code sensor devices to poll more frequently than the 30s minimum that the web interface offers, like maybe as low as 5seconds to avoid burning my toast (having recently tried measuring the particle emissions again but found it too infrequent).
It's running on an Adafruit Feather ESP32 v2 with 8MB flash 2MB PSRAM plus w.FL connector and the external WiFi antenna, connected to a SEN5x breakout board using a StemmaQT cable, and the Sensirion SEN54 air quality sensor with it's weird locking JST-GHR 6pin cable. (Skip to the end to see the device in-situ)
So Saturday morning I was having a prod at the firmware (you can too as it's open source code) and watching the API calls in the network monitor to see where gets prodded when the user changes a sensor to read every 30s.
Here we can see the period being updated to 30seconds when I select that option in the Adafruit IO component dialog and click update component.
So the idea now is to recreate that message to update the time period for the sensor, but with a new value of our choosing.
📮Postman 📬📯
I've used postman for API testing for a while now, it allows me some quick and useful templating and storing collections with reusable "variables".
Since starting this job I've built a collection of requests that use some of the more interesting bits of the IO API, and for this example I've ended up copying the request payload from my google chrome Developer tools window (the network panel shown in the image above) into my Postman collection.
There I already have my authorisation key setup as an HTTP header (by following the adafruit IO API docs), and I'm modifying the time period in the payload to a lower value of 5 seconds then sending the HTTP PUT request.
You'll see the response from the API with the updated value:
Now as Postman is so useful (and free for minimal use - teams of 3), I've decided to include my collection here so you can easily import it into your own postman account.
I've created a new account called playground_example and included those details so you could immediately run one of the GET requests, but the key has been automatically reset due to publishing it online.
Please instead update the variables to use your own account immediately.
Sharing Accounts and giving out your key is a very bad idea, if that happens by accident you can regenerate a new key from the View Key dialog.
If your key is detected as published publicly online, then you'll receive an email saying it's been compromised and has been automatically regenerated. Something like this:
After importing the collection of requests in your Postman account, click on the collection name and goto the Variables tab of the collection window that opens.
Update your io_user and io_key variables (both the default and current_value entries).
After rebooting the device it worked!
The readings now come every 5seconds instead of every 30, as shown below in the serial monitor, and the adafruit IO feed page for the temperature sensor:
You can see the sensor component interface on the wippersnapper device page now shows a blank entry for temperature sensor poll period, but still shows the 30seconds poll period for all the other sensors sub components:
There's even more WipperSnapper pin information available from the Feeds API endpoint which I've had my eye on for a while... It's also possible to create and modify Dashboards via the API! Once I've got a bit more other stuff done I may revisit this topic.
Now I just need to do it to the particle sensor sub-components instead as that's how I'll be detecting the toast beginning to burn (and then switch off the toaster).
Then setup a quick Action to trigger the power off once a burning toast event is detected and voila...no more burnt toast!
The only downside of my current setup is that I'm using those TP-Link Tapo P110 power monitoring wifi switches which don't have a friendly API supporting webhooks. I either need to run a python script on a raspberry pi (that I use for netflix) which would monitor a feed using MQTT and then run a python+rust combo to interact with the Tapo plug, or alternatively pay IFTTT a monthly fee, or last option is to wire my toaster through a relay (I have a High Power Relay featherwing supporting 1200Watts and my toaster is 700w so it's not insane - ignoring inrush and resistive load issues which derate it to about half).
I should probably just be running home assistant at this point, then I could more easily interact with the Tapo devices. So far I've been happy enough integrating my Tapo and eWeLink devices over google, plus the free tier of IFTTT, only occasionally reaching into a web dashboard or mobile app. I have to admit I'm also running a pi in the greenhouse with NodeRED (diagram flow based programming) for the odd automation and test.
This page (Set your sensor polling frequency to anything - WipperSnapper + API "testing" Adafruit IO) was last updated on September 29, 2024.