Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. nRF24L01+ MQTT

nRF24L01+ MQTT

Scheduled Pinned Locked Moved Development
13 Posts 4 Posters 3.8k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Nca78N Offline
    Nca78N Offline
    Nca78
    Hardware Contributor
    wrote on last edited by Nca78
    #3

    Hello,

    It will be difficult to help you without sketch and wiring of the problematic node, can you post them (or at least explain for the Iring, tell us what you use as power source etc)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TimDe
      wrote on last edited by
      #4

      you are right, Nca78.

      So here is my sketch of the sender

      #include <SPI.h>
      
      #define MY_RADIO_NRF24
      
      #include <MySensors.h>
      int Payload;
      
      #define CHILD_ID 2
      
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
      }
      
      void presentation()
      {
      }
      
      void loop()
      {
        Payload = Payload+2;
        send(msg.set(Payload));
        delay(2000);
      }
      

      and here is the sketch of the recheiver:

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      
      #define MY_GATEWAY_MQTT_CLIENT
      #define MY_GATEWAY_ESP8266
      
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "nRFGateway-Publish"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "nRFGateway-Subscribe"
      
      #define MY_MQTT_CLIENT_ID "mysensors-1"
      
      // Enable these if your MQTT broker requires usenrame/password
      //#define MY_MQTT_USER "username"
      //#define MY_MQTT_PASSWORD "password"
      
      #define MY_ESP8266_SSID "..."
      #define MY_ESP8266_PASSWORD "..."
      
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      // #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway"
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,178,87
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // MQTT broker ip address and port.
      #define MY_CONTROLLER_IP_ADDRESS ...
      #define MY_PORT ...
      
      #include <ESP8266WiFi.h>
      #include <MySensors.h>
      
      void setup() {
        Serial.begin(38400);
      }
      
      void presentation() {
      }
      
      void loop() {
      }
      

      I think there is no problem with the sketch, because both sketches work when I am using an Arduino Uno instead of the standalone ATmega with the same sketch and wiring.

      And here are photos of the wiring. The radio is wired correctly, I checked it several times. And I also use the same wiring for the ATmega as I do usually...
      0_1517580253597_b618ae95-7482-4f8d-ac61-3baa6afb6f7f-image.png

      0_1517580272148_2cf39497-d90a-4458-9e17-f463b9e76364-image.png

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TimDe
        wrote on last edited by
        #5

        A short addition:
        After starting the Mikrocontroller, my MQTT broker always receives the same messages. They have no payload and the syntax of the first four messages for example is:

        nRFGateway-Publish/255/16/3/0/3
        nRFGateway-Publish/255/239/3/0/3
        nRFGateway-Publish/255/206/3/0/3
        nRFGateway-Publish/255/174/3/0/3

        I hope this may help...

        1 Reply Last reply
        0
        • Nca78N Offline
          Nca78N Offline
          Nca78
          Hardware Contributor
          wrote on last edited by
          #6

          I'm sorry I won't be able to help for the MQTT side, I've not implemented this at my home yet...

          But if you run exactly the same script on the same chip then the difference is the wiring.
          What bootloader/frequency do you use on the atmega ?
          I see no 100nF cap on the power pins, maybe it would help for stability ?

          1 Reply Last reply
          0
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #7

            I think you need to add something in presentation function of the node, otherwise the mysensors gw down't know what the node is sending

            T 1 Reply Last reply
            0
            • T Offline
              T Offline
              TimDe
              wrote on last edited by
              #8

              So there is the difference. The Uno has 16MHz and the standalone 1MHz... and the wiring is 100% correct, I did this again and again like 10 Times and also tried a Second microcontroller without improvements. And the Strange Thing is that I Receive Messages (from Time to Time) but the Data Sent are Strange)
              And so the only difference is in the Frequence and the missing other Parts. Is there anything in the mqtt background which prohibits the correct transmission?

              1 Reply Last reply
              0
              • gohanG gohan

                I think you need to add something in presentation function of the node, otherwise the mysensors gw down't know what the node is sending

                T Offline
                T Offline
                TimDe
                wrote on last edited by
                #9

                @gohan

                But the exact same Code works on the uno...

                1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #10

                  I don't know much about the 1Mhz, but I read quite some times it can give problems.

                  T Nca78N 2 Replies Last reply
                  0
                  • gohanG gohan

                    I don't know much about the 1Mhz, but I read quite some times it can give problems.

                    T Offline
                    T Offline
                    TimDe
                    wrote on last edited by
                    #11

                    @gohan until now everything worked well with this 1MHz. Also other libraries directly worked without Problems

                    1 Reply Last reply
                    0
                    • gohanG Offline
                      gohanG Offline
                      gohan
                      Mod
                      wrote on last edited by
                      #12

                      You'd never know what an updated library could do to your setup. Even a newer board definition could add a bug that you didn't have before.

                      1 Reply Last reply
                      0
                      • gohanG gohan

                        I don't know much about the 1Mhz, but I read quite some times it can give problems.

                        Nca78N Offline
                        Nca78N Offline
                        Nca78
                        Hardware Contributor
                        wrote on last edited by
                        #13

                        @gohan said in nRF24L01+ MQTT:

                        I don't know much about the 1Mhz, but I read quite some times it can give problems.

                        It can give problems to speed/time accuracy related stuff, like driving neopixels or sensors with bit-banging and need for very precise pulse duration. For sending messages with a NRF24 it has never been a problem for me.

                        It can also be a problem ... with serial. @TimDe is debug set in your MyConfig.h file ? and what baudrate is set for serial ?
                        Can you try to set baudrate to 9600 as 1MHz with internal oscillator you can't go faster than that reliably, maybe your node is trying to write something on serial too fast for what it can handle ?
                        Try to put the 100nf ceramic caps first (between gnd/avcc and gnd/vcc), that will close one possibility.

                        Can you get a debug log on the mqtt gateway to see the content of the MySensors messages it receives from the node ?

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        13

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.1k

                        Posts


                        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular