Sending an integer >32767
-
Hey there,
I'm trying to send a value between 10.000 and 99.999, but as soon as it gets bigger than 32.767 (size of int16) I receive totally senseless numbers. Is there a way to send this big number e.g. with an int32? I use V_VAR1 as message type.
Regards,
Anduril
-
@Anduril
I have checked my sketches. But I don't know so much about code.double VAR1
long VAR1Try if they work
-
@Anduril Are you sending it from your sketch or the controller? If you are sending from the sketch make sure the "setter"
// Setters for payload MyMessage& set(void* payload, uint8_t length); MyMessage& set(const char* value); MyMessage& set(uint8_t value); MyMessage& set(float value, uint8_t decimals); MyMessage& set(unsigned long value); MyMessage& set(long value); MyMessage& set(unsigned int value); MyMessage& set(int value);
can recognize the variable as a type > int16. (
long
orunsigned long
) i.e
unsigned long variableToBeSend = 1234567 UL ;
I assume the value is now 'overflowing' to a negative number.
-
I tried to send from controller. When sending
32768
the node 'received'4294934528
(written to the serial monitor)...
-
well I did some further testing... sending e.g.
65000
from the node to the controller works, sending back65001
does not. That seems more related to the controller (MyController) than MySensors. Maybe @jkandasa can help shine some light on this.
-
I found the problem... or to be honest @jkandasa found it. He told me in the MyController forum to check my receiving code and not use getInt() but getLong(). Thanks again to him.
-
@Anduril great that you found the problem. Thanks for sharing the solution, it might help someone else in the future.
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
LAN8720A - will mysensors work with this module
Development • 13 Nov 2024, 17:06 • Marcin 15 Nov 2024, 10:59 -
Home Assistant/MySensors quirks
Development • 13 days ago • OldSurferDude 13 days ago -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14 -
PJON and Minicore not working
Development • 8 days ago • Trand 8 days ago