Hi all, am developing a Wipy multisensor, I want to have a PIR sensor running on a background thread pinging an MQTT message when it registers motion, whilst performing other periodic sensor readings on the main thread (or vice-versa I suppose). Does anyone have a good example of this?
This post is deleted!
no, your link is for pyboard
here you have example from docs
from machine import Pin def pin_handler(arg): print("got an interrupt in pin %s" % (arg.id())) p_in = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP) p_in.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler)
for pycom doc is here
@bucknall Hi Alex, thanks for the advice, you are referring to https://docs.micropython.org/en/latest/pyboard/reference/isr_rules.html#isr-rules
? If you know of any examples that could get me started that would be a great help, as this appears quite advanced.
Would using an interrupt on the PIR sensor pin be a potential solution? You could then run your main code loop and have your MQTT message sent any time that the interrupt is triggered?