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. Controllers
  3. Vera
  4. Issue with temperature units

Issue with temperature units

Scheduled Pinned Locked Moved Vera
23 Posts 9 Posters 11.3k 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.
  • Y Offline
    Y Offline
    Yveaux
    Mod
    wrote on last edited by
    #10

    @jocke4u said:

    l=2:M

    I find it strange that length is reported as 2 while only a single character seems to be sent. The protocol version 1.4 is correctly reported as length 3.

    http://yveaux.blogspot.nl

    H 1 Reply Last reply
    0
    • Y Yveaux

      @jocke4u said:

      l=2:M

      I find it strange that length is reported as 2 while only a single character seems to be sent. The protocol version 1.4 is correctly reported as length 3.

      H Offline
      H Offline
      hek
      Admin
      wrote on last edited by
      #11

      @Yveaux

      uint8_t MyMessage::getByte() const {
      	if (miGetPayloadType() == P_BYTE) {
      		return data[0];
      	} else if (miGetPayloadType() == P_STRING) {
      		return atoi(data);
      	} else {
      		return 0;
      	}
      }
      

      Payload type will be P_STRING when controller sends the data. Yes, why does it get size 2?!

      H 1 Reply Last reply
      0
      • H hek

        @Yveaux

        uint8_t MyMessage::getByte() const {
        	if (miGetPayloadType() == P_BYTE) {
        		return data[0];
        	} else if (miGetPayloadType() == P_STRING) {
        		return atoi(data);
        	} else {
        		return 0;
        	}
        }
        

        Payload type will be P_STRING when controller sends the data. Yes, why does it get size 2?!

        H Offline
        H Offline
        hek
        Admin
        wrote on last edited by hek
        #12

        Hmm.. we should probably not use atoi in case of String. Payload type should not matter in the getByte.

        H 1 Reply Last reply
        0
        • H hek

          Hmm.. we should probably not use atoi in case of String. Payload type should not matter in the getByte.

          H Offline
          H Offline
          hek
          Admin
          wrote on last edited by hek
          #13

          Yep, this is a bug.

          I've also found that the newline character is included and transmitted on all outgoing messages from gateway! So payload length 2 was correct, and wrong ;)

          How is it possible no one has seen this before (me included)?

          Y 1 Reply Last reply
          0
          • J Offline
            J Offline
            jocke4u
            wrote on last edited by
            #14

            Sounds good anyway....one bug less :)
            I just setup a sensor with DHT22/AM2302 and get the same results here.

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

              Fix checked in. I'm creating a more comprehensive release note in the 1.4 thread.

              1 Reply Last reply
              0
              • H hek

                Yep, this is a bug.

                I've also found that the newline character is included and transmitted on all outgoing messages from gateway! So payload length 2 was correct, and wrong ;)

                How is it possible no one has seen this before (me included)?

                Y Offline
                Y Offline
                Yveaux
                Mod
                wrote on last edited by
                #16

                @hek said:

                How is it possible no one has seen this before (me included)?

                At least I saw it ;-)
                I personally tend to read over all the details in the serial api... This time I noticed.

                Be glad you nailed it!

                http://yveaux.blogspot.nl

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jocke4u
                  wrote on last edited by
                  #17

                  Thanks @hek and @Yveaux I can confirm it's working on both Dallas sensor and DHT22.
                  Great support!!

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    Nuubi
                    wrote on last edited by
                    #18

                    Hmmm... how can one override this statement to be METRIC?
                    float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?TemperatureSensors.getTempCByIndex(CHILD_ID_TEMPERATURE_FIRST+i):TemperatureSensors.getTempFByIndex(CHILD_ID_TEMPERATURE_FIRST+i)) * 10.)) / 10.;

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hexenmeister
                      wrote on last edited by
                      #19

                      hello,

                      I must confess I have not read this thread completely. Too much for my bad english)

                      We try MySensors support for FHEM (www.fhem.de) to impementieren. I noticed that when the I_CONFIG message is answered correctly with 'M' for metric, then the sensor sends in Imperial. Is not surprising, everything is interpreted as a string from Gateway, but also byte checked. My solution proposal: In MySensors.cpp:
                      (isMetric = msg.getString()[0] == 'M' ; instead of isMetric = msg.getByte() == 'M' ;)

                      			} else if (type == I_CONFIG) {
                      				// Pick up configuration from controller (currently only metric/imperial)
                      				// and store it in eeprom if changed
                      				//isMetric = msg.getByte() == 'M' ;
                      				isMetric = msg.getString()[0] == 'M' ;
                      				if (cc.isMetric != isMetric) {
                      					cc.isMetric = isMetric;
                      					eeprom_write_byte((uint8_t*)EEPROM_CONTROLLER_CONFIG_ADDRESS, isMetric);
                      					//eeprom_write_block((const void*)&cc, (uint8_t*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
                      				}
                      			} else if (type == I_CHILDREN) {
                      

                      Best regards,

                      Alexander

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

                        Welcome @hexenmeister!

                        What version of MySensors library did you download? The current version in gihub/master already has getString()[0].

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          hexenmeister
                          wrote on last edited by
                          #21

                          Thanks for the quick reply.
                          I've downloaded the source here: https://github.com/mysensors/CodeBender/blob/master/MySensor.cpp
                          Since it is still old.

                          Now I see that https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MySensor.cpp would be better.

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

                            Oh.. you downloaded from codebender. That explains it.

                            Unfortunately it's still a bit too messy to update the public libraries over there (have to contact the codebender-people every time). Nowadays we keep a copy among in the MySensors-account which gets copied if you clone one of the examples.

                            Github always contains the latest.

                            1 Reply Last reply
                            0
                            • H Offline
                              H Offline
                              hexenmeister
                              wrote on last edited by
                              #23

                              My mistake. Was unfortunately cost few hours time for the search. For that I have won something overview in MySensors Code :)

                              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


                              19

                              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