Recommended way to get/send data from sensor?
Posted: Fri Dec 21, 2018 9:01 pm
This is partly micropython related and partly just a general question about good practices since I'm new to both micropython (but not regular python) and microcontrollers and sensors... I've done past projects with Raspberry Pis, but those are basically full blown computers so working with them is different.
My project here to know when my washing machine finishes a cycle, both via an alert, and also being able to query the status from another device. For this I have an esp8266 board and a vibration sensor with digital output. I've mounted the vibration sensor on the back of the washing machine and connected to the esp8266, and have done enough playing around in the REPL to determine that it definitely can detect vibrations when the machine is running. So the hardware setup seems fine.
The goal is to have the device running a loop to detect extended periods of vibration, indicating the machine is running, or extended period of no vibration, indicating that the machine is stopped. At the transition between the two, it will send an alert.
The above seems straightforward with just doing things in a loop, but... I would also like it to possible to query or poll the device, maybe with an http API, to find out what the current state is: washing or stopped.
That seems to get more complicated: how do I have it listening for an incoming connection while also doing the washing machine state checking loop?
Also this goes back to the general question of what the best/recommended/standard way is to get information from a remote device like this? Is it customary to pull data from it like with an http API? or to have it send data to another service waiting on another device?
Thanks,
robo
My project here to know when my washing machine finishes a cycle, both via an alert, and also being able to query the status from another device. For this I have an esp8266 board and a vibration sensor with digital output. I've mounted the vibration sensor on the back of the washing machine and connected to the esp8266, and have done enough playing around in the REPL to determine that it definitely can detect vibrations when the machine is running. So the hardware setup seems fine.
The goal is to have the device running a loop to detect extended periods of vibration, indicating the machine is running, or extended period of no vibration, indicating that the machine is stopped. At the transition between the two, it will send an alert.
The above seems straightforward with just doing things in a loop, but... I would also like it to possible to query or poll the device, maybe with an http API, to find out what the current state is: washing or stopped.
That seems to get more complicated: how do I have it listening for an incoming connection while also doing the washing machine state checking loop?
Also this goes back to the general question of what the best/recommended/standard way is to get information from a remote device like this? Is it customary to pull data from it like with an http API? or to have it send data to another service waiting on another device?
Thanks,
robo