String myConvertedString(myFloat, 2); // convert float to String, with specified number of decimals
proof of concept:
void setup()
{
Serial.begin(115200);
Serial.println("ready");
float myFloat = 36.1415;
Serial.println(myFloat, 4);
String myConvertedString(myFloat, 2); // convert float to String, with specified number of decimals
Serial.println(myConvertedString);
// it compiles, because myConvertedString is a String (if you replace it with myFloat, will throw compilation error)
String myString = myConvertedString;
Serial.println(myString);
}
void loop()
{}
and well its partially blynk related if one is to use those api functions… but anyway, thanks for the reply, im going to mull over this together with the other stuff I have still to get my head wrapped around.
ok let me skip the how I do it now and go straight to the how can I do it from now on:
Setup (3 ESP’s)
Thermometer <—> Central unit <–> Relay
Central also communicates with the app.
The relay will send every e.g. 12 hours a maintenance bool ON or OFF to central over virtual pin V10. Now I can put central in a loop constantly checking whether the state of V10 has changed and as soon as that has happened: send the value onwards to the thermostat (which then displays: “maintenance running”).
But is there a smarter way to ‘only act when the value has changed or value change is send’ ?
does that make more sense?
(pls note that this is a oversimplified example. reality is more complex and a LOT more variables are shot around)
And I’m again a couple of miles further down the road, only to find another wall…
I’ve rewritten most of my code to work on a local server and after quite some debugging I stumbled on a communication issue. That is: something is send but nothing is received. Now initially I thought that this line:
String url = "http://blynk-cloud.com/";
was the issue as I’m not running the setup on the blynk-cloud. So I changed it to:
String url = "http://192.168.1.93/";
which is the IP of the server that is running. But nothing is happening. Any clue what I’m doing wrong?
@wolph42 Port 9443 is for the App link to the server, I believe HTTP commands act as if from the device, which is port 8080 for Local Server (and eventually Cloud as I understand).
Correct! HTTP API is on the same port as device-to-server channel. I don’t know if setting in .properties file other port than 8080 will work, but I don’t feel the need to try.
yes, I got that from another topic where I got a http error which I couldn’t make sense of. That fix I’ve applied here as well. I’ve also checked 3 times whether Im really sending the info to the right token: I am. But nothing is received.
(later) Ok I’m at a loss: I thought to check the app to see if the value is updated there and noticed that I could not log in to the server. Checking my router and I noticed that my server is NOT in the list. Then I checked the serial.print of my central specifically: isHardwareConnected and that one returns TRUE. How on earth is that possible??? There is no server to connect to and thus no server to check if the device is online, but my central esp magically knows that its on???
Point now is that I don’t know what to trust and how to test whether the API is actually working…
edit: rebooted server, everything working ‘normally’ again. I noticed that I did not change the port for the value update, after changing that to 8080 it worked!
note that im still curious how on earth the device could be detected with the server being offline!