B9 switches the MOSFET (digitalWrite),
A4 is the the presence sensor (analogRead of a radar module, cf. https://shop.weidmann-elektronik.de/index.php?page=product&info=8),
A0 is the 'darkness sensor' with a photo resistor.
TSensor is meant to be a universal threashold sensor, all the parameters basically control how the raw signal is prepared such that the threshold makes sense. Both sensors call into the tsw1 switch instance passing 1 or 0.
The system is self contained. The switch tsw1 additionally reports actions via HTTP, which seems to be of no relevance, I've checked it.
I'll look deeper into setWatch(...irq: true). It might well be overkill, but it would be fun to get it working!
After all, in the end, it might be not too hard, and it would be a nice 'backdoor' in case it's really needed (e.g. if I wanted to check the presence sensor every 50 ms). @allObjects: Fully agree. Not breaking the really great Espruino concept while beeing able to unleash the close to infinite speed of the great processor - that's the goal. It feels wrong to know that my little light switch would run perfectly if implemented in C. And my VIP customer - my wife - needs to be content ;)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The TCP connection is created and closed for each single request.
The main code is here, modules ar attached:
B9 switches the MOSFET (digitalWrite),
A4 is the the presence sensor (analogRead of a radar module, cf. https://shop.weidmann-elektronik.de/index.php?page=product&info=8),
A0 is the 'darkness sensor' with a photo resistor.
TSensor is meant to be a universal threashold sensor, all the parameters basically control how the raw signal is prepared such that the threshold makes sense. Both sensors call into the tsw1 switch instance passing 1 or 0.
The system is self contained. The switch tsw1 additionally reports actions via HTTP, which seems to be of no relevance, I've checked it.
I'll look deeper into setWatch(...irq: true). It might well be overkill, but it would be fun to get it working!
After all, in the end, it might be not too hard, and it would be a nice 'backdoor' in case it's really needed (e.g. if I wanted to check the presence sensor every 50 ms).
@allObjects: Fully agree. Not breaking the really great Espruino concept while beeing able to unleash the close to infinite speed of the great processor - that's the goal. It feels wrong to know that my little light switch would run perfectly if implemented in C. And my VIP customer - my wife - needs to be content ;)
2 Attachments