Debian Codegraph @

build/shared/ArduinoSerialPlotterProtocol.md

raw symbols SCIP
1 # SerialPlotter protocol
2
3 One message can consist of multiply parts.
4 One part can consist of one label, one label and a value or only a value.
5
6 | | |
7 | --- | --- |
8 | End of message symbol | \n |
9 | Part separator symbols | ' '(space), '\t'(tab), ','(comma) |
10 | Label-value separator symbol | : |
11
12 # Valid messages are
13
14 ## Labels and value messages:
15 | | | | | | |
16 |-------------------|----|-------------------|-----|-------------------|----|
17 | Label : Value | | | | | \n |
18 | Label 1 : Value 1 | \t | Label 2 : Value 2 | | | \n |
19 | Label 1 : Value 1 | \t | Label 2 : Value 2 | ... | Label n : Value n | \n |
20
21 ## Label only messages
22 | | | | | | |
23 |-----------|----|-----------|-----|----------|----|
24 | Label: | | | | | \n |
25 | Label 1 : | \t | Label 2 : | | | \n |
26 | Label 1 : | \t | Label 2 | ... | Label n: | \n |
27
28 There is a special case, the CSV header style.
29
30 | | | | | | |
31 |-------|----|---------|-----|---------|----|
32 |Label 1| \t | Label 2 | ... | Label n | \n |
33
34 But in this format, labels consisting of only numbers are not recognised as labels.
35 It is safer to just use the normal label only message.
36
37 ## Value only messages Value
38 This is not recommended if you using a board with USB to UART converter.
39 Because when the label is sent, before you had the SerialPlotter opened, then the label/labels get/gets never set.
40
41 | | | | | | |
42 |---------|----|---------|-----|---------|----|
43 | Value 1 | \t | Value 2 | | | \n |
44 | Value 1 | \t | Value 2 | ... | Value n | \n |
45
46
47 # Examples
48 ## Single Trace without label
49
50 This example plots on line on serial plotter without setting a label
51
52 ```ino
53 void setup() {
54 Serial.begin(9600);
55 }
56
57 void loop() {
58 int sensorValue1 = analogRead(A0);
59
60 Serial.println(sensorValue1);
61
62 delay(100);
63 }
64 ```
65
66 The output looks like this
67 ```
68 10\n
69 11\n
70 12\n
71 13\n
72 14\n
73 ```
74 ## Single Trace with label
75
76 This example sends the label once in the setup routine. Afterwards only the value is send.
77
78 ```ino
79 void setup() {
80 Serial.begin(9600);
81 Serial.println("Label 1:");
82 }
83
84 void loop() {
85 int sensorValue1 = analogRead(A0);
86
87 Serial.println(sensorValue1);
88
89 delay(100);
90 }
91 ```
92
93 The output looks like this
94 ```
95 Label 1:\n
96 10\n
97 11\n
98 12\n
99 13\n
100 14\n
101 ```
102
103 ## Single Trace with label send every time
104
105 This example sends the label every time together with the value.
106
107 ```ino
108 void setup() {
109 Serial.begin(9600);
110 }
111
112 void loop() {
113 int sensorValue1 = analogRead(A0);
114
115 Serial.print("Label 1:"); Serial.println(sensorValue1);
116
117 delay(100);
118 }
119 ```
120
121 The output looks like this
122 ```
123 Label 1:10\n
124 Label 1:11\n
125 Label 1:12\n
126 Label 1:13\n
127 Label 1:14\n
128 ```
129 ## Two Traces with label send every time
130
131 This example sends two values together with the labels.
132
133 ```ino
134 void setup() {
135 Serial.begin(9600);
136 }
137
138 float avg = 0;
139
140 void loop() {
141 int sensorValue1 = analogRead(A0);
142
143 // send lable and value seperated by ':'
144 Serial.print("Value:"); Serial.print(sensorValue1);
145
146
147 avg = (avg * 4 + analogRead(A0)) / 5.0;
148 // send part devider '\t'
149 Serial.print("\t");
150 // send the second lable and value
151 Serial.print("AVG5:"); Serial.println(avg);
152
153
154 delay(100);
155 }
156 ```
157
158 The output looks like this
159 ```
160 Value:377 AVG5:431.01
161 Value:338 AVG5:408.81
162 Value:392 AVG5:395.85
163 Value:583 AVG5:427.28
164 Value:221 AVG5:383.42
165 Value:195 AVG5:343.74
166 Value:202 AVG5:314.19
167 Value:209 AVG5:292.15
168
169 ```
170