Create menu with buttons to tap when motion detected

Ah I see - i interpreted this part

to mean that your whole code hangs for minutes at a time - but I think you were referring to the actual MQTT transaction round-trip. Which is pretty unusual! MQTT ought to be near-instant.

It’s worth a try! I’m not sure how the adafruit library uses the QOS settings - i thought they were more a call-response type of behaviour to guarantee QOS. If the initial publish takes very long to complete then it may not make a difference.

Let us know how you go :slight_smile:

Oh yes, my mistake - I should’ve explained further. I’ve watched my mosquitto MQTT logs in these instances of delays, and can confirm it doesn’t leave the unit for X minutes, and by the time the log shows the MQTT command come through, the action (ie lamp on/off) has just completed. Also the unit screen stays on sometimes for a few minutes during these delays (ie. doesn’t turn off after 15 seconds of not tapping), which suggests to me the MQTT command hasn’t left the unit yet or is still processing it. It does seem odd that such a simple program takes so long… wifi remains at around -45 to -55dBm and still seeing same delays when I’m sitting right under the access point too, and I’ve just used 9 alpha firmware after updating some libraries which I thought also could help but no luck. I’ll try the QoS level 1 or 2 and advise!

Hi @Tom252062
May I clarify that this line below is where the program is hanging?
client.publish(button_message[touched], data)

Hey @Pixmusix yes, I’m certain that’s where its hanging. The button status doesn’t even change (ie show as ‘pressed in’) until the MQTT command goes. So sometimes I’ll tap a button, it wont change to pressed in, and then say 2 minutes later it’ll ‘press in’ then the MQTT message goes, and screen turns off 15 secs from that point.

I was reading these two thread below.

I think something to try is building the “Fixes” branch of the repo.
It’s 4 commits ahead of master.

2 Likes

Thank you! I’ll look into this and let you know how I go

1 Like

Hi all just to round this out - it works 95% of the time. I think its my wifi which isnt; awesome. I suspect

I am looking at a way to install openhasp on the titano (somehow) in place of this, as it seems more stable, but the code above should work for others!

2 Likes