Hi,
How can I pass array of doubles through the wifi?
I've been playing with client.write() and successfully passed strings, characters, integer numbers but when it comes to double numbers, i can't get it to work. I have some sensors data that uses decimal number and need help passing double values.
Thank you in advance
how to send array of double through wifi
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: how to send array of double through wifi
Not sure exactly what you mean, but printf is the way to have precise control over your output. A double = long long = int64_t in esp32.
Code: Select all
double x = 9876543210;
Serial.printf("Output my double value: %ll\n", x);
Re: how to send array of double through wifi
thank you for your responce.lbernstone wrote: ↑Tue Oct 03, 2023 3:24 amNot sure exactly what you mean, but printf is the way to have precise control over your output. A double = long long = int64_t in esp32.Code: Select all
double x = 9876543210; Serial.printf("Output my double value: %ll\n", x);
what if x is an array?
is there a way to pass x as an array? or do you have to printf each element of the array individually? if its a larger array say 20 elements it gets harder to printf/call each element individually.
Code: Select all
x [] = {9.12, 5.53, 7.23}
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: how to send array of double through wifi
Code: Select all
const float array1[] = {1.23, 4.56, 7.89};
void setup() {
Serial.begin(115200);
uint32_t array_count = sizeof(array1) / sizeof(float);
if (array_count) {
String buffer = String(array1[0]);
for (int x=1; x<array_count; x++) {
buffer += ", " + String(array1[x]);
}
Serial.println(buffer);
}
}
Who is online
Users browsing this forum: No registered users and 90 guests