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. Troubleshooting
  3. How to send updated V_TEXT/S_INFO to controller?

How to send updated V_TEXT/S_INFO to controller?

Scheduled Pinned Locked Moved Troubleshooting
domoticzvtextmysensors 2.0.0sinfo
8 Posts 3 Posters 4.6k 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.
  • micahM Offline
    micahM Offline
    micah
    wrote on last edited by
    #1

    I'm working on an alarm clock... my controller is Domotiocz. I'm using a text sensor to send the alarm time to my arduino.... the following post helped me get it all working properly -> lcd-clock-and-text-sensor-node-with-new-v_text

    My clock also has buttons (like a traditional alarm clock), I've written all the code to change the alarm using the buttons.

    Now I want to send the new alarm time set on the arduino to the controller (Domoticz), and have the text sensor updated. I thought this would simply be a send(....) command, but I can't get it working.

    Here is a sub-set sample code of what I thought I needed to do to send the update (I'm on mysensors 2.0.*)

    #define MY_DEBUG 
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 9
    #include <SPI.h>
    #include <MySensors.h>
    #define cID_ALARM_TIME 1
    
    MyMessage MySensors_MSG_Alarm1_Time(cID_ALARM_TIME, V_TEXT);
    
    void setup() {
    	Serial.begin(115200);
    
    	request(cID_ALARM_TIME, V_TEXT);
    }
    void presentation()  {
    	sendSketchInfo("WakeUp Clock", "0.0.1");
    	
    	present(cID_ALARM_TIME, S_INFO, "Alarm Time", true);
    }
    void loop() {
    
    	int newHour = 12;
    	int newMinute = 45;
    
    	String val = String(newHour) + "." + String(newMinute);
    
    	send(MySensors_MSG_Alarm1_Time.set(val), true);
    }
    void receive(const MyMessage &message) {
    	if (message.type==V_TEXT) {
    		if (message.sensor == cID_ALARM_TIME){
    			// Here is where the return value comes from Domoticz when requesting the V_TEXT
    		}
    	}
    }
    

    When I run it I get the following console message....

    35287 TSF:MSG:SEND,9-9-0-0,s=1,c=1,t=47,pt=1,l=1,sg=0,ft=0,st=OK:1
    35297 TSF:MSG:READ,0-0-9,s=1,c=1,t=47,pt=1,l=1,sg=0:1
    35302 TSF:MSG:ACK
    

    and then my controller (Domoticz) updates the text sensor to the value of 1

    I'm very confused, please help :)

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hek
      Admin
      wrote on last edited by
      #2

      You should not use the String class in a Arduino environment (google why).

      The send function takes a char buffer. If you need to append/copy things into it, use strcpy or memcpy.

      http://www.cplusplus.com/reference/cstring/strcpy/

      mfalkviddM micahM 2 Replies Last reply
      0
      • H hek

        You should not use the String class in a Arduino environment (google why).

        The send function takes a char buffer. If you need to append/copy things into it, use strcpy or memcpy.

        http://www.cplusplus.com/reference/cstring/strcpy/

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        @hek not strncpy? http://www.cplusplus.com/reference/cstring/strncpy/

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hek
          Admin
          wrote on last edited by
          #4

          @mfalkvidd
          Sure, if you'd like some more control over things :)

          mfalkviddM 1 Reply Last reply
          0
          • H hek

            @mfalkvidd
            Sure, if you'd like some more control over things :)

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by mfalkvidd
            #5

            @hek otherwise you might end up in this thread https://forum.mysensors.org/topic/5212/why-ioyt-matters

            Edit: well not centrally bricked but owned and part of a botnet

            1 Reply Last reply
            0
            • H hek

              You should not use the String class in a Arduino environment (google why).

              The send function takes a char buffer. If you need to append/copy things into it, use strcpy or memcpy.

              http://www.cplusplus.com/reference/cstring/strcpy/

              micahM Offline
              micahM Offline
              micah
              wrote on last edited by
              #6

              @hek
              Ok, I think I understand what you are saying, but I can't figure out the implementation.

              This didn't work

              char temp_Msg[3];
              strcpy (temp_Msg, char("1"));
              strcpy (temp_Msg, char("."));
              strcpy (temp_Msg, char("1"));
              send(MySensors_MSG_Alarm1_Time.set(temp_Msg), true);
              

              or this

              char temp_Msg[3];
              strcpy (temp_Msg, "1");
              strcpy (temp_Msg, ".");
              strcpy (temp_Msg, "1");
              send(MySensors_MSG_Alarm1_Time.set(temp_Msg), true);
              

              or this

              char temp_Msg[3];
              strcpy (temp_Msg, '1');
              strcpy (temp_Msg, '.');
              strcpy (temp_Msg, '1');
              send(MySensors_MSG_Alarm1_Time.set(temp_Msg), true);
              

              But this does work (message is sent and loaded into Domoticz)

              send(MySensors_MSG_Alarm1_Time.set("1.1"), true);
              

              What am I not understanding?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hek
                Admin
                wrote on last edited by hek
                #7
                  char buf[20];
                  strcpy (buf,"Hello ");
                  strcat (buf,"world");
                  strcat (buf,"!");
                
                
                micahM 1 Reply Last reply
                0
                • H hek
                    char buf[20];
                    strcpy (buf,"Hello ");
                    strcat (buf,"world");
                    strcat (buf,"!");
                  
                  
                  micahM Offline
                  micahM Offline
                  micah
                  wrote on last edited by
                  #8

                  @hek

                  Oh, I didn't know I needed to use both.

                  Well I tried a million combinations after seemingly reading everything on the subject, and I still couldn't get {int + char + int} converted into a char[] using strcpy and strcat

                  for some reason my brain is just not wrapping itself around the concept today... maybe I'll come back to it tomorrow.

                  In the mean time, I tried the following and it worked.

                  char buf[20];    
                  sprintf(buf, "%d.%d", Alarm1_Time_Local[0], Alarm1_Time_Local[1]);
                  send(MySensors_MSG_Alarm1_Time.set(buf), true);
                  

                  I've read that using sprintf increases the size of your sketch... but for now I'm fine with it, since it works and I can move on to being creative and productive.. lol

                  1 Reply Last reply
                  0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  45

                  Online

                  12.0k

                  Users

                  11.2k

                  Topics

                  113.4k

                  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