CSV telemetry in Arduino
Comma-separated lines that the serial plotter graphs directly.
// Comma-separated lines: the serial plotter graphs them directly.
void setup() {
Serial.begin(115200);
Serial.println("soil,light,temp");
}
void loop() {
int soil = analogRead(A0);
int light = analogRead(A1);
int temp = analogRead(A2);
Serial.print(soil);
Serial.print(',');
Serial.print(light);
Serial.print(',');
Serial.println(temp);
delay(250);
}
How it works
- A header line names the columns once in
setup. - Three sensors print with
,separators,printlnlast. - 115200 baud keeps the plot smooth at four lines a second.
Keywords and builtins used here
SerialanalogReadbegindelayintloopprintprintlnsetupvoid
The run, in numbers
- Lines
- 17
- Characters to type
- 352
- Tokens
- 97
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 83 seconds.
Step 3 of 3 in Serial, step 15 of 27 in Language basics.