QTR analog sensor readings not stable

Hi there,

I have purchased several QTR 3A sensors, but I’m not getting stable results from them. It seems that the output either increase or decrease in time.

Here is my test program:

void setup() {
  Serial.begin(9600); 
}

void loop() {
  // put your main code here, to run repeatedly:
  int val = analogRead(0);       
  Serial.println(val);            
  delay(500); 
}

Below, at the end, are the results. You can see that the first reading is 336, but then, in time, decrease to 258. My device is not moving, nothing else is moving around it … so why I have such variation in time?

thanks,
mihai

336
336
335
334
334
335
334
334
333
333
332
334
332
332
332
332
331
333
331
331
331
331
327
329
327
327
327
327
327
328
327
326
327
325
325
327
324
324
324
325
325
326
324
324
324
324
323
325
323
322
323
323
322
324
322
322
322
322
322
323
322
322
321
322
322
323
321
321
321
321
320
322
319
320
319
318
318
320
318
318
318
317
318
319
317
317
317
317
316
319
317
317
316
316
316
318
315
315
314
314
313
315
313
313
314
313
313
313
313
312
313
312
313
314
312
312
311
311
310
312
310
309
310
310
307
309
305
304
305
301
300
299
292
264
275
282
288
292
292
294
295
296
296
299
297
297
298
297
298
301
298
299
300
300
300
302
300
300
300
301
301
303
301
301
301
301
301
303
301
302
302
301
302
304
302
302
301
302
301
304
301
302
302
302
302
304
302
302
303
304
302
304
305
302
303
302
304
305
304
302
302
304
304
305
302
303
303
302
302
303
296
298
293
290
295
293
293
293
284
287
299
301
300
298
301
295
293
295
297
296
289
289
291
290
288
287
288
287
287
289
283
282
288
293
295
296
292
294
295
295
291
297
298
297
297
293
292
293
291
293
290
289
291
291
289
288
288
290
290
291
291
289
289
289
288
288
288
286
286
285
285
284
284
286
286
285
284
284
286
284
284
278
287
287
289
287
287
286
286
286
288
286
285
285
286
285
286
285
285
285
285
284
286
284
284
284
284
284
286
284
285
285
285
286
286
285
284
285
284
282
284
281
281
281
280
281
283
281
282
282
282
283
285
283
284
285
286
284
286
287
287
285
290
287
288
290
288
293
290
292
295
293
291
296
291
293
293
292
291
291
292
291
290
288
288
288
287
286
289
286
286
286
286
285
287
286
285
285
285
286
286
287
288
286
286
284
286
284
285
285
284
284
285
282
283
284
283
285
286
285
288
287
287
286
288
287
288
288
290
288
290
288
288
288
288
289
291
293
290
292
290
289
291
288
288
289
290
289
288
287
287
286
287
287
291
290
289
290
290
292
292
292
290
289
290
288
288
288
286
289
287
287
286
286
285
285
285
284
284
283
283
282
280
279
281
282
280
280
280
281
281
281
279
280
280
279
278
278
277
277
277
278
276
276
275
275
277
276
277
276
276
274
275
277
275
273
273
272
272
272
274
274
273
273
272
273
273
271
270
271
276
271
273
272
271
271
271
270
272
270
271
268
268
269
270
269
268
268
268
268
269
267
267
267
267
266
268
266
266
266
267
268
268
268
268
266
268
267
267
267
265
265
265
265
267
267
265
265
266
266
266
264
264
266
267
264
266
265
266
263
263
263
265
264
265
266
266
267
268
266
266
265
265
266
267
265
265
264
265
265
267
264
264
264
264
264
266
264
263
264
264
263
265
263
263
264
264
264
266
265
264
264
264
264
266
264
265
264
263
263
265
263
264
264
264
264
265
264
264
264
263
263
266
264
263
264
263
263
265
263
262
264
263
262
265
263
263
263
263
266
265
266
266
263
263
265
266
263
264
264
265
266
267
266
267
266
266
264
265
263
264
264
263
262
266
263
262
263
263
262
265
263
262
263
262
263
263
263
263
263
265
262
265
264
264
265
263
262
262
264
262
264
262
261
264
262
264
262
262
262
265
264
265
265
264
262
265
265
263
265
265
265
265
264
262
262
263
261
261
262
262
261
262
261
262
261
264
263
262
261
262
264
262
262
262
262
262
264
263
264
262
264
264
264
262
263
262
264
264
263
262
261
262
262
264
263
261
261
261
261
263
263
261
261
261
261
261
263
261
261
261
261
261
263
261
261
261
261
261
262
263
260
261
261
261
263
260
260
261
261
261
262
261
260
261
261
261
263
261
261
261
261
261
263
261
261
261
261
262
263
262
261
262
261
261
264
261
261
262
262
263
262
260
260
261
261
261
262
260
261
261
261
260
261
260
263
261
265
261
263
262
262
261
261
263
263
261
261
260
260
260
261
259
259
259
259
259
260
259
259
259
259
259
260
259
258
261
259
259
261
258
258
259
260
259
261
261
259
260
260
259
262
260
262
259
260
260
262
259
259
259
259
260
262
259
260
259
259
258
261
259
259
258
258
259
261
258
259
259
260
259
261
261
260
259
259
258
260
259
258
258
260
260
260
259
261
258
258
258
261
258
260
258
258
258
260
258
258
261
258
261
260
258
258
258
258
258
259
257
257
258
257
258
259
257
259
257
258
257
259
257
257
257
257
257
259
257
257
256
257
257
260
257
258
257
256
257
259
256
257
256
256
256
259
256
257
256
256
256
259
258
256
256
258
256
258
256
256
256
256
256
258
255
256
256
257
257
258
256
256
255
255
255
257
255
255
257
255
255
257
255
255
255
255
255
257
255
255
254
255
255
256
255
255
255
254
254
256
255
255
254
254
255
256
256
254
254
254
254
256
254
254
254
254
253
257
254
254
254
254
255
255
254
255
255
255
255
255
255
254
256
256
255
254
256
255
255
255
256
255
255
255
255
255
255
255
255
255
255
256
256
256
256
257
257
257
258
258
260
258
258
257
258
258
261
259
260
261
261
262
264
264
265
265
266
267
267
266
265
265
264
264
266
264
264
261
259
255
256
253
259

Here is another reading. Same sensor, same setup. I have only disconnected the USB cable from my Arduino Nano and then I have reconnected again. Now the values are increasing:

Any ideas?

215
215
215
215
215
216
215
215
216
216
216
218
216
217
218
216
217
217
217
217
219
217
217
217
217
216
218
215
215
216
216
216
219
217
217
217
218
219
221
219
219
220
221
221
222
221
221
221
222
222
224
223
222
223
223
224
226
224
224
224
225
225
227
225
226
226
226
226
228
227
227
228
228
228
230
228
229
229
229
230
232
230
230
230
232
230
232
230
230
231
231
231
232
231
231
231
234
232
235
232
233
233
233
234
237
235
235
234
235
235
236
235
235
235
235
235
237
235
236
235
237
236
239
237
237
237
237
238
240
238
238
238
238
238
240
239
239
238
238
239
241
239
239
239
239
239
242
239
240
241
240
240
243
241
241
241
241
241
243
241
241
241
241
242
245
242
242
242
243
242
246
244
246
243
244
244
247
244
245
245
246
246
249
246
248
246
246
247
250
247
247
248
248
248
250
248
248
248
248
248
252
249
249
250
250
250
252
250
253
252
250
250
252
253
251
252
252
251
254
252
251
252
254
254
255
252
253
253
253
253
256
253
255
254
256
254
257
256
254
254
255
255
258
257
258
257
257
258
259
257
257
257
258
259
259
257
257
257
257
257
260
260
259
259
258
258
260
258
258
257
258
257
260
258
260
258
261
258
260
260
261
260
258
258
260
258
258
258
258
259
261
262
261
260
261
259
263
260
259
261
261
261
259
258
262
253
264
263
266
264
266
265
268
267
271
269
268
267
267
266
267
265
267
265
265
266
266
264
265
265
268
266
270
268
270
270
270
271
275
274
272
272
272
271
272
269
269
270
267
267
269
266
265
265
265
264
266
264
264
264
264
264
264
264
264
263
264
263
263
263
263
262
263
265
264
262
262
263
262
262
262
262
262
262
263
263
262
264
262
262
261
262
263
261
261
261
261
261
262
260
264
260
263
260
262
261
263
261
263
261
261
262
262
263
262
264
262
263
263
262
263
263
263
262
262
263
262
263
263
263
265
263
263
265
265
262
262
263
265
263
263
265
266
263
263
265
262
262
263
262
262
262
263
261
262
261
264
264
261
263
261
262
261
262
265
263
261
265
263
264
264
265
262
264
262
262
262
263
261
261
261
262
262
263
262
262
262
262
262
264
262
262
262
261
261
263
262
262
262
262
262
264
261
263
261
262
263
263
263
267
292
295
297
299
300
301
300
300
303
304
303
304
306
307
308
310
306
309
308
312
316
313
317
318
318
324
329
334
335
336
336
336
336
338
336
336
337
337
337
339
337
337
336
334
332
333
331
332
332
332
332
333
331
332
332
335
333
335
334
334
334
332
332
332
331
331
331
330
331
333
333
332
333
331
331
332
331
331
332
334
336
338
336
335
334
332
333
337
334
335
339
302
335
335
340
341
342
337
344
341
343
337
342
339
341
341
341
343
350
353
354
356
354
355
354
355
356
357
354
351
350
349
348
347
348
349
343
351
343
352
341
353
348
352
353
345
347
353
351
350
354
358
359
359
360
361
361
364
366
366
367
365
363
370
371
371
371
370
370
371
369
370
371
371
373
373
371
371
372
372
372
374
372
373
373
374
373
375
374
374
374
374
375
377
376
375
376
375
376
377
375
375
376
376
376
377
378
378
377
376
376
377
375
376
375
375
375
377
365
375
366
376
376
376
377
378
378
376
376
378
371
377
377
377
377
378
376
362
377
378
378
379
378
380
380
380
376
381
380
380
359
379
380
360
364
372
382
381
384
387
386
386
369
377
385
389
388
388
389
391
392
392
386
387
390
391
399
406
408
396
427
432
432
431
425
424

Hello.

We do not expect that much variation from that sensor. Can you tell me more about how you are using it? What microcontroller are you using to read the data? How are you supplying power? How is the QTR-3A mounted? What kind of ambient lighting is the sensor operating in? Can you post pictures that clearly show your connections and setup?

-Jon

I use Arduino Nano in my setup.
I will send a picture soon.
Is there possible to have such variation in a matter of several minutes?
or, something is wrong with my setup ?

Like I mentioned in my initial reply, we do not expect that much variation over that much time. If you include a picture of your setup and describe it more, I might be able to determine if there is something obviously wrong with your setup.

-Jon

thanks!

I think that I have found the problem.
I think that the distance to the surface was too small in my case. If I increased the distance a little bit, the results are stable in time.

thanks again,
mihai