0

I have a case type 12 V 3-pin fan and I would like to connect its tach signal wire to an ESP32 input pin. Power supplies to ESP32 and the fan are separate, but the ground wire is common.

Based on some posts in google, internally the tach wire gets connected to ground wire twice during each fan rotation cycle. If it is that simple, should I just connect this wire to an ESP32 input pin and have a pull up resistor connected to 3.3 V? If so, what is the minimal reliable current or range the resistor should be calculated for - is it 12 mA or less? Or can the ESP32 pin be configured to use an internal pull-up resistor so the external resistor is not required?

ocrdu
  • 9,195
  • 22
  • 32
  • 42
Serge
  • 1
  • 1
  • yeah, setting the gpio to INPUT_PULLUP should work to read open collector outputs. I would make sure that there's not ever 12v on the signal before connecting it to an esp, just in case the fan isn't like what you read or described. If it is 12v pulses, use a voltage divider to chip that to 3v, and set the GPIO as a normal INPUT – dandavis Jan 22 '23 at 08:56
  • Read the answers to https://electronics.stackexchange.com/questions/69613/how-to-read-rpm-from-3-wire-fan-pic18f4550; the easiest solution is a resistor and a diode to ensure you don't get 12V on your ESP32. – Paul Jan 24 '23 at 15:32
  • @dandavis. Kind of same question with regards to the voltage divider - should there be some current consideration? For example, to get 3 / 12 division, I can use 3K + 9K resistors, but I can also use 3M + 9M resistors? – Serge Jan 29 '23 at 03:18
  • targeting 1ma should suffice. Use INPUT instead of INPUT_PULLUP in that case. – dandavis Jan 29 '23 at 06:18
  • @Paul. Being a person with some theoretical knowledge and virtually no practice, I found that solution elegant. But it helped me realize that, while I have some idea how to calculate resistors to connect MCU output pin to a transistor using load current, transistor current gain and Ohm's law, I have no idea how to calculate resistors for MCU input pin. That schematic shows 10K pullup resistor connected to the MCU's input pin, which should mean about: (5V - 0.6V) / 10K = 0.00044mA. – Serge Jan 30 '23 at 01:13
  • This raises a question what is the minimal current for the MCU's input pin to consider a logical "1"? Bases on some google results, "ESP32’s pins can source 40mA and sink 28mA current" [Some other results say 12mA], but I assumed those are for output pins? And these number are not even close to the 0.00044mA, calculated above. Is there a spec/formula how to calculate that? – Serge Jan 30 '23 at 01:14
  • @Serge your calculation is off, 4.4V/10K is 0.44 mA which is plenty for any GPIO. Lower resistor values are useful if you have very high frequencies, as the parasitic capacitance starts playing a role. In your case, don't worry about it, 10K is fine. – Paul Jan 31 '23 at 08:16
  • Thank you @Paul. One of the specs for ESP32 is: "IIH High-level input current - - 50 nA". I could not believe it is so small so I thought I did not understand what this spec means, but does it sound like the threshold value we are talking about? – Serge Feb 01 '23 at 15:41
  • Yes, in the static case. With that kind of current, a small parasitic capacitance can easily become a problem, so it is sensible to use a pull-down or pull-up that carries a lot more than that - in your case, 0.1 mA would be sufficient, and 0.44 mA is plenty. Note that the internal pull-up/pull-down resistors are 45k, which is good enough for most applications. – Paul Feb 06 '23 at 14:53
  • @Paul, that makes sense and good to know. Than you – Serge Feb 07 '23 at 21:17

1 Answers1

0

I don't have practical experience with the fan you're referring to but if what you say is correct, connect a multimeter to the tach o/p and gnd on the fan and power it up. If it uses an active internal pulse o/p you should see an AC signal on the tach o/p pin. https://www.petervis.com/electronics%20guides/cpu%20fan%20tacho/cpu%20fan%20tacho%20schematic.html Follow the link above.

If you have an oscilloscope, you will be able to see the signal, of course. For a simple answer to the resistor value, look at the sink current for the ESP i/p pins. Work on that current and use the fan supply voltage for a safe resistor value.

donaldD
  • 1
  • 1
  • It looks like all messages here are that most fans will not have the tach wire just connected to ground as the fan rotates, but may supply some voltage so the input pin requires some protection. I also saw some mentioned hall sensor used. I have a few fans and I should be able to check them with oscilloscope. – Serge Jan 29 '23 at 03:21