Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. anderBAKE
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    anderBAKE

    @anderBAKE

    1
    Reputation
    8
    Posts
    4
    Profile views
    0
    Followers
    1
    Following
    Joined Last Online

    anderBAKE Follow

    Best posts made by anderBAKE

    • RE: Node to Node ACK

      @mfalkvidd said in Node to Node ACK:

      Welcome to the forum @anderBAKE

      Multiple people have tried, but I don't think anyone has been able to make it work.

      Some threads
      https://forum.mysensors.org/post/99252
      https://forum.mysensors.org/post/99485
      https://forum.mysensors.org/post/102134

      @mfalkvidd thanks! The first link is where I got the inspiration for my resend loop. I'll look into the other links after work today.

      @BearWithBeard said in Node to Node ACK:

      @anderBAKE When a node to node communication fails, MySensors will automatically fall back to the default route via the node's parent, so that ultimately the gateway can try to reach the destination node. I'm not sure if you can change that behaviour without touching the library code. But if you don't mind, a small change in MyTransport.cpp should do the trick.

      Change the following starting on line 548...

      if (destination > GATEWAY_ADDRESS && destination < BROADCAST_ADDRESS) {
      	// node2node traffic: assume node is in vincinity. If transmission fails, hand over to parent
      	if (transportSendWrite(destination, message)) {
      		TRANSPORT_DEBUG(PSTR("TSF:RTE:N2N OK\n"));
      		return true;
      	}
      	TRANSPORT_DEBUG(PSTR("!TSF:RTE:N2N FAIL\n"));
      }
      

      to the following...

      if (destination > GATEWAY_ADDRESS && destination < BROADCAST_ADDRESS) {
      	// node2node traffic
      	if (transportSendWrite(destination, message)) {
      		TRANSPORT_DEBUG(PSTR("TSF:RTE:N2N OK\n"));
      		return true;
      	} else {
      		TRANSPORT_DEBUG(PSTR("!TSF:RTE:N2N FAIL\n"));
      		return false;
      	}
      }
      

      This will drop out of the transportRouteMessage() function returning false to the send() function if the N2N communication failed.

      Note that, after this change, the node will not fall back to the default transport route anymore.

      Maybe this could be made an optional feature by introducing something like #define MY_DISABLE_N2N_FALLBACK to MyConfig.h?

      @BearWithBeard very interesting. I'll definitely be looking into this this evening as well.

      Thank you both for the speedy replies!

      posted in Troubleshooting
      anderBAKE
      anderBAKE

    Latest posts made by anderBAKE

    • RE: WeMos D1 Mini Gateway + Relay

      @TheoL Thanks. I kind of suspect that might be the case. It honestly shouldn't be this complicated. The device does everything else correctly and I'm certain the relay is wired correctly. I checked voltage, 5.4 at the relay (external power) and I know signal is getting through based on the spikes you mentioned (rapid open/close) when flashing the device.

      I'm not going to look it up right now, but I believe I remember reading somewhere that D0 was a reserved or special pin. Having looked at the WeMos relay shield, D1 is what is used, so I see no reason why it shouldn't work except that maybe I shorted it accidentally. Wouldn't be the first time.

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • RE: WeMos D1 Mini Gateway + Relay

      No success after stripping the sketch down to a bare relay example and using multiple different Boards from the board manager. I'm going to look into picking up a new D1 Mini + relay shield to see if it magically solves whatever issue I'm facing. @Yveaux once again, I appreciate the suggestions.

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • RE: WeMos D1 Mini Gateway + Relay

      @Yveaux Thanks again for the suggestions. I tried the

      #define RELAY_PIN D1
      

      in the previous sketch to no avail. I'll try something simple from the main loop() next without anything else mysensors.

      Maybe, I'm selecting the wrong board from the board manager? I had been using the NodeMCU 1.0 (ESP-12E Module) based on the instructions.

      I know that in my effort to make this work last night, I was using ESP8266 >3.0 in the board manager which had the LOLIN(WeMos) D1 Mini (clone). Nothing using >3.0 worked though, so I rolled back to ESP8266 2.7.4 which does not have the same LOLIN(WeMos) D1 Mini (clone); however, maybe I should be using one of the LOLIN models from the board manager?

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • RE: WeMos D1 Mini Gateway + Relay

      @Yveaux Thank you for the reply - at the least, it gave me the chance to reexamine the sketch I posted previously. In an effort to clean things up, I broke the functionality. Relay still doesn't work though. Here is the corrected sketch with output from the Serial Monitor.

      I realize how frustrating it is when the code posted doesn't accurately reflect what's being used - sorry about that.

      #define MY_DEBUG
      #define MY_BAUD_RATE 9600
      #define MY_RADIO_RF24
      #define MY_GATEWAY_ESP8266
      #define MY_WIFI_SSID "WiFiNetwork"
      #define MY_WIFI_PASSWORD "SuperSecretPassword"
      #define MY_HOSTNAME "MySensors_GW"
      #define MY_PORT 5003
      #define MY_GATEWAY_MAX_CLIENTS 255
      #define MY_NODE_ID 0
      #define CHILD_ID_RELAY 2
      
      #include <MyConfig.h>
      #include <MySensors.h>
      
      #define RELAY_PIN 1  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      MyMessage msgRelay(CHILD_ID_RELAY, V_STATUS);
      
      void before() {
        pinMode(RELAY_PIN, OUTPUT);
        digitalWrite(RELAY_PIN, 1);
      }
      
      void presentation() {
        sendSketchInfo("Attic GW", "0.2");
        present(CHILD_ID_RELAY, S_BINARY, "Switch");
        send(msgRelay.set(0));
      }
      
      void setup() {
        //pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
      }
      
      void loop() {
        //digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
      }
      
      void receive(const MyMessage &message) {
        //digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
        if (message.type == V_STATUS) {
          Serial.print("message.type = ");
          Serial.println(message.type);
          if (message.getBool() == 1) {
            Serial.print("message.getBool() = ");
            Serial.println(message.getBool());
            Serial.println("This is a V_STATUS message with a value of 1");
            //digitalWrite(RELAY_PIN, 0);
            //wait(5000);
            //digitalWrite(RELAY_PIN, 1);
            //wait(100);
          }
          send(msgRelay.set(0));
        }
      }
      

      Serial Monitor output below

      74064 GWT:RFC:C=0,MSG=0;2;1;1;2;1
      message.type = 2
      message.getBool() = 1
      This is a V_STATUS message with a value of 1
      

      I commented out the LED - I'm only using that as a simple network activity indicator - it's not related to the relay at all.

      I read in another forum post by @mfalkvidd that he used the Dn notation in his script, but I can't find the post now. I'm going to try that next.

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • WeMos D1 Mini Gateway + Relay

      Hello all,

      I'm attempting to add a single relay to my WeMos D1 Mini gateway. I have my nrf24 wired according to the instructions on the connecting the radios page and I currently have the relay attached to D1/GPIO5.

      I'm certain the gateway is receiving messages for the switch, I can see them in the Arduino Serial Monitor with debug enabled.

      I'm certain the relay is functional, it clicks on and off while uploading firmware to the device.

      I suspect I have the relay_pin mapped incorrectly, but I've tried several different variations with no success. I also suspect that I may be using a protected or special pin, but I've seen others on this forum using D1, so I'm not sure.

      Here's the Sketch, superfluous code/comments removed.

      #define MY_DEBUG
      #define MY_BAUD_RATE 9600
      #define MY_RADIO_RF24
      #define MY_GATEWAY_ESP8266
      #define MY_WIFI_SSID "WiFiNetwork"
      #define MY_WIFI_PASSWORD "SuperSecretPassword"
      #define MY_HOSTNAME "MySensors_GW"
      #define MY_PORT 5003
      #define MY_GATEWAY_MAX_CLIENTS 255
      #define MY_NODE_ID 0
      #define CHILD_ID_RELAY 2
      
      #include <MyConfig.h>
      #include <MySensors.h>
      
      #define RELAY_PIN 1
      #define RELAY_ON 0
      #define RELAY_OFF 1
      
      MyMessage msgRelay(CHILD_ID_RELAY, V_STATUS);
      
      void setup() {
        pinMode(RELAY_PIN, OUTPUT);
        pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
        digitalWrite(RELAY_PIN, RELAY_ON);
      }
      
      void presentation() {
        sendSketchInfo("Attic GW", "0.2");
        present(CHILD_ID_RELAY, S_BINARY, "Switch");
        send(msgRelay.set(0));
      }
      
      void loop() {
        wait(3);
        digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
      }
      
      void receive(const MyMessage &message) {
        digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
        if (message.type == V_STATUS) {
          if (message.getBool() == 1) {
            digitalWrite(RELAY_PIN, RELAY_OFF);
            wait(5000);
            digitalWrite(RELAY_PIN, RELAY_ON);
            wait(100);
          }
          send(msgRelay.set(0));
        }
      }
      

      As always, comments/suggestions appreciated.

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • RE: Node to Node ACK

      @BearWithBeard Making the change that you suggested returns the expected results! Thanks for suggestion.

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • RE: Node to Node ACK

      @mfalkvidd said in Node to Node ACK:

      Welcome to the forum @anderBAKE

      Multiple people have tried, but I don't think anyone has been able to make it work.

      Some threads
      https://forum.mysensors.org/post/99252
      https://forum.mysensors.org/post/99485
      https://forum.mysensors.org/post/102134

      @mfalkvidd thanks! The first link is where I got the inspiration for my resend loop. I'll look into the other links after work today.

      @BearWithBeard said in Node to Node ACK:

      @anderBAKE When a node to node communication fails, MySensors will automatically fall back to the default route via the node's parent, so that ultimately the gateway can try to reach the destination node. I'm not sure if you can change that behaviour without touching the library code. But if you don't mind, a small change in MyTransport.cpp should do the trick.

      Change the following starting on line 548...

      if (destination > GATEWAY_ADDRESS && destination < BROADCAST_ADDRESS) {
      	// node2node traffic: assume node is in vincinity. If transmission fails, hand over to parent
      	if (transportSendWrite(destination, message)) {
      		TRANSPORT_DEBUG(PSTR("TSF:RTE:N2N OK\n"));
      		return true;
      	}
      	TRANSPORT_DEBUG(PSTR("!TSF:RTE:N2N FAIL\n"));
      }
      

      to the following...

      if (destination > GATEWAY_ADDRESS && destination < BROADCAST_ADDRESS) {
      	// node2node traffic
      	if (transportSendWrite(destination, message)) {
      		TRANSPORT_DEBUG(PSTR("TSF:RTE:N2N OK\n"));
      		return true;
      	} else {
      		TRANSPORT_DEBUG(PSTR("!TSF:RTE:N2N FAIL\n"));
      		return false;
      	}
      }
      

      This will drop out of the transportRouteMessage() function returning false to the send() function if the N2N communication failed.

      Note that, after this change, the node will not fall back to the default transport route anymore.

      Maybe this could be made an optional feature by introducing something like #define MY_DISABLE_N2N_FALLBACK to MyConfig.h?

      @BearWithBeard very interesting. I'll definitely be looking into this this evening as well.

      Thank you both for the speedy replies!

      posted in Troubleshooting
      anderBAKE
      anderBAKE
    • Node to Node ACK

      Evenin' all. I'm using the following to confirm messages are successfully sent.

      void Resend(MyMessage &msg) {
        int repeatDelay = 1000;
        boolean sendOK = false;
        unsigned long lastWhile;
      
        while (sendOK == false) {
          if ((millis() - lastWhile) >= repeatDelay) {
            if (send(msg) == true) sendOK = true;
            else repeatDelay += 1000;
            lastWhile = millis();
          }
        }
      }
      

      Here's the full code.

      #define MY_DEBUG
      #define MY_RADIO_RF24
      #define MY_NODE_ID 22
      #define SENSOR_NAME "Master Bedroom Sensors"
      #define SENSOR_VERSION "2.1"
      #define DHT_DATA_PIN 3
      #define SENSOR_TEMP_OFFSET 0
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      #include <SPI.h>
      #include <DHT.h>
      #include <MySensors.h>
      #include <avr/wdt.h>
      
      DHT dht;
      
      int lastTemp, lastHum;
      unsigned long lastLoop;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      void presentation() {
        sendSketchInfo(SENSOR_NAME, SENSOR_VERSION);
        present(CHILD_ID_HUM, S_HUM, "Humidity");
        present(CHILD_ID_TEMP, S_TEMP, "Temperature");
      }
      
      void setup() {
        wdt_enable(WDTO_8S);
        dht.setup(DHT_DATA_PIN);
      }
      
      void loop() {
        if ((millis() - lastLoop) >= 10000) {
          dht.readSensor(true);
          int temperature = lrint(dht.toFahrenheit(dht.getTemperature()) + SENSOR_TEMP_OFFSET);
          if (temperature > 1 && temperature != lastTemp) {
            lastTemp = temperature;
            Resend(msgTemp.setDestination(26).setSensor(101).set(lastTemp));
            Resend(msgTemp.set(lastTemp));
          }
      
          int humidity = lrint(dht.getHumidity());
          if (!isnan(humidity) && humidity != lastHum) {
            lastHum = humidity;
            Resend(msgTemp.setDestination(26).setSensor(100).set(lastHum));
            Resend(msgHum.set(lastHum));
          }
          lastLoop = millis();
        }
        wdt_reset();
      }
      
      void Resend(MyMessage &msg) {
        int repeatDelay = 1000;
        boolean sendOK = false;
        unsigned long lastWhile;
      
        while (sendOK == false) {
          if ((millis() - lastWhile) >= repeatDelay) {
            if (send(msg) == true) sendOK = true;
            else repeatDelay += 1000;
            lastWhile = millis();
          }
        }
      }
      

      This works very well for messages sent to the gateway; however, it is not catching node-2-node failures.

      10041 !TSF:MSG:SEND,22-22-26-26,s=101,c=1,t=0,pt=2,l=2,sg=0,ft=0,st=NACK:70
      10048 !TSF:RTE:N2N FAIL
      10052 TSF:MSG:SEND,22-22-0-26,s=101,c=1,t=0,pt=2,l=2,sg=0,ft=0,st=OK:70
      10094 !TSF:MSG:SEND,22-22-26-26,s=100,c=1,t=1,pt=2,l=2,sg=0,ft=0,st=NACK:58
      10101 !TSF:RTE:N2N FAIL
      

      I shut down node 26 in order to reproduce the errors. Is there a way to catch these failures?

      Thanks!

      posted in Troubleshooting
      anderBAKE
      anderBAKE