Serial Communication & Adafruit IO

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
JoseeMallah
 
Posts: 9
Joined: Thu Oct 31, 2019 6:34 am

Serial Communication & Adafruit IO

Post by JoseeMallah »

Hello everyone!
I am using an Arduino UNO to get analog readings from 2 sensors. Then, I am sending the product (*) of these 2 values to a NodeMCU via serial communication. The value is received correctly: when I use

Code: Select all

Serial.write(Serial.read())
correct values are displayed. However, when I move the value received to a variable then print it:

Code: Select all

x = Serial.read()
Serial.println(x)
different (wrong) values are shown. And these same wrong values are uploaded to Adafruit IO.
So, does anyone know what's happening? Any format or data size differences? Why am I obtaining wrong values? And how to get the correct ones?
Thank you

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Serial Communication & Adafruit IO

Post by dastels »

What language are you coding in and what is the type of x? There is probably some incorrect casting/coercion happening.

Dave

User avatar
JoseeMallah
 
Posts: 9
Joined: Thu Oct 31, 2019 6:34 am

Re: Serial Communication & Adafruit IO

Post by JoseeMallah »

Yes right thank you, I had to use parseFloat().

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”