Can't get past first base (Arduino Serial Gateway)



  • Hello. I cannot get even the simplest MySensors example working. I am sure I must be missing something simple but I have run out of ideas.

    THIS WORKS:
    I have two Arduino Uno, each with an NRF24L01 connected, and each Arduino is connected to (and powered by) a laptop computer via USB and running Arduino 1.8.6 software so I can use the Serial Monitor.

    Via the Sketch>>Include Library>>Manage Libraries I have added RF24 by TMRh20 version 1.3.0, and I have added MySensors by The MySensors Team version 2.1.1.

    If I use the RF24 Example Sketch “pingpair_ack” the only change I have to make is to add “#define MY_BAUD_RATE 9600”. Apart from that I can upload the sketch to each Arduino and monitor them via Serial Monitor and they work perfectly.

    I can even swap the two Arduino’s between the two laptops and they still both work.

    So I have proven that fundamentally I have two working RF / Arduino devices powered via laptop USB connections.

    THIS DOES NOT WORK:
    Same setup as above, but using MySensors Examples does not work. For example Sketch “GatewaySerial” gives me the following:

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;!TSM:INIT:TSP FAIL
    0;255;3;0;9;TSM:FAIL:CNT=1
    0;255;3;0;9;TSM:FAIL:PDT
    0;255;3;0;9;TSM:FAIL:RE-INIT
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;!TSM:INIT:TSP FAIL
    0;255;3;0;9;TSM:FAIL:CNT=2```


  • What controller are you connecting your gateway to?



  • @dbemowsk No controller - I was using a RPi and MQTT but because I could not get that to work I have stripped everything back to the simplest solution I could think of. So now I just have two Arduinos, one running the Arduino Serial Gateway. I assume it just writes to the Serial port which I can monitor via the Serial Monitor?



  • I have had the same problem when first trying out MySensors.

    The MySensors gateway doesnt work without a controller. Just download MyController for testing purposes (it is small and can run on your pc) and connect the serial gateway to it.

    If you have proved everything working, you can switch to a Raspi or other controller device with a more powerful software to run 24/7


  • Mod

    @mljbr4 welcome to the MySensors community!

    Just to check, you are using the wiring described at https://www.mysensors.org/build/connect_radio and you have connected a capacitor close to the nrf24?

    I am not familiar with the raw tmrh20 library, but it seems it defaults to different pins for CE and CSN (compared to MySensors default).



  • @mfalkvidd said in Can't get past first base (Arduino Serial Gateway):

    https://www.mysensors.org/build/connect_radio

    It's a miracle. Works perfectly now! I knew it had to be something obvious but I had tried so many things I lost track. Turns out it was a simple CE / CSN Pin issue. You are right, the NRF24 library defaults to Pins 7 and 8, but MySensors defaults to 9 and 10. Thanks for your help. Hopefully now I can march on with my real solution which is a RaspberryPi Gateway and MQTT running on one RPi, and OpenHAB running on another.


  • Mod

    @mljbr4 great! Thanks for reporting back.

    About the rpi gateway, there have been several reports of problems lately. We haven't found the root cause, but the development version seems to work better than the 2.1.1 release.



  • @mfalkvidd Unfortunately I can't get a clean compile of the development branch at the moment. I did the following:

    rm -R ~/MySensors
    git clone https://github.com/mysensors/MySensors.git --branch development
    cd MySensors
    ./configure --my-transport=nrf24 --my-rf24-ce-pin=22 --my-rf24-cs-pin=24 --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=home-network --my-mqtt-subscribe-topic-prefix=home-network-in --my-mqtt-client-id=home-network --my-rf24-channel=76 --DMY_RF24_DATARATE=RF24_250KBPS --my-debug=enable
    make
    

    and I got the following result:

    gcc -MT build/drivers/BCM/bcm2835.o -MMD -MP -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_GATEWAY_MQTT_CLIENT -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_RF24_CHANNEL=76 -DMY_MQTT_CLIENT_ID=\"home-network\" -DMY_MQTT_SUBSCRIBE_TOPIC_PREFIX=\"home-network-in\" -DMY_MQTT_PUBLISH_TOPIC_PREFIX=\"home-network\" -DMY_CONTROLLER_IP_ADDRESS=127,0,0,1 -DMY_RF24_CS_PIN=24 -DMY_RF24_CE_PIN=22  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/BCM -c drivers/BCM/bcm2835.c -o build/drivers/BCM/bcm2835.o
    drivers/BCM/bcm2835.c: In function ‘bcm2835_delayMicroseconds’:
    drivers/BCM/bcm2835.c:441:40: error: expected ‘)’ before ‘PRIu64’
       printf("bcm2835_delayMicroseconds %" PRIu64 "\n", micros);
                                            ^
    drivers/BCM/bcm2835.c:441:40: warning: spurious trailing ‘%’ in format [-Wformat=]
    Makefile:102: recipe for target 'build/drivers/BCM/bcm2835.o' failed
    make: *** [build/drivers/BCM/bcm2835.o] Error 1
    

    I might try fixing the code myself and see what happens but I'd be interested to know if this is a common problem.



  • @mljbr4 well I don't know if this is the right solution or not but to solve the PRIu64 issue I added the following lines to the top of drivers/BCM/bcm2835.c and I managed to get a clean compile and now mysgw on my RaspberrryPi is working:

    #define __STDC_FORMAT_MACROS
    #include <inttypes.h>
    

  • Mod

    @mljbr4 thanks for the feedback.
    Reference to github issue: https://github.com/mysensors/MySensors/issues/980


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 8
  • 1
  • 6

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts