How can i connect the water level switch to microcontroller ?

Thread Starter

Rawankhader

Joined Sep 22, 2017
28
Hi all,

I need to use the following water level switch .


80f64752-1e4a-47f4-87fe-c23915aa110c.jpg



Description:

  • Product Name : Float Switch;Max Contact Rating : Max Contact Rating;10W : 10W;Max Switching Voltage : 100V DC
  • Max Switching Current : 0.5A;Max Breakdown Voltage : 220V DC;Max Carry Current : 1.0A;Max Contact Resistance : 100mΩ
  • Temperature Rating : -10 ~ +60 °C / +85 °C;Float Ball Material : PP;Float Body Material : PP;Float Ball Size(Approx) : 24 x 17mm /0.94" x 0.7"(L*D)
  • Thread Dia(Approx) : 16mm/3/8" PT;Hex Nut Diameter : 23mm /0.9";Body Length : 90mm/3.5";Cable Length : 39cm / 15.3"
  • Color : Black;Net Weight : 22g;

I want to use 10k pull up resistor with the switch to connect it with the microcontroller .

The distance between the tank(switch) and the microcontroller 15 m.

Should I modify the connection ?


Thank you .
 

MrChips

Joined Oct 2, 2009
25,930
What microcontroller?
What power is powering the microcontroller?
How much voltage and current do you have available from the power supply that is supplying the microcontroller?

A 10kΩ pull-up might work but it will be susceptible to noise pickup.
A 220Ω ½W resistor would be a better choice.

And you may want to put a filter capacitor across the input of the microcontroller,

and maybe a MOV while you're at it.

Better yet, use an opto-coupler/isolator.
 

MrChips

Joined Oct 2, 2009
25,930
Use a 620Ω ½W resistor in series with an opto-isolator driven from the 12V line.
Then use a 2k-10k pullup on the receiver of the opto-isolator into the PIC input.
 

MrChips

Joined Oct 2, 2009
25,930
The 620Ω value is not carved in stone. Anything from 470Ω to 1kΩ will work fine.

Why opto?
The objective is to keep EMI away from your PIC input. You want the opto close to the PIC.

Water switch = = = = 15m cable = = = = opto / / PIC

Any high voltage spike picked up on 15m cable does not jump across the opto-isolator.
 

Thread Starter

Rawankhader

Joined Sep 22, 2017
28
Thank you :)

Should I denounce the switch or using the opto enough ?

if I use 9v ,7v or 15 v power supply instead of 12v should I modify the circuit ,)
 
Last edited:

MrChips

Joined Oct 2, 2009
25,930
And if I use 9v ,7v or 15 v power supply instead of 12v should I modify the circuit ,)
When you select the opto-isolator, check the data sheet for the max current allowed on the LED. You don't want to exceed the max current.

With 15V supply , 680Ω series resistor would give about 20mA.
You have a lot of leeway with anything from 680Ω to 1000Ω for any supply voltage from 7V to 15V.
 
Top