Digital potentiometer for 12v ?

it seems the gauge has a resistance of 80 ohms. According to my test 600 ohms will be the highest resistance I will need.
The average will be about 130 ohms. That is temperature/ohms the engine should work most of the time.

I will test the mosfet. Any of those seems to be ok. Will you recommend one over the others ?

This is the origin of your misunderstanding.
Nothing measures resistance not even a multimeter.
The gauge( and multimeters) measure current.
A multimeter converts that current to a resistance value.
Your gauge converts it to a temperature value.

Are you trying to repair the gauge in a car or use the gauge in a simulated "dashboard"? If the latter, you could use a 5V supply.

No you don't. it more like 0 to 3V
I have two other circuits that will work with an ESP32 using readily avialble through hole components.

So does the CHT go up and down with engine RPM?

I'm not convinced this is true. What is the make/model of the motorcycle. Post a picture of the gauge.

Does the sending unit mount under the spark plug or somewhere else?

Did you determine the resistance necessary to match each temperature marked on the gauge? You need to do that if you want to have any hope of building a circuit to emulate the original sending unit.
Post your results of temperature vs resistance for each needle position on the gauge.

Hello again.
I was testing the gauge and yes. My 12v line can be also a 9v line. All the readings will also change. May be the gauge was a piece of shit and that explain why are so many of them NOS.
May be the sender did some magic ....

For you the more skeptical person in this forum
you can buy the gauge here

this is a real treasure. The last time the sender was seen....

One more question please
How I can calculate the volts I need at the gate to have 600 ohms ??

the math is the same for any of those mosfets right ? (IRF3708 AO3414 SI2300DS)

There was a voltage stabilizer that took care of those fluctuations back in the day. Nowadays you would use a buck-boost converter set to some voltage that works for you.

:smile:

Okay, I thought you said it was a vintage British bike. I live in the US and old Harleys are very common here. I'll just get Harley Davidson on the phone and ask them about the sending unit.
From another post:

You're not understanding how the suggested solution works. You're not trying to make the MOSFET have a particular resistance. You will be turning it on and off via PWM on your controller at a certain rate that makes the average current that it passes be the same as if it was replaced by a resistor. Let's say yo need it to read 175ºC, you might have to turn it on for 40% of the time and of for 60% of the time, very quickly so that the gauge needle doesn't quiver.
This brings up another issue. You haven't figured out what resistance is needed to hit the right temperature ate the middle range. If your gauge was meant to operate with an NTC thermistor, its response is a curve, not a straight line. You need to figure out what that curve is so that you can make the needle point to the correct temperature at temperatures other than 95ºC and 260ºC.

Perhaps the easiest way to do that will be to get a 1k potentiometer and adjust it to the various temperatures and measure its resistance with your multimeter.

Now that I know it's from a Harley, that changes everything. I'd be shocked if it wasn't a Stewart Warner gauge, private labeled for Harley being as Stewart Warner was the major automotive gauge maker of the time. That gives another company besides Harley to ask about a sending unit.
I can walk to the Harley shop where I live. Maybe I'll ask them what the source of the sending unit is.

The mosfets will work just as a switch, open or closed. So, 3.3V => fully open, 0V => closed.

And it will be the same for both solutions: your resistors selector or the PWM signal.
Regardless of what solution you decide to apply, you need the same, open or close the mosfets with some ESP32 pins.

Then for the calculations, I think that you have to follow Emily suggestions. Also for either solution you choose.

It's not controlled by a voltage, it's controlled by a pulse width mudulated signal (PWM), the numbers are specified on the schematic I specified.

Do yoy want a circuit that is controlled by a voltage?
Do you want a circuit that uses easy to solder through components?

@sivi1234
Determining the PWM values that correspond to various temperature marking on you gauge can be done with a circuit like this and the code from an example in the Arduino IDE. I've used a 5V Arduino because it may be simpler for you to find a 5V logic level MOSFET for your initial experiments. I've used 330R resistors in parallel to get you down to a power dissipation of <1/2W each so you can use resistors that are common.

This sketch from the IDE examples will give you a way to match PWM values to temperatures on your gauge.

/*
  Analog input, analog output, serial output

  Reads an analog input pin, maps the result to a range from 0 to 255 and uses
  the result to set the pulse width modulation (PWM) of an output pin.
  Also prints the results to the Serial Monitor.

  The circuit:
  - potentiometer connected to analog pin 0.
    Center pin of the potentiometer goes to the analog pin.
    side pins of the potentiometer go to +5V and ground
  - LED connected from digital pin 9 to ground through 220 ohm resistor

  created 29 Dec. 2008
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogInOutSerial
*/

// These constants won't change. They're used to give names to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9;  // PWM Analog output pin to MOSFET

int sensorValue = 0;  // value read from the pot
int outputValue = 0;  // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the Serial Monitor:
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 1 second before the next loop for the analog-to-digital
  // converter to settle after the last reading:
  delay(1000);
}

Wire this up and run the sketch. Adjust the potentiometer so that you get the gauge needle to move to various places on the dial and notice how the "output =" value changes. This will show you how PWM allows you to simulate a "resistor" in your circuit.
Notice how the "350ºF" mark is a little to the left of exact center of your gauge. This is because the original sensor resistance does not vary linearly over the temperature range and this will have to be accounted for in your final code. In the meantime, build this circuit and play around with it so that you understand the concept.

If you have to use a 3V3 Arduino, this concept can be modified to accommodate that. Tell the group what parts you have on hand and can easily get.

Meanwhile, after breakfast, I'm going to toddle over to the Harley dealer and talk to their technician as I'm sure there is more to learn about this gauge.

Edit: I didn't learn anything new about the gauge but after walking over, I did ride away on a new Softail. jk

Thanks thanks and many thanks guys for all your help
I am curious person. I will test the mosfet to see if that works. The B plan is the multiplexer with a ladder of resistances that seems like a idiots prof solution to me and my little knowledge of this.
First I need stable source of power not only for the electronics but also for the gauge that is sensible to that.
Once I have that I need to make a list of resistances for every temperature I need the gauge to show
The third step will be generating those. Plan A the mosfet . Plan B the multiplexer with a ladder of resistances
Finally I need to read the temperature in the cylinder head and make my vintage gauge to show that.

I should win a prize for doing this in the hardest way. But I will have my vintage motorcycle riding around with a vintage CHT that seems to work but will have a lot of electronic parts hidden somewhere doing the job.

If any of you guys sees someone riding around with some electronics and a multimeter held with tape on the gas tank ... tell him hi .... that will be me

Keep us posted and have fun!

If it doesn't I have several circuits that use readily availabe through hole parts that will

@sivi1234
I noodled up a quick test of this circuit:


to see how well an IRLZ44 would switch with 3V3 logic.
It did well enough for the current you will be switching as it only got warm to the touch. Scope traces, yellow PWM from controller, blue drain of FET.

I recommend you use a thermocouple instead of a thermistor for a sensor. The thermocouples are a lot easier to find than a suitable thermistor and if you use one in a stainless steel sheath like in the picture you can epoxy one into a hole drilled into a brass bolt and attach to the hole in your cooling fin.

I'll include the MicroPython code I used to test to although you'll probably use C++. As you can see, it's pretty simple.

from machine import ADC, Pin, PWM
from time import sleep

Duty_Full_Scale = 65536
CHT = PWM(Pin(14), freq=2000, duty_u16=int(Duty_Full_Scale*0.5)) #50% duty cycle,PMW(A7),Pico pin 19
POT = ADC(Pin(26))     # create ADC object on ADC pin (GPIO26, ADC0)

while True:
    x = POT.read_u16() # read value, 0-65535 across voltage range 0.0v - 3.3v
    print(x)
    CHT.duty_u16(x)    # set the duty cycle of PWM channel A7, range 0-65535
    sleep(2)

You would use code like this to map the PWM duty cycle onto your gauge. I would just map the points that have lines on your gauge plus points halfway between the lines and assume it's linear. It's not but that gauge is so course you won't be able to read the error.

from machine import  Pin, SPI
import math
import struct
from time import sleep

data = bytearray(4) # for 32-bit read from MAX31855

CS = Pin(17, Pin.OUT) # SPI chip sellect, chip pin #22
CS.on() # set /CS High
# CHT_sensor is an ungrounded K-type thermocouple inside a SS probe
CHT_sensor = SPI(0, baudrate=992063, polarity=0, phase=0, bits=8, sck=18, mosi=19, miso=16) #chip pin #24, #25, #21

while True:
    CS.off() # set /CS Low for read
    CHT_sensor.readinto(data)       # read 32 bits into the buffer
    CS.on() # #set /CS High 
    sleep(2)
    print(data)
    hot, cold = struct.unpack(">hh", data)
    cold >>= 4
    hot >>= 2
    C_hot = hot * 0.25
    F_hot = C_hot * 9 / 5 + 32
    C_cold = cold * 0.0625
    F_cold = C_cold * 9 / 5 + 32
    print(C_hot, F_hot, C_cold, F_cold)

The code to read the MAX31855 thermocouple amplifier is simple as well as you don't have to do any setup of the chip, just read it whenever you want an update.
After you map your gauge, you would then write a function to convert measured temperature to PWM duty cycle. We can help you with that when you get there.

This is all just a suggestion and you can obviously do it however you want but it is a hardware version of all the handwaving done here that demonstrates the concept.

I wonder if an analog panel meter is enough of an inductive load to require a flyback diode?

If anyone is still watching.

I have a gauge that Harley gave me and it is indeed a Stewart Warner part # 828499.

Also the full scale current for the gauge is 15 mA, 0.015 A, which doesn't match up with what OP would have delivered with the 12V and resistors they used. Based on this fact, the sensor does not have to handle as much power as thought.


Shot at an angle so the SW part number is visible.
The 600 ohms OP said they used would be about right for full scale but the 50 ohms is completely wrong.

Holy moly xD