Error decoding message from gateway, bad data received

  • Hi all!
    I am brand new to this forum and sorry for the following newbie question.
    I just finished assembling a serial gateway consisting of an Arduino Nano (clone) and an NRF24L01 radio module. The gateway is connected to an RPi 3 via USB port. The gateway and the test child node is able to communicate just fine. However Home Assistant is having an issue with the data coming from the gateway.


    2022-09-11 18:02:48.316 INFO (MainThread) [mysensors.gateway_serial] Trying to connect to /dev/ttyACM0
    2022-09-11 18:02:48.343 INFO (MainThread) [mysensors.transport] Connected to Serial<id=0x7fa5227640, open=True>(port='/dev/ttyACM0', baudrate=38400, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False)
    2022-09-11 18:05:43.312 DEBUG (MainThread) [mysensors.transport] Receiving �E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������
    2022-09-11 18:05:43.313 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: �E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������E������������@���P��������
    2022-09-11 18:05:43.331 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
    2022-09-11 18:05:43.370 DEBUG (MainThread) [mysensors.transport] Receiving E����6�������
    2022-09-11 18:05:43.371 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: E����6�������
    2022-09-11 18:05:43.378 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)

    Of course the same baud rate is used on both gateway and home assistant. I tried lowering the baud rate, but that didn't help, only gibberish is received.

    The sketch running on the gateway is as follows:

    / Enable debug prints to serial monitor
    // #define MY_DEBUG
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    // Enable serial gateway
    #define MY_BAUD_RATE 38400
    // Enable inclusion mode
    // Enable Inclusion mode button on gateway
    // Inverses behavior of inclusion button (if using external pullup)
    // Set inclusion mode duration (in seconds)
    // Digital pin used for inclusion mode button
    // Set blinking period
    // Inverses the behavior of leds
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    #include <MySensors.h>
    void setup()
      // Setup locally attached sensors
    void presentation()
      // Present locally attached sensors
    void loop()
      // Send locally attached sensor data here

    I am using the following software versions:
    MySensors: 2.3.2
    Home Assistant OS: 8.5

    I'm kinda stuck and clueless. Any help is welcome and highly appreciated!

  • @adamk The data looks like different serial BAUD rates in Home Automation (HA) and your Arduino. The default for HA is 115200. The default in the Arduino GatewaySerial example is 38400. (line 58) You must change one or the other to match. (I'd call this a bug) I'd opt on the safe side and make them both 38400, though 115200 would minimize over running the serial buffer.

    Alternately, you could try the MySensors MQTT gateway running on the RPi. Home Assistant, mosquitto (MQTT broker) and MySensors gateway might be a bit much for an RPi. Daunting task, Let's hope it's the BAUD


  • Mod

  • @mfalkvidd That's really good information! Thanks!

    The bug to which I refer is the fact that the default BAUD rate setting should be the same in all examples. The documentation you present shows what the default should be.


  • Mod

    @OldSurferDude the examples are not specific to atmega328-based Arduinos.

    The comment in the sketch is fairly specific

    // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400

  • Thanks for all the answers!

    Finally i managed to get it work. The reason for this issue was that a wrong serial port was entered in the input field of the MySensors Serial gateway setup window in Home Assistant. By default it was /dev/ttyACM0 however it turned out that it was already used by some other dongle.

Log in to reply

Suggested Topics

  • 2
  • 1
  • 1
  • 2
  • 6
  • 3
  • 7