Replace Hall sensor with switch in Tuya door/window sensor

georgedb

New Member
Hi all,

I need to alter one of these Tuya door/window sensors. They used to use a reed relay, but all current models seems to use a Hall effect sensor. For my project, I need to replace the reed relay with a real switch (that's easy), but for the door/windows sensor with a Hall sensor, I need to find a solution.

Used is a VCS2373S Hall sensor. It has a Vcc connection and a ground connection and the 3rd pin, I guess, will be some voltage between Vcc (5V? 3V3?) and ground, which will be fed to some integrated microcontroller (unknown type) as a measure of the strength of the magnetic field.



  1. Would the above solution work?
  2. And what would be the difference, other then default high versus default low (things will be solved in the software anyway), when I would swap Vcc and GND in the above?
  3. No resistor needed in the Vcc to uC connection, or maybe only there and not where I currently drew it?
  4. And how to determine the value for the resistor?

Cheers,
George
 
Last edited:
From the datsheet table 8 on page 4 shows that the output can source and sink 10 mA. the output is a change of state rather than a voltage proportional to the magnetic field strength. I doubt that the microcontroller input will require 10 mA so I would choose a pull up / down resistor to pass 10 mA (330 ohms for 3.3 volts 500 ohms for 5 volts.) And the same value resitor in series with the connection with the micro controller. This could provide up to 10 mA when the switch is closed or 5 mA when open. If I was doing the conversion I would break the connection to the existing hall sensor output and measure the current with the door open and closed. That will also tell you if the switch contacts need to go to ground or Vcc.

Les.
 
That is great. Totally different than expected, I'll experiment a bit when I have found the time and report here.
 
That sounds like a perfect solution! We need to see what this solution does to te power consumption. No need for a de bouncing capacitor around the switch, or is that arranged by the microcontroller?
 
That sounds like a perfect solution! We need to see what this solution does to te power consumption. No need for a de bouncing capacitor around the switch, or is that arranged by the microcontroller?

A simple capacitor doesn't provide debouncing, it takes considerably more than that, it's likely the control system already includes debouncing, in either hardware, software, or both.
 
The switch goes to a GPIO (general-purpose input/output) on the microcontroller (mcu).

Power consumption to create a "logic one" is close to zero (I think it might actually be exactly zero to "hold" it). It is usually the case that a microcontroller actually measures whether something is "zero" (ground) or "not-zero" (not-ground) instead of measuring zero/one. Logical "ones" are weaker and more difficult to work with than "zeros".

The switch is a "pull to ground 390ohm resistor" and assumes that there is a built-in pull-up in the mcu. And it works.

Haven't finished testing yet but, there shouldn't be any difference in having the switch "open / broken" in the state you think it will be in most of the time.

De-bouncing is free to do in software and a capacitor costs 0.2 cents, so the Chinese have probably done it in software.

My goal is to try to pry this into the door frame and trigger on the "locking bolt". Going to work in the morning, like a zombie, then later in the day I want to know that I really locked the front door.
 
Last edited:
Regarding hall sensors, when all other possibilities are exhausted, check the data sheet.



There is one direction to which it is primarily sensitive. If the circuit is assembled as in the picture, it is most sensitive to right-left movements. Up down goes too. It says nothing about "Z axis".

This is a common mistake.
 
Sorry, incorrect.

As a technical point, a MOS input on an MCU is pretty much the same as any other CMOS logic gate input, and high or low are symmetrical. Near enough zero current with the input near VDD or VSS, with most power taken during the transition either way.

That's not considering pull up or pull down resistors, internal or external.

Outputs may have lower current capabilities in the high side, due to differences in the P channel vs N channel devices.

TTL device are not symmetrical (>1V for "1" and <0.6V for "0") but even then, high or low are both "active" states - an open input is not valid, it must be driven or have a pullup resistor.

Some devices are designed to be compatible with TTL levels, but high or low are both active states.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…