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. Problems with V_TEXT in MySensors 2.0.0

Problems with V_TEXT in MySensors 2.0.0

Scheduled Pinned Locked Moved Development
4 Posts 2 Posters 1.2k Views 2 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.
  • M Offline
    M Offline
    MikeF
    wrote on last edited by MikeF
    #1

    I've been converting my sketches to MySensors 2.0.0, and I seem to have hit a problem with a node using V_TEXT and S_INFO, getting a text value from Domoticz. Previously - under 1.5 - I had added V_TEXT and S_INFO to MyMessage.h, and this worked OK. (I have a text sensor in Domoticz, and typically this has a value such as 10.3#77#3, which I'm parsing in the sketch.)

    Now, however, I cannot get the sketch to read the value.

    I've stripped the sketch down to the bare basics here:

    // Text Sensor
    // MySensors 2.0.0
    
    #define MY_DEBUG
    
    #define MY_RADIO_NRF24
    #define MY_RF24_CE_PIN 7
    #define MY_RF24_CS_PIN 8
    
    #define MY_NODE_ID 40
    
    #include <MySensors.h>
    
    #define SKETCH_NAME "Text sensor"
    #define SKETCH_MAJOR_VER "2.0"
    
    #define TEXT_CHILD_ID 11
    
    unsigned long SLEEP_TIME = 30000;  	//  0.5 min. (300 sec.) sleep time between reads (seconds * 1000 milliseconds)
    String tempSensor;
    String outsideTemp;
    
    MyMessage textMsg(TEXT_CHILD_ID, V_TEXT);
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER);
    
    	present(TEXT_CHILD_ID, S_INFO);
    } 
    
    void setup()  
    {  
    
    }
    
    void loop() 
    {
    	request(TEXT_CHILD_ID, V_TEXT); 
      
    	// Sleep until something happens with the sensor
    	sleep(SLEEP_TIME);
    } 
    
    void receive(const MyMessage &message) {
    	if (message.type == V_TEXT)
    	{
    		tempSensor = message.getString();
    		int sepIndex = tempSensor.indexOf('#');
    		outsideTemp = tempSensor.substring(0, sepIndex);
    		Serial.println(tempSensor);
    	}
    }
    

    The main difference was changing 'void incoming Message' to 'void receive'.

    I've included a sample of the serial output here:

    TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
    TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
    TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
    

    The sketch seems to be sending out empty text strings, but not issuing any reads.

    Any clues? Thanks in anticipation.

    AWIA 1 Reply Last reply
    0
    • M MikeF

      I've been converting my sketches to MySensors 2.0.0, and I seem to have hit a problem with a node using V_TEXT and S_INFO, getting a text value from Domoticz. Previously - under 1.5 - I had added V_TEXT and S_INFO to MyMessage.h, and this worked OK. (I have a text sensor in Domoticz, and typically this has a value such as 10.3#77#3, which I'm parsing in the sketch.)

      Now, however, I cannot get the sketch to read the value.

      I've stripped the sketch down to the bare basics here:

      // Text Sensor
      // MySensors 2.0.0
      
      #define MY_DEBUG
      
      #define MY_RADIO_NRF24
      #define MY_RF24_CE_PIN 7
      #define MY_RF24_CS_PIN 8
      
      #define MY_NODE_ID 40
      
      #include <MySensors.h>
      
      #define SKETCH_NAME "Text sensor"
      #define SKETCH_MAJOR_VER "2.0"
      
      #define TEXT_CHILD_ID 11
      
      unsigned long SLEEP_TIME = 30000;  	//  0.5 min. (300 sec.) sleep time between reads (seconds * 1000 milliseconds)
      String tempSensor;
      String outsideTemp;
      
      MyMessage textMsg(TEXT_CHILD_ID, V_TEXT);
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER);
      
      	present(TEXT_CHILD_ID, S_INFO);
      } 
      
      void setup()  
      {  
      
      }
      
      void loop() 
      {
      	request(TEXT_CHILD_ID, V_TEXT); 
        
      	// Sleep until something happens with the sensor
      	sleep(SLEEP_TIME);
      } 
      
      void receive(const MyMessage &message) {
      	if (message.type == V_TEXT)
      	{
      		tempSensor = message.getString();
      		int sepIndex = tempSensor.indexOf('#');
      		outsideTemp = tempSensor.substring(0, sepIndex);
      		Serial.println(tempSensor);
      	}
      }
      

      The main difference was changing 'void incoming Message' to 'void receive'.

      I've included a sample of the serial output here:

      TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
      TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
      TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
      

      The sketch seems to be sending out empty text strings, but not issuing any reads.

      Any clues? Thanks in anticipation.

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #2

      @MikeF you are sleeping the node for almost all the time. While sleeping the node won't receive any messages. Use wait() instead.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        MikeF
        wrote on last edited by
        #3

        Thanks, @AWI - using wait() instead of sleep() works.

        However, isn't there an issue for battery-powered nodes in using wait rather than sleep? Sleep worked OK on my sketch under MySensors 1.5 - maybe the use of gw.begin(incomingMessage, NODE_ID) woke it up?

        Will this also be the case with other sketches which receive messages from the controller? for example, I have still to convert an RGB LED sketch which gets a hex value (in the form 0xrrggbb) from the controller?

        AWIA 1 Reply Last reply
        0
        • M MikeF

          Thanks, @AWI - using wait() instead of sleep() works.

          However, isn't there an issue for battery-powered nodes in using wait rather than sleep? Sleep worked OK on my sketch under MySensors 1.5 - maybe the use of gw.begin(incomingMessage, NODE_ID) woke it up?

          Will this also be the case with other sketches which receive messages from the controller? for example, I have still to convert an RGB LED sketch which gets a hex value (in the form 0xrrggbb) from the controller?

          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by
          #4

          @MikeF Good to hear that it worked for you. Possible just coincidence that it worked in V1.5. Reception of information on battery powered nodes is always an issue. The radio consumes a lot of energy while listening. There are a few new options in V2 to get around that. Take a look at the "Sleeping" section of the API Description

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


          11

          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