0
\$\begingroup\$

I'm designing a zigbee switch with additional capabilities in order to give it some flexibility. The main idea is to put this design in the interconection boxes that are in my walls.

So, this PCB will be in a constantly noisy environment because the 220V AC cables around the PCB.

I want to reuse my wall switches rewiring the common to the 5V power supply of the board in order to convert these switches in digital inputs for the microcontroller, so if somebody changes the switch, the microcontroller can read the new status and change the output relay that is controlling the lights, wall plugs or whatever.

The problem is that some wall switches could be around 30 meter from the wall interconection boxes and can be near of power cables with 220V AC.

The power supply of the control electronics is an in-board AC/DC converter whose output is 5V and 3.3V DC and this is the reason the digital signal have to be in that values.

I don't want to change the 2.5mm copper cables that connects the lights with the switches.

Can be reliable this circuit with these characteristics or should I change the design in some point?

I have read in other topics that it can be done with an optocoupler, some capacitors and zener/schotkky diodes but them can change the wires for twisted pair or whatever in their design but this is not my case.

Edit: Simplified Circuit for clearance:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ your English is very good, don't worry about it. \$\endgroup\$ – Marcus Müller Apr 3 at 9:08
  • \$\begingroup\$ Can you be clear about what your question is? \$\endgroup\$ – Andy aka Apr 3 at 9:10
  • \$\begingroup\$ I want to use a 5V digital signal input for the microcontroller. The problem is the long distance of the 2.5mm cables and the other cables witch 220V AC around it. They could make interferences in the continuous 5V signal I think. The cuestion is that what can I do in order to reduce the interferences in that cables if I can't change the type of cables. \$\endgroup\$ – Bolivicmtb Apr 3 at 9:21
  • \$\begingroup\$ You do not want to be integrating low voltage electronics into your live mains wiring boxes. Common sense and electrical codes should tell you why this is not a good idea. \$\endgroup\$ – Michael Karas Apr 3 at 9:37
  • \$\begingroup\$ The idea is that the power supply for the electronics will be isolated and properly grounded. Also, all the circuitry will be in a plastic box isolating it of possible contacts. I don't see the problem there, if you can explain a little more probably I abandon this idea. \$\endgroup\$ – Bolivicmtb Apr 3 at 9:51
0
\$\begingroup\$

It should be pretty easy to sense a switch being open or not; you'd just measure the current that goes through the switch instead of trying to measure an open-loop voltage.

schematic

simulate this circuit – Schematic created using CircuitLab

R1 is a so-called "pull-up" resistor here. When the switch is open, no current flows through it. And a resistor through which no current flows has no voltage drop, so the "to microcontroller" node is at 5 V-0 V = 5 V.

When the switch is closed, then the "to microcontroller" node is pulled to ground, 0V. Easy to sense!

In the above diagram, I simply connected the switch to ground at the place where the switch is; so, basically, connected one side of the switch to the "neutral" wire, and the other to the wire going to your microcontroller.

That is fine as long as "ground" is the same all over your house. It might not be!

In that case, things are quite a bit harder: you either need to run a second wire back from the switch to the microcontroller and connect to ground there (but that needs two wires per switch, instead of one), or you need to find a way of measuring without relying on common ground.

One way to do that:

schematic

simulate this circuit

With a bit of microcontroller firmware:

  • set the microcontroller pin to "output"
  • set the output to "high" for some time (100 ms, for example)
    • If the switch is closed, this charges the capacitor
  • set the microcontroller pin to "input"
  • measure how long it takes until the pin goes "low".
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The ground is the same in all the house.The first circuit it's fine for me and is the first idea I have but, although I measure current, the noises also exists so, the microcontroller could read some wrong value. I want to avoid a time delay in the input because I want to actuate in the output relay as fast as posible like the light was connected directly to the 220V AC power supply like now. \$\endgroup\$ – Bolivicmtb Apr 3 at 9:43
  • \$\begingroup\$ I promise, you'll find the ground to be non-identical, especially under load, in different parts of your house. If there was no influence of loading nor of EMI on the ground, then there wouldn't be such influence on desired signals, either :) \$\endgroup\$ – Marcus Müller Apr 3 at 10:23
  • \$\begingroup\$ The point is that noise is an AC thing, and has a high source impedance, so that it gets easily shorted to ground by the switch. \$\endgroup\$ – Marcus Müller Apr 3 at 10:24
  • \$\begingroup\$ I edited the post with a schematic of my idea. I don't understand what you say about different grounds. I want to put one of this circuits per interconection box in order to control all the plugs or lights that are connected in these boxes. \$\endgroup\$ – Bolivicmtb Apr 3 at 11:03
  • \$\begingroup\$ so, if you run both directions of wires, this is really easy (my first approach, but the connection from switch to ground happens inside your plastic box). Since you'd be running quite some current (5mA) through that loop, your noise essentially doesn't matter. \$\endgroup\$ – Marcus Müller Apr 3 at 11:09
0
\$\begingroup\$

I read nothing in your question about noise rejection.

One way to do that is with 0.1uf capacitors soldered across the wire (from the remote switch) to the MCU gnd point/region/area on the PCB.

And have two resistors: one is pullup to VDD of the MCU. The other resistor is 10% of the pullup value, installed between MCU/pullup and the remote switch.

Thus 1Kohm and 100 ohm, plus the 0.1uf (often has 104 as the value code on cap package).

As some of the other answers advise, use a separate ground wire for the switch, or your system will mis-behave whenever the water-heater or oven or vacuum cleaner turn on/off.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.