Puck js, how to send MQTT message with button pressed? #2453
Replies: 20 comments
-
Posted at 2017-01-24 by @gfwilliams Hi, The simplest way to do it would be to advertise a 'button press count' variable. If you upload the following:
And then disconnect from Puck.js, whenever you press the button you'll see a service UUID '0xFFFF' broadcast that has a number in it. Each time the number changes, an MQTT event will get fired, and you can hook on to that in Node-red (by default you'll still get an event fired by EspruinoHub every 60 seconds even it it hasn't changed, but there's a node-red block that'll filter that out by only passing a message when the value changes). The nice thing about doing it this way is there's no connection, and also if you walk out of range, press the button and then walk back in range, the event will still fire when Puck.js gets back in range |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-24 by Grzegorz Hello
Any clue what is wrong please? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by @gfwilliams Have you updated the EspruinoHub code from GitHub recently. I have seen this problem before... @dklinkman do you remember what the cause was? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by Grzegorz Hi
IT looks like the EspruinoHub is not installed properly. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by dklinkman @gfwilliams I don't think I have seen that particular error before. But from the output it's odd that the service appears to have been translated to its UUID format but the characteristic has not. Maybe there is a subtle problem with the mqtt publish and/or interpretation by the hub. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by @gfwilliams @dklinkman thanks - that's a good spot! I don't know why it would fail though - looking at the code, it's identical to get the characteristic and service, so the only thing I can think is perhaps there was a character at the end of the topic - a stray space maybe? (and yes - I just looked at the message that's posted, and @grzegorz it's because you put @grzegorz I'm not sure how to help with this most recent problem. You had this working before, so presumably you have more of a chance of working out what you did then than I do now :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by Grzegorz I have just mended mqtt subscription to "/ble/write/c9:a2:6b:fd:3f:9d/nus/nus_tx" I can receive the advertise and rssi thou. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by @gfwilliams Ok, thanks for letting me know. @eric I know here you were having |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by dklinkman I found this in one of my old posts. This is the specific syntax I had to use to get my /ble/write to work properly from the linux command line. It has to do with how the linefeed character gets passed through if I recall. But I don't know if this relates at all to the problem @grzegorz is having.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-25 by @gfwilliams Ahh I just Googled the message and found this:
So it looks like it's something funny with your Bluetooth dongle I've just updated EspruinoHub - please could you |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-26 by Grzegorz No luck, still the same issue. I have got Plugable BLE adapter |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-26 by dklinkman I use the Plugable USB dongle on my Windows 7 Pro machine to talk to the Puck with good results. On my RPi2 hub I used this one from ameriDroid (via Amazon) with good results prior to my switching to the RPi3. The RPi3 works well also. https://www.amazon.com/gp/product/B01LEX8Z6W/ref=oh_aui_search_detailpage?ie=UTF8&psc=1 I got that one since I really wanted to use my Odroid XU4 as my Espruino Hub. And that is the official BT/BLE dongle for it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-02-01 by Grzegorz I could not find the ameriDroid on UK market, I have bought an other one different BT dongle and the issue persist. Could be the error platform depended? I don't use R pi. Is the error caused definitely by BT dongle? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-02-02 by dklinkman No experience with Olimex A20 unfortunately. I did easily get the hub to work on an Odroid, however, so I know it can work on other platforms. Though once I tried it on the RPi 3 I just left it there. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-25 by werty1st I cant send a write command to the puck:
I only found this information: I had a look into the EspruinoHub code and i saw that the scanning is interruptet if a write message needs to be sent.
and
Can it still be related to the dongle i use? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-25 by werty1st The dongel has Bluetooth 4.0 and not 4.1. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-26 by @gfwilliams Great - thanks for the update! Which Bluetooth Dongle was it out of interest? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-28 by werty1st Its a
Do you know why that happends? Doesn't the code stop scanning before sending? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-29 by @gfwilliams Which one of the two adaptors was causing problems? I was pretty sure the BCM20702A0 would be ok. Honestly, I don't know why it happens. As you say, it seems the code does stop scanning - however perhaps there needs to be some time delay between stopping scanning and trying to connect. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-29 by werty1st With both of them. I already increased the
to 2000 without success. I will try this command later: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-24 by Grzegorz
I have managed to run the mqtt example from: espruino.com/Puck.js+Node-RED
I can receive the advertise and rssi. Now I'm trying to send a MQTT message when the button is pressed.
Any suggestions, examples please?
Beta Was this translation helpful? Give feedback.
All reactions