Sending telemetry
CPP
main.ino
void kirimData() {
float suhu = 28.5;
ruangiot.send("temperature", suhu);
}
Set the interval
Avoid publishing on every loop() iteration. Use a timer so the publish rate matches what the sensor needs without overloading the broker or the database.
Payload format
- Use numbers for numeric data.
- Use consistent values for booleans, for example
0/1orOFF/ON. - Avoid large JSON payloads when a single variable is enough.
- Don't send passwords, tokens, or personal data.
Validate the results
- Check the Serial Monitor.
- Make sure the MQTT status shows as connected.
- Open Data History and filter by device/variable.
- Make sure the timestamp and data source are correct.