DS1820 outputs 85C only when heating pad is connected and write value is not 255

Hello, beginner here. I am trying to use a DS1820 temperature sensor, which works fine by itself, but when I connect a heating pad which I need for my project, it only outputs 85C. When I disconnect the heating pad the readings are normal, and when I replace the heating pad with an LED, the readings are also normal. I also noticed that the readings are normal when the analogWrite() value is set to 255, but are 85C if its not 255 (like in the code).
I have used the heating pad in this circuit configuration with a TMP36 in the past and it worked fine with non-255 analogWrite() values...

From reading other posts, this seems to be a communication issue, but I’m assuming it stems from some type of electrical or PWM issue?

I have attempted to make a schematic but bear with me. Note that the temperature sensor is a DS1820 and instead of the bulb it is the heating pad (Sparkfun heating pad). The transistor is a MOSFET IRF520. The board is an Arduino Uno.

Here is the tester code I’ve been using:

#include <PID_v1.h>
#include <OneWire.h>
#include <DallasTemperature.h>

const int tempPin = 4;
const int gatePin = 10;
double temperatureC;
double tempReading;

OneWire oneWire(tempPin);
DallasTemperature sensors(&oneWire);

void setup(void) {

  pinMode(tempPin, INPUT);
  pinMode(gatePin, OUTPUT);
  Serial.begin(9600);
  sensors.begin();
}
void loop(void) {
  sensors.requestTemperatures();
  analogWrite(gatePin, 150);
  temperatureC = sensors.getTempCByIndex(0);

  Serial.print("celsius:");
  Serial.println(temperatureC);
}

Any help would be appreciated. Thanks!

Welcome to the forum.

To understand your project, I would like to know what you have. Which Sparkfun heating pad to you have: https://www.sparkfun.com/categories/tags/heating-pad

Your heating pad is an antenna which your feed with a nasty pulses (the PWM signal). It can overrule the 1-Wire bus easily.

Do you have a "logic level" mosfet ? The IRF520 needs 9V or 10V at the gate and the Arduino Uno only has a output level of 5V from a pin.

Where did you buy the DS18B20 ? Did you know you your DS18B20 is counterfeit ?

What are you heating ?
If that is a large metal mass, then you can turn off the heating to measure the temperature.

What is your power supply and how is it connected ?

The wires (GND, 5V, data) to the DS18B20 should be used carefully. Don't use one of those wires for something else. They should go directly from the Arduino board to the DS18B20. If you have a single GND wire to a breadboard, and from the breadboard to both the heating pad and the DS18B20, then it will not work.

Can you show a photo of your project ? Perhaps you share a GND wire or perhaps there are wires next to each other.

Can you wrap your DS18B20 with its wires in copper foil ?

This is how is often is on this forum. You ask a simple question, and we like to know much more, and we see many more possible problems. Just hang on, it should be possible to make it work.

1 Like

Thanks for the response! Connecting the DS1820 directly to GND fixed it. Not sure why I didn't try that earlier

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.