Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tatic char* getTelemetryPayload() {
- Senzor s = utilizator.getSenzor();
- int sensorValue = analogRead(A0); // Read the sensor value
- // Convertirea valorii analogice la tensiune
- float voltage = sensorValue * (3.3 / 1023.0);
- float temperatureC = (voltage - 0.5) * 25; // Convert the voltage to temperature in Celsius
- Serial.print("Temperature: ");
- Serial.print(temperatureC);
- Serial.println(" °C");
- // Create the JSON payload using sprintf
- sprintf((char*)telemetry_payload,
- "{ \"SenzorId\": %d, \"Val1\": %.2f, \"Val2\": %.2f }",
- s.getSenzorId(), temperatureC, (30 + (millis() % 10) / 10.0));
- telemetry_send_count++;
- Serial.println((char*)telemetry_payload);
- return (char*)telemetry_payload;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement