Custom Raspberry Pi3 Controller, gateway API question



  • I have successfully setup a MySensors network using multiple Nano's + nRF24, with a gateway Nano setup as a 'serial G/W' and connected to my RaspberryPi 3 via USB cable. I have programmed my own controller on the Pi in NodeJs successfully reading the message data sent to Pi from the Nano gateway via USB serial link, and I have created custom web pages to display the sensor data. All of this is working very well.

    However I have run into a problem when I try to use the Pi/Nano USB serial connection to write data from the Pi to the gateway in order to send an action to a sensor. e.g. when I send the following text "7;0;1;0;32;31" from my NodeJs app on Pi to the gateway, it's as if the gateway isn't reading the message, as nothing happens. i.e. the gateway does not forward the message to node 7. What am I missing, is there a configuration setting on the serial gateway that I need to enable the gateway to receive and act on the data sent from my custom controller via serial port (USB cable) ? I know my custom NodeJS controller on the Pi is actually sending the correct text string down the USB cable to the Nano, because I tested it by replacing the gateway script with a simple script that reads and echos the data read from the serial port. This worked perfectly as the string "7;0;1;0;32;31" was echoed back as the correct ascii character codes e.g. 55 59 48 59 etc. So the problem is definitely with the MySensors gateway software not interpreting the text string "7;0;1;0;32;31" that I am sending from my custom Pi NodeJs controller. Or perhaps this message format is wrong. I have tried varies formats e.g. "7;0;1;0;32;31", "7;0;1;0;32;31\n", "7;0;1;0;32;31;", none of them initiate any response from the gateway. I even tried something simpler e.g. e.g. "0;0;3;0;2;" which is the controller requesting the gateway's version. But the gateway isn't responding to any of these messages sent from my custom Pi controller.

    Any help would be appreciated 🙂


  • Admin

    Do you send a newline character after the command? Do you need to flush the serial line from nodejs perhaps?



  • Thanks, problem solved.
    It was the newline character as you indicate. The node script I wrote on the Raspberry PI wasn't converting my text string correctly to ascii and was not sending the newline character. Thanks for pointing me in the right direction. I'm now on my way to completing a really cool project that connects my custom Amazon Echo web service to my mySensors home network via a Raspberry Pi, allowing me to change my TV channels using voice recognition commands from the comfort of my living room couch. "Alexa Pause TV", "Alexa rewind 2 TV minutes", "Alexa replay Detroit Lions touchdown" 🙂 .


  • Mod

    What do you use mysensors for in this project?



  • I have setup a voice activated remote control for my TV. I use Amazon Alexa voice services building a custom skill for the voice commands. This calls a URL on my Raspberry PI with an integer representing the command requested. My PI then sends the command to my mySensors gateway via serial link. The gateway then sends the command to a node that has an IR transmitter sending the signal to the TV. It all works like a charm.


  • Mod

    It's a little complex but not bad! 👍 😄


Log in to reply
 

Suggested Topics

  • 3
  • 3
  • 2
  • 10
  • 15
  • 2

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts