Ground Problems?

I'm fairly new to the Arduino, but I am quickly learning the ropes. However, I have run into a problem that I can't figure out. I am using my arduino to give readouts on the sensors in my pre OBDII vehicle (1988). Specifically oil temperature, oil pressure, coolant temperature, and battery voltage. The problem is that the oil temperature and coolant temperature are single pole thermistors.

Originally power came into the terminal on top, and the sensor was grounded through the block/head. I have figured out a way to read them by powering the pole and using a ring terminal with both ground and analog input wires crimped into it. When I bench tested both sensors with this circuit I got accurate readings, however, when I screwed both into the engine I get some interesting results.

When I power the arduino over usb from my laptop I seem to get correct readings, but both coolant and oil temps are the exact same values when they shouldn't be. Now comes the really weird part; when I power the arduino over usb from a 12v to 5v converter wired into the car, on the LCD screen the output for both oil/water temps is -495F, and never changes.

I am thinking it is a grounding issue or something of the sort because when I put my multimeter in beep mode and touch the leads to each of the ground wires going to the temp sensors it beeps. The same happens for the analog input wires. The only idea I have come up with is that I need to somehow isolate those circuits but I am not sure how.

You need to run a shielded connection with ground lead to the sensor, and isolate the Arduino as completely as possible from the rest of the automotive circuitry.

The electrical environment in an automobile is extremely harsh and unless you take proper precautions to protect your circuitry, you stand a good chance of it being destroyed. Here is one application note, google for many others.

jremington: You need to run a shielded connection with ground lead to the sensor, and isolate the Arduino as completely as possible from the rest of the automotive circuitry.

How do I shield it when the sensor itself if grounded to the cylinder head, as well as the ground sensor?

A good approach is to use two conductor twisted pair shielded cable, with the two conductors connected to the sensor and the cable shield connected to the Arduino ground. You will need voltage spike protection on the Arduino input.

Do NOT connect the Arduino ground to anything else in the auto or you will have ground loops (the Arduino would have to be battery powered).

jremington: A good approach is to use two conductor twisted pair shielded cable, with the two conductors connected to the sensor and the cable shield connected to the Arduino ground. You will need voltage spike protection on the Arduino input.

Do NOT connect the Arduino ground to anything else in the auto or you will have ground loops (the Arduino would have to be battery powered).

I think you missed the point about the sensor having one side grounded to the engine. Fair enough for the shield as it only grounds at the Arduino end but the sensor with 2 cables as you suggested must have one end at auto ground and then this also becomes Arduino ground and hence introduction of noise etc. which must be avoided.

bluejets: I think you missed the point about the sensor having one side grounded to the engine.

Yes. The problem I am having is because of the sensor being grounded to the engine.

bluejets: Fair enough for the shield as it only grounds at the Arduino end but the sensor with 2 cables as you suggested must have one end at auto ground and then this also becomes Arduino ground and hence introduction of noise etc. which must be avoided.

I also added an oil pressure sensor to the engine, which is connected to the arduino with +5v, ground, and signal wire. No part of the sensor is connected to the vehicle electrical system, and the sensor seems to be functioning properly. Is there any way I can take my current temperature sensors and do the same with them because unattached from the car the sensor read the temperature properly?

You require a good mechanical contact with the engine block to transfer the heat for the sensor to measure.

The design of your temp sensor cannot be changed.

You could however use a different sensor such as an LM335. This would avoid the "common earth" problem.

Some may even be available as a "module" for Arduino from Ebay at a relatively low cost compared to your current temperature sensor. Take a short tab of metal from the block to your sensor to mount it. Use a sensor similar to your oil pressure, i.e. +5, neg, and signal wire with the body of the sensor being plastic type material, hence isolated from ground.

Choice would need to take into account the temperature involved naturally.

Either the above or a thermocouple and interface.

Maybe something like this ..... http://www.ebay.com.au/itm/Hot-Competitive-New-MAX6675-Module-K-Type-Thermocouple-Sensor-for-Arduino-/201405391261?hash=item2ee4b2619d:g:wfgAAOSw~gRVyUys

the 2 cables as you suggested must have one end at auto ground and then this also becomes Arduino ground

No, for anything other than D.C., it doesn't.

The suggested internal twisted pair introduces inductance and capacitance with respect to the Arduino ground, which reduces high frequency noise coupled from the connection at the engine block.

It is best to avoid grounded sensors.

A lot of "advice" is being given without asking what the sensor resistances are over the temp range. And the value of the pullup resistors used. Didn't see the code, diagram or picture either.

I assume if you use the full A/D range, some ground voltage difference will have little impact on the temperature readout.

-495F must be more than a ground problem. Leo..

jremington: No, for anything other than D.C., it doesn't.

The suggested internal twisted pair introduces inductance and capacitance with respect to the Arduino ground, which reduces high frequency noise coupled from the connection at the engine block.

It is best to avoid grounded sensors.

The Op showed a sensor and that sensor has one connection on top and the other is ground via the engine block. In between is the resistance that varies with temperature change.

If 2 wires are run to this sensor as you say then one must be the ground and the other monitors the resistance change.

Last time I looked, these sensors operate on DC.

You get it wired wrongly, you need to wired in this way

+5v to resistor to the terminal on top and to A0 analog input.

I am trying to read the coolant temperature sensor(thermistor) in my car. I have my arduino powered over USB from a 12v to 5v voltage regulator connected to the car battery. When the car is off the sensor reads properly, but as soon as I turn the car on the reading all of a sudden increases anywhere from 12-20 degrees. I can’t power the arduino through a laptop or wall adapter because the arduino and sensor share a common ground with the car battery. Any help would be greatly appreciated as I have been tearing my hair out trying to solve this problem.

shawkur16v: I can't power the arduino through a laptop or wall adapter because the arduino and sensor share a common ground with the car battery.

I imagine there's likely a solution without using a laptop of wall adapter but I don't understand your aversion to sharing the ground of one of these devices with the car battery's ground. It's very common to share ground connections this way.

Edit: Nevermind. I see sharing the ground causes noise. Good luck.

Please do not cross-post. Threads merged.

post#8 What is the sensor's resistance at room temp and operating temp (nothing else connected). What is the value of the pullup resistor. Post the code. Leo..

Wawa:
post#8
What is the sensor’s resistance at room temp and operating temp (nothing else connected).
What is the value of the pullup resistor.
Post the code.
Leo…

The sensors resistance at room temp (20c right now) is approximately 1000 ohms. My meter bounces around between 980-1000 depending on how I hold it. The pullup resistor is 1k ohms. I am working on a schematic now. As I have mentioned before, when the arduino is powered from my laptop, or my car with it not running the readings are +/- 2F of the readings I get on a thermometer. It is only when I turn the car on that the readings jump up about 10F.

#include <LiquidCrystal.h>
#include <math.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int oilTemp,  waterTemp;

void setup()
{
   lcd.begin(16, 2);       //// set up the LCD's number of columns and rows:
}
void loop()
{

   //OIL TEMPERATURE
   oilTemp = ThermistorF(analogRead(A0));
   //OIL TEMPERATURE END

   //WATER TEMP
   //waterTemp = ThermistorF(analogRead(A5));
   //WATER TEMP END
   
    
  lcd.setCursor(0,0);
  lcd.print("OIL:" + (String) oilTemp + " " + (String) analogRead(A0) + "RAW");
  lcd.setCursor(0,1);
  //lcd.print("H20:" + (String) waterTemp + " " + (String) analogRead(A5) + "RAW");
  
  delay(1000);
  lcd.clear();

}

double ThermistorF(int input) {
 double temperature;
 temperature = log(1000.0/((1024.0/input-1))); 
 temperature = 1 / (.001678469668 + (.0002198296536 + (.0000006499155079 * temperature * temperature ))* temperature );
 temperature = temperature - 273.15;          
 temperature = (temperature * 9.0)/ 5.0 + 32.0; 
 return temperature;
}

What is the value of the pullup resistor. I assume it's a 1k resistor, connected to 5volt. And the sensor is an NTC (lower resistance with rising temp).

Try this: Remove the pullup resistor, and use a 2k2 pullup resistor between +3.3volt and the sensor. Add this line of code in the setup: analogReference(INTERNAL);

You should now have a higher RAW value that is not depending on supply anymore.

The code that dsplays the temp has to be adjusted. Leo..

Wawa: What is the value of the pullup resistor. I assume it's a 1k resistor, connected to 5volt.

Yes the pullup resistor is 1k.

The circuit is wired as so: +5v wire with 1k resistor is series. After the resistor I spliced in a wire to go to the analog pin, and the +5v wire goes to the sensor, which is screwed into the engine block, which also grounds it.

Wawa: And the sensor is an NTC (lower resistance with rising temp).

Correct it is an NTC thermistor

Wawa: Try this: Remove the pullup resistor, and use a 2k2 pullup resistor between +3.3volt and the sensor. Add this line of code in the setup: analogReference(INTERNAL);

You should now have a higher RAW value that is not depending on supply anymore.

The code that dsplays the temp has to be adjusted. Leo..

I will have to get a 2.2k ohm resistor.

Could you explain how changing the resistor and making the analogReference call will help?

shawkur16v:
Could you explain how changing the resistor and making the analogReference call will help?

The resistor and the sensor make up a voltage divider, with the center connected to the analogue input.
The divider (pullup resistor) is connected to 5volt.
That 5volt rail could come from different sources (USB, onboard regulator), and is potentially unstable.
The 3.3volt pin is less affected by this (second layer) , so a better point to supply the voltage divider with.

The A/D measures the voltage from the sensor using a reference voltage.
That is normally (the unstable) 5volt rail.

Arduinos also have an inbuild ~1.1volt reference voltage.
You have to call this in setup (the line of code).
That makes the measuring system also independent of supply voltage.

The value of the pullup resistor has to be choosen so that the voltage of the divider falls below the reference voltage at all times (temps).
2k2 pullup and 1k sensor, supplied from 3.3volt is <=1volt.

You could try 2x1k in series, but that would give ~1.1volt when the sensor is cold.
That could give an A/D value of 1023 (overflow) when the sensor temp falls below ~30C.
Leo…

So I put a 2k2 resistor in series (I did change my code), and moved the positive wire from +5v to +3.3v. I also added analogReference(INTERNAL) to setup. The output is now -459 no matter what. I commented out the analogReference line to see what would happen and it started reading the correct temperature. Am I doing something wrong?