0

I'm having trouble writing exact values to the arduino. I have an led strip that I want to control using software on my computer (Processing Serial equivalent), but the values received don't seem to match the ones sent. I'm using byte coercion on Java, so I should be sending the correct bit pattern even though Java bytes are signed. I wrote a loop to send and get back bytes from the arduino, and I got back this mapping. (human readable sent, human readable received).

0 128
1 129
2 130
3 131
4 132
5 133
6 6
7 135
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 48
17 49
18 50
19 51
20 52
21 53
22 54
23 55
24 56
25 57
26 58
27 59
28 60
29 61
30 158
31 159
32 160
33 161
34 66
35 67
36 68
37 69
38 70
39 71
40 72
41 73
42 74
43 75
44 76
45 77
46 78
47 79
48 112
49 113
50 114
51 115
52 116
53 117
54 118
55 119
56 120
57 121
58 122
59 123
60 188
61 125
62 190
63 191
64 192
65 193
66 130
67 131
68 132
69 133
70 134
71 135
72 136
73 137
74 138
75 139
76 140
77 141
78 142
79 143
80 176
81 177
82 178
83 179
84 180
85 181
86 182
87 183
88 184
89 185
90 186
91 187
92 188
93 189
94 190
95 223
96 224
97 193
98 194
99 195
100 196
101 197
102 198
103 199
104 200
105 201
106 202
107 203
108 204
109 205
110 206
111 207
112 240
113 241
114 242
115 243
116 244
117 245
118 246
119 247
120 248
121 249
122 250
123 251
124 252
125 253
126 254
127 255
128 128
129 129
130 130
131 131
132 132
133 5
134 134
135 135
136 8
137 9
138 10
139 11
140 12
141 13
142 14
143 15
144 48
145 49
146 50
147 51
148 52
149 53
150 54
151 55
152 56
153 57
154 58
155 59
156 60
157 61
158 62
159 159
160 160
161 65
162 66
163 67
164 68
165 69
166 70
167 71
168 72
169 73
170 74
171 75
172 76
173 77
174 78
175 79
176 112
177 113
178 114
179 115
180 116
181 117
182 118
183 119
184 120
185 121
186 122
187 123
188 188
189 189
190 190
191 191
192 192
193 193
194 130
195 195
196 132
197 133
198 134
199 135
200 136
201 137
202 138
203 139
204 140
205 141
206 142
207 143
208 176
209 177
210 178
211 179
212 180
213 181
214 182
215 183
216 184
217 185
218 186
219 187
220 188
221 189
222 190
223 223
224 224
225 225
226 194
227 195
228 196
229 197
230 198
231 199
232 200
233 201
234 202
235 203
236 204
237 205
238 206
239 207
240 240
241 241
242 242
243 243
244 244
245 245
246 246
247 247
248 248
249 249
250 250
251 251
252 252
253 253
254 254

There are these inexplicable gaps in the values. Further, this does not appear to be a 1:1 mapping. I am completely baffled by this. The arduino code opens the serial like this:

Serial.begin(1000000);

Java end (using jssc, like processing serial does).

SerialPort x = new SerialPort ("/dev/ttyUSB1");
x.openPort();
x.setParams(1000000, 8, 1, SerialPort.PARITY_NONE);
x.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);

Even though I'm using a high baud, that does not appear to be the issue. I ran this multiple times and got the exact same mappings every time.

(should be irrelevant, but I'm using a NodeMCU with the arduino library.)

  • have you tried using a lower baud rate? – jsotola Feb 5 at 2:54
  • That does fix it. Why would running at a high baud create a stable mapping like that? – J Atkin Feb 5 at 3:34
  • 6
    google aliasing .... you have a stream of data ... the data is sampled at regular intervals, but not at correct intervals .... if you run the same data and sample at the same points, then you will get the same results – jsotola Feb 5 at 3:39
  • That didn't do it. However, this page did work it all out. esp8266.com/viewtopic.php?t=1711 – J Atkin Feb 6 at 7:09

Browse other questions tagged or ask your own question.