1
\$\begingroup\$

I am trying to read the temperature sensor in a car with a Raspberry Pi. The temperature sensor's resistance changes as the engine temp increases however the temperature sensor would be in parallel to the voltage divider that runs to the ADC I would read from and since the temperature sensor grounds in the engine block I am unable to read anything after the sensor.

How would I find the resistance of the temperature sensor and read it from the ADC?

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
1
  • 1
    \$\begingroup\$ As you've drawn it, the ADC is reading the battery voltage ! I assume that you mean the temperature sensor is a thermistor which is entirely likely. Your circuit needs attention. It's not possible to measure temperature as shown. The sensor needs to be part of a voltage divider. \$\endgroup\$ – Graham Stevenson Oct 11 '20 at 0:01
1
\$\begingroup\$

Your ADC is monitoring the battery voltage. Your temperature sensor just passes current from the battery to ground. The amount of current will vary with the temperature.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Set R1 approximately equal to R3.

The output voltage will be given by \$ V_{out} = 3.3 \frac {R_3}{R_1 + R_3} \$.

\$\endgroup\$
3
  • \$\begingroup\$ I think you have 3v3 in the wrong place; in practical terms that would be the maximum desired output, not the input. \$\endgroup\$ – Chris Stratton Oct 10 '20 at 16:46
  • \$\begingroup\$ Thank you transistor. This is actually very similar to the circuit I already have that works. What I was hoping to achieve was be able to read the analog gauge as well as the digital input simultaneously. However it seems that I cannot do both so I will most likely add a switch to go between the analog and digital gauges so I can look at either one. Thank you for the help. \$\endgroup\$ – Nate Oct 11 '20 at 4:44
  • \$\begingroup\$ Thanks for accepting my answer, @Nate, but I'm not sure that it's much use to you. If your original circuit is showing a car's temperature sensor then it seems to be missing the temperature gauge. As it is now it's just showing a sensor connected between the battery and ground so it's just a heater! Can you clarify? You can unaccept then to encourage better answers. \$\endgroup\$ – Transistor Oct 11 '20 at 8:53
0
\$\begingroup\$

In simple terms, your voltage divider is connected in the wrong place, so you are measuring the supply, and not the sensor output.

So conceptually speaking, you need to connect the ADC to the sensor output.

No Raspberry Pi itself has an ADC, so whatever ADC you use will be an add-on board. One very "black box thinking" solution would be to simply by a USB data aquisition system. More likely however you are using some SPI or I2C ADC chip on a breakout board/module.

Let's assume your ADC has either a 5v or 3.3v input maximum.

Given the relatively low impedance of the sensor as you depict it, you could probably connect the voltage divider directly to the sensor output, and the load of the divider wouldn't matter much. Only automative electrical environments are notoriously nasty - you get noise and spikes during operation, and it's not unheard for a car to be jump started with 24 volts, which could mean getting twice the designed input voltage. So you'll probably need some clamps for the voltage.

If you wish to avoid loading the sensor with the voltage divider (especially if something in the car is already reading it) then you may want to consider using an op-amp as a buffer amplifier first, and have that feed the the voltage divider. There are IC's marketed as being particularly suitable for the concerns of automative applications which you might consider.

Finally, two additional thoughts:

First a pi is a relatively delicate system needing steady quiet power. Depending on your needs, something simpler and more robust like an Arduino, ESP8266 or ESP32, etc might be a better fit, and these actually have their own ADC already.

The other is that in a modern vehicle, that sensor is probably already being read, and you might be able to obtain it via a CAN bus, OBD-II or similar...


If the temperature sensor is not an original part of the vehicle, then you should probably just get your own sensor more compatible with the pi, either an analog one and feed it from the same lower voltage supply, or perhaps a digital one such as a one-wire type sensor (though beware many of those on ecommerce sites are fakes that are only partially functional with software changes)

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the explanation Chris. I am using an add on ADC, ADS1115. What I am trying to do is modernize a 1976 jeep. I am using a raspberry pi over Arduino because I am using it as a web server so I can connect to the pi with any wifi enabled device minimizing the need for a permanent display. Thank you for mentioning the clamps I will look into that for sure as I want to do my best to protect my pi. I am also aware of the noise but am unsure how to tackle it at this point but will most likely be asking some questions here if they haven't already been asked and answered. \$\endgroup\$ – Nate Oct 11 '20 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.