Touch Sensor Switch, am I going crazy?

Ok, so after chasing my tail for over 2 days I finally found out the issue, well where the issue is. After many many rebuilds and reloading Hassio this is what I finally noticed.

I am making a poor mans version of a sonoff switch. I am using esp8266 and touch sensors. I created my own USB male plugs with only positive and negative connected.

Here is the problem. When I connect my set up to my laptop USB EVERYTHING works as expected, mainly the touch sensor switch (set to switchmode 5). If I measure the volts going in I get 5.02 plus or minus a few .01’s. The touch sensor is connected to the 3.3 V output, and it reads right at that, plus or minus a couple of .01’s.

Ok, so since it is working correctly with the USB plugged in to my laptop I figured I could install. BUT when I connect it to a USB power plug (the ones used to charge cell phone with 5v 1Amp) the touch sensor stops working. At times it doesn’t work at all, at times once my finger gets about 1cm it starts working or flickering, then stops working all together. Other times it just doesn’t work at all.

I measured Volts, and when using the wall USB adapter I get 5.20 volts, plus or minus a couple .01’s, and the volts going to the button are the same as when plugged in to a computer, about 3.3 plus minus a couple of .01s

The little I know about circuits and electronics (which is very little) this doesn’t make any sense! If someone came to me with the same issue I would have bet them money that there was something else causing the issue, but since I am the one that ran into the issue I am 100% sure there are no other variables.

If I plug my set up to my laptop everything works 100%, (again the male USB plug I am using is only connected to the left and to the right most pins, it is getting no input what so over from the laptop via rx/tx). When I unplug from the laptops port and connect it to a USB wall charger the issues with the touch sensor start.

Does anyone have any idea of why this might be? And better yet, does anyone have any ideas on how I can correct the issue? Everything else works just fine, I just can’t use the physical touch sensor to turn on/off the relay.

Thanks in advance for any and all help!

Might be something to do with the capacitive touch sensor requiring a ground reference and the wall adaptor being isolated. Does it work if you unplug the laptop and use it on the laptop battery only?

Tom thank you. Seems I won’t be going to be soon after all since I am now working on the advice you gave me on other post.

I haven’t tried with laptop running on battery only. Remember I know little, almost nothing about electronics and electricity, but the power cord to the laptop isn’t grounded either, so not sure what the difference would be running laptop off battery only vs of adapter, but will give it a try.

Ok, so I just unplugged the power from the laptop so that it was running on battery only and it did work as expected.

My issue doesn’t make much sense does it?

I’d be betting on switchmode power supply noise from that wall adaptor interfering with the touch detection circuit then. Do you have another wall adaptor (maybe a big old linear power adaptor with a transformer) you could try?

I will try with a different usb power adapter tomorrow. I just bought about 15 of the same USB power adapters, would suck if they don’t work. Is the noise from the wall adapter something I could fix with debouncing? (Also, like you I always spelled it as adaptor, but seems the spell check says it is adapter… not sure if they are the same word, is adaptor the correct term?)

If it is a noise problem with your wall adaptors it should be easy enough to filter out with a small passive filter (couple of inductors and a capacitor). Because the switchmode switching noise spikes have very high frequency components we can use quite small value inductors and capacitors.

Adaptor/adapter is regional spelling. Either can be used when referring to a device that adapts one thing to another.

Well today I did try with different USB wall adaptor (a real one from Samsung) and this time it did work just fine as well. Seems the USB adaptors I purchased on the cheap have too much noise problems.

I did a very quick search on small passive filters and it seems that is way way above my skills level. Seems will be easier for me to purchase different USB adaptors

so if I change from touch sensors to regular two post push button, with signal line pulled to ground with a resistor should I be ok, or would the noise also affect an actual push button?

A regular push button will not be affected by the noise.

Try this fliter, the values are a guess but it has a pretty low cut off frequency so should work:

This will not filter common mode noise very well though, only transverse. Creating some coupling between the two inductors by winding wire on a toroidal ferrite would be better, but see if this works first as it is simple to build with off the shelf components. If you know how much current your circuit draws you can lower the current rating of the inductors. They are available as ‘RF chokes’ at most electronics hobby stores.

Tom, thank you so much! Talk about a picture is worth over a thousand words! When you put it like that, man that is EASY! I can do that no problem :wink:

In Cancun we don’t have a real electronics store, Stern is the closest thing we have. They do have the capacitors for less than 20 cents each, but no inductors. Seems no one carries inductors like that locally.

Thankfully we also have MercadoLibre, ebays version in Mexico. I am getting 20 of them for about $3.50 but paying an extra $5 for shipping. Oh well, still cheaper than getting either new switches or new power supplies :slight_smile:

Also, if you wouldn’t mind answering another question for me since you seem to know circuits and electricity well. If down the road I want to change ceiling bulbs that run on 110v AC to LEDs that run on DC, could I be lazy and use the wiring, or would the tickness of the cable might create an issue, and I should take the time to rewire with proper size cable? (And what would be the proper size)

That’s a question for an electrician. I’m an electronics technician. There may be rules and regulations I am not aware of.

But as a rule of thumb, check the AC circuit breaker or fuse current for the light circuit. As long as the total current from your LEDs does not exceed this (current per light = watts per light / light voltage) you should be good. Note that the current interrupt rating for circuit breakers is a lot less for DC than AC, so while this should be ok to judge the wire current carrying capacity you may need to replace the circuit breakers with ones rated for the DC current.

Really you should ask an electrician.

Good luck with the filters. Let me know how it goes.

Try just one 0.1 uf capacitor. It might be just enough.

1 Like

You mean one capacitor and the two inductors, or literally just one .1 uf capacitor.

Just the one capacitor across the power.

Thank you tom. I will be experimenting soon. If only single capacitor doesn’t do the trick I will try your suggestion. Now just to make sure I don’t do anything I re great, if I do use the two Inductors as you showed me, can I try the same setup but with only one capacitor, or if I use the two inductors I have to use the capcitors as well?

Also, I am assuming that all this happens on the 5v line, after it has come out of the USB adaptor correct?

You would need an oscilloscope to see what the output voltage looks like. I am guessing, from experience, that it’s a semi-square wave with transient spikes.This is what you see in poorly designed supplies. It would work just fine if all you’re doing is charging a battery (because to the electrons, the battery just looks like a very large capacitor). The two-capacitors with two inductors is maximum effort and will clean up just about any power supply, but sine it’s easier to get the capacitors, then it’s the quickest and easiest thing to test. The value is not critical. It can be 0.1uf or 0.5uf or anything in-between.

Of course, with the original Sonoff Basic for $5 (US) there’s no such thing as a cheap Sonoff knockoff.

Here’s a tutorial from someone who made a capacitive touch switch from a Sonoff Basic and two cheap touch buttons: https://www.youtube.com/watch?v=WsatPkC2Hf0

I built one without the PIR detector. I just hot-glued the touch switches to a blank panel. (https://www.amazon.com/Decora-Faceplate-Blank-Insert-White/dp/B000BSJJ6C/ref=sr_1_189?ie=UTF8&qid=1546295959&sr=8-189&keywords=decora+face+plates).

Stevamann thank you for your suggestions. I see what you mean now regarding the poor man’s sonoff. I am relatively new to this, and for some reason I assumed sonoff was something I had to purchase via amazon or similar. Here in Mexico, the cheapest IoT sold on Amazon Mexico is about $15 USD.

After your post I did check with Ali express, (where I got my esp8266s from to begin with), and did find that they do offer the sonoffs for about $5 a pop.

I was proud that I could make my poor man’s switch for about 100 pesos (about $5). $2.10 for the esp8266, $.50 for one channel relay, $1.80 for the usb power adaptor, so that is about $4.40 plus there is also the couple of strips of wire, the connectors, etc. All in all you are right, doesn’t make sense for me to make my own switches from scratch.

Except- look at all you learned.

1 Like

Well I did find a .1uf capacitor I had at home and it seems a “single” capacitor didn’t do the trick. Will have to wait for the inductors to come.