Sending an integer >32767
Anduril last edited by Anduril
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.
flopp last edited by flopp
I have checked my sketches. But I don't know so much about code.
Try 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. (
unsigned 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
32768the node 'received'
4294934528(written to the serial monitor)...
well I did some further testing... sending e.g.
65000from the node to the controller works, sending back
65001does 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.