Hey All! I'm using sensors that don't come with a library so I had to convert a c string into a float using the atof() function. When I print the float of the atof function on the serial monitor, I'm getting good values. However, when I try to link an IoT variable to the float, I just get zero. I've attached the code here. Is there anyway to show what's on the serial monitor on my dashboard?
const unsigned int MAX_MESSAGE_LENGTH = 13;
#include "thingProperties.h"
void setup() {
Serial.begin(9600); //start serial communication with PC
Serial4.begin(9600); //setting communication rate with R1 Gigia (serial port 4) at 9600 baud rate
initProperties(); //defined in thingProperties library
ArduinoCloud.begin(ArduinoIoTPreferredConnection);// connect to iot cloud
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
while (Serial4.available() > 0)
{
static char dissolvedoxygen[MAX_MESSAGE_LENGTH];
static unsigned int domessage_pos = 0;
char doinByte = Serial4.read();
if ( doinByte != '\r' && (domessage_pos < MAX_MESSAGE_LENGTH - 1) )
{
dissolvedoxygen[domessage_pos] = doinByte;
domessage_pos++;
}
else
{
dissolvedoxygen[domessage_pos] = '\0';
float dissolved_oxygen = atof(dissolvedoxygen);//store value as float
Serial.println(dissolved_oxygen);
domessage_pos = 0;
}
}
}