<SOLVED> What is wrong with my S_Wind V_Direction value? Never changes...



  • Hi,

    I am using a "dummy-sketch" to keep it simple. The sketch sends and updates the data for windspeed and gust to the Domoticz controller whenever i change the values in the skript. But when i change the value for val_wdirection the wind direction never changes in Domoticz. How come?

    It seems there is something wrong with this part of the sketch, right?

        unsigned int val_wdirection = 15; 
        if(last_wdirection != val_wdirection)
        { 
           last_wdirection = val_wdirection;
           send(msgWDirection.set(val_wdirection, 1));
           Serial.print("WD: ");
           Serial.println(val_wdirection);
        }
    

    And this is the complete sketch:

    #define MY_RADIO_NRF24
    #define MY_DEBUG
    #include <MySensors.h>
    #include <SPI.h>
    
    #define CHILD_ID_WIND 1
    
    unsigned int val_wspeed;
    unsigned int val_wgust;
    unsigned int val_wdirection;
    
    
    unsigned int last_wspeed;
    unsigned int last_wgust;
    unsigned int last_wdirection;
    
    MyMessage msgWSpeed(CHILD_ID_WIND, V_WIND);
    MyMessage msgWGust(CHILD_ID_WIND, V_GUST);
    MyMessage msgWDirection(CHILD_ID_WIND, V_DIRECTION);
    
    
    void presentation()
    {
        present(CHILD_ID_WIND, S_WIND);
    }
    
    void loop()
    {  
    //  gw.process();
     
    //  currentTime = millis();
      
        unsigned int val_wspeed = 12; 
        if(last_wspeed != val_wspeed)
        { 
           last_wspeed = val_wspeed;
           send(msgWSpeed.set(val_wspeed, 1));
           Serial.print("WS: ");
           Serial.println(val_wspeed);
        }
        
        unsigned int val_wgust = 4; 
        if(last_wgust != val_wgust)
        { 
           last_wgust = val_wgust;
           send(msgWGust.set(val_wgust, 1));
           Serial.print("WG: ");
           Serial.println(val_wgust);
        }
      
        unsigned int val_wdirection = 15; 
        if(last_wdirection != val_wdirection)
        { 
           last_wdirection = val_wdirection;
           send(msgWDirection.set(val_wdirection, 1));
           Serial.print("WD: ");
           Serial.println(val_wdirection);
        }
    }
    

    alt text
    The wind direction always say 20NNE. Temp and Chill also says 20 degrees and i have no idea where the number 20 comes from.

    I drives me crazy. I don't know what to do 😕


  • Mod

    The sketch looks ok to me.
    Could you post the serial debug output from the node with two different values?


  • Hero Member

    @edsteve Just a guess.. You seem to be sending an unsigned int (wind variables) as a float with one decimal with set(x, 1). It can very well be that this is not casted as expected.
    Try it with set(x)



  • Wow. I am happy to see answers 🙂

    @mfalkvidd
    Thats the serial log, which seems okay to me:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 TSM:INIT:TSP OK
    13 TSF:SID:OK,ID=1
    14 TSM:FPAR
    51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    69 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    73 TSF:MSG:FPAR OK,ID=0,D=1
    789 TSF:MSG:READ,3-3-1,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    878 TSF:MSG:READ,8-8-1,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    2058 TSM:FPAR:OK
    2059 TSM:ID
    2060 TSM:ID:OK
    2062 TSM:UPL
    2065 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2075 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2079 TSF:MSG:PONG RECV,HP=1
    2082 TSM:UPL:OK
    2084 TSM:READY:ID=1,PAR=0,DIS=1
    2088 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2096 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2103 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2113 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2125 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2131 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=9,pt=0,l=0,sg=0,ft=0,st=OK:
    2138 MCO:REG:REQ
    2141 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    2147 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    2152 MCO:PIM:NODE REG=1
    2154 MCO:BGN:INIT OK,TSP=1
    2159 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=8,pt=7,l=5,sg=0,ft=0,st=OK:12.0
    WS: 12
    2167 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=9,pt=7,l=5,sg=0,ft=0,st=OK:4.0
    WG: 4
    2176 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=10,pt=3,l=2,sg=0,ft=0,st=OK:15
    WD: 3
    

    @AWI
    I tried. Without success.

    Is there a clue why it is 20NNE? Also the temperature shows 20 in the picture from first post. Even though there is only the nrf24l01 connected. No sensor. Maybe the problem is related to this number. Just guessing also 🙂
    I used this arduino with a temp sensor before. Can that be conected? Hmm


  • Hero Member

    @edsteve something strange in the last two lines of the serial dump. You can see the node sending 15 while the print shows 3...

    Domoticz also has some peculiarities. The 20 is probably default and and a full circle is 16 values 😉



  • My mistake. I actually edit it right after i posted. But i think you were faster than me 🙂
    Yeah. I read about the magic number 16. Thats why i test with 15 😄
    If i understand that right Domoticz goes from 0 to 16 instead of 0 to 360. So 15 should do fine.
    So now i am out of guesses and clues 😕


  • Hero Member

    @edsteve This is from a wind sensor which is reporting the right values. As you can see I send the (float) windDirection as (int)windDirection / 16 to Domoticz (destinationNode 0). If sent to another node I can just use the float value (in degrees).

       	if (destinationNode == 0){			//send winddirection Deg/16 (for Domoticz)
       		send(windDirectionMsg.setDestination(destinationNode).set((int)lastWindDirection/16));
       	} else {
       		send(windDirectionMsg.setDestination(destinationNode).set(lastWindDirection, 1));	
       	}
    


  • Thanks for still coping with me. Tried playing with your suggestions but no success as well.
    But i found the problem.

    SOLUTION:
    I just gave the wind-sensor-node a different NODE_ID manually and now it updates the direction value.
    Seems there was some problems with old data when i used this arduino as a temp sensor.


Log in to reply
 

Suggested Topics

  • 5
  • 3
  • 5
  • 2
  • 2
  • 4

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts