Node ESP8266 with NFR24 and WiFi disabled



  • I happen to have few ESP8266 and NRF24+ laying around and would like to use ESP instead of Arduino to blend with the rest of mySensors network. I prefer WiFi disabled on ESP. Does anybody have a sample code to start with?


  • Mod

    @apl2017 I don't think I have seen anyone use esp as nodes, but it should just be a matter of wiring and setting defines like the esp gateway, except removing MY_GATEWAYXESP8266. Then add the code for the node, just like a "normal" node.



  • Thank you, I will try



  • This post is deleted!


  • @mfalkvidd

    Here is my sketch intended to detect water leak from a sensor connected to D4:

    #define MY_DEBUG
    #define MY_BAUD_RATE 9600
    #define MY_RADIO_RF24
    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    #define LEAK_1_CHILD_ID 1
    #define LEAK_1_PIN D4
    bool LEAK_1;
    bool last_LEAK_1;
    MyMessage msg_LEAK_1(LEAK_1_CHILD_ID,V_TRIPPED);

    void setup()
    {
    pinMode(LEAK_1_PIN,INPUT);
    digitalWrite(LEAK_1_PIN,HIGH);
    WiFi.mode( WIFI_OFF );
    WiFi.forceSleepBegin();
    }

    void presentation()
    {
    present(LEAK_1_CHILD_ID, S_DOOR);
    }

    void loop()
    {
    LEAK_1 =digitalRead(LEAK_1_PIN);
    if (LEAK_1 != last_LEAK_1)
    {
    send(msg_LEAK_1.set(LEAK_1));
    last_LEAK_1 = LEAK_1;
    }
    }

    Here is what I am reading over serial interface. After seems to be successful initial communication, ESP gets stack on not getting ACK from the radio. Any idea why?

    189 MCO:BGN:INIT NODE,CP=RNNNE---,REL=255,VER=2.3.1
    377 TSM:INIT
    391 TSF:WUR:MS=0
    414 TSM:INIT:TSP OK
    435 TSF:SID:OK,ID=102
    458 TSM:FPAR
    508 TSF:MSG:SEND,102-102-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    1262 TSF:MSG:READ,0-0-102,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    1320 TSF:MSG:FPAR OK,ID=0,D=1
    2585 TSM:FPAR:OK
    2602 TSM:ID
    2615 TSM:ID:OK
    2631 TSM:UPL
    2649 TSF:MSG:SEND,102-102-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2724 TSF:MSG:READ,0-0-102,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2784 TSF:MSG:PONG RECV,HP=1
    2813 TSM:UPL:OK
    2830 TSM:READY:ID=102,PAR=0,DIS=1
    2867 TSF:MSG:SEND,102-102-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2946 TSF:MSG:READ,0-0-102,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    3013 TSF:MSG:SEND,102-102-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1
    3094 TSF:MSG:SEND,102-102-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    5170 TSF:MSG:SEND,102-102-0-0,s=1,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
    5241 MCO:REG:REQ
    5263 TSF:MSG:SEND,102-102-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    5339 TSF:MSG:READ,0-0-102,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    5398 MCO:PIM:NODE REG=1
    5424 MCO:BGN:STP
    force slp enable,type: 2
    fpm open,type:2 0
    5443 MCO:BGN:INIT OK,TSP=1
    7768 !TSF:MSG:SEND,102-102-0-0,s=1,c=1,t=16,pt=1,l=1,sg=0,ft=0,st=NACK:1


  • Mod

    @apl2017 on the öast message, the node is not getting ack from the next node. The mose common cause is i sufficiently clean power supply. What size of capacitor are you using? How is the radio getting its power?
    Adding wait(200) before the send call can help the power to stabilize.

    Since all communication before works, wiring and everything else should be ok.


Log in to reply
 

Suggested Topics

  • 4
  • 8
  • 2
  • 3
  • 9
  • 9

16
Online

11.4k
Users

11.1k
Topics

112.7k
Posts