I need advice on Debugging Node for Temperature Sensor Project

Hi guys! :smiling_face_with_three_hearts:

I am working on a project where I need to interface a DS18B20 temperature sensor with an Arduino using XOD. I’ve followed a few tutorials and have managed to get some basic readings, but I am facing issue where the readings sometimes spike to unrealistic values (e.g., -127°C).

Here are the steps I’ve taken so far:

  • Connected the DS18B20 to the Arduino with the appropriate pull-up resistor on the data line.
  • Used the XOD DS18B20 node to read the temperature values.
  • Added a watch node to monitor the readings in real-time.
  • Despite these steps, I still get occasional incorrect readings. I suspect it might be a problem with my wiring or perhaps a glitch in the code. Has anyone else experienced similar issues? If so, how did you resolve them? Any advice on debugging techniques or code adjustments in XOD would be greatly appreciated.
    I also check this : https://forum.xod.io/t/temperature-sensor-am2302-dht22-not-workingcp But I have not found any solution.

Thanks! :innocent:

Reading through the code for the XOD node, it requires very precise timing. My guess would be that Arduino board gets busy doing something else & that timing gets messed up occasionally. The odds of that happening would increase as you add more timers (like delay nodes, PWM pins, servos, etc.) that generate interrupts.

Do you usually only see one bad reading, then return to normal? You could use average temperature, but that would still be thrown off by these drastically different values. You could write wrapper code that ignores values that are too far from previous value. This will require adding a buffer node to remember the previous value, and NOT updating it if new value too drastic a change from previous value. This requires setting initial value on boot (and hoping that 1st value isn’t a bad one…)

Hello @mini90
I think you should try to find the error