Hello,
I already have 3 switchmote working flawlesly in my house that are 2 or 3 years old ..
Recently I bought a new one for a kitchen light and receive the new version with the new PSU (see the news on discount for them)
I use a basic code to detect a button pressed (after setting the internal pull up)
if ( !digitalRead(pin_bouton) && (millis() - change_state) > 1000 ) {
...
}
And when I'm pluged on the 220V I get false detection of low state .. even with the pullup enable.
There is no false detection when I'm ON the 220V + programer pluged (with the 5V pin disabled)
There is no false detection when I'm NOT on the 220V
I was thinking of a noise/gnd problem ?, maybe related to the new PSU ??
I will have an oscilloscope next week end, I'm planning to take a look on the digital pin to see what's happening ..
Any thoughts ?
ps: I coded a work arround to wait until the button is pressed for a few ms before doing anything.
Would be interesting to do some investigation WRT the PSU. Ie an easy check would be to swap with the old PSU.
BUT I would like to mention the new PSU has more certifications, more safety specs, and includes an internal fuse - no fuse required in the recommended circuit, only MOV (and MOV only at 220V).
In any case if this is a fail point then it should be brought up to RECOM.
A potential solution could be to add more filtering on the DC side. However if the difference is clear between old/new PSU then the PSU can be at fault.
@E.Walker Is there any possibility that a bouncing switch could cause mis-operation? For example, how do you set change_state, could it be stale and so the timeout exits early?
Mark.
I will look at pin D6 signal with an oscilloscope to see what the µC sees
I don't think the switch has anything to do as it is occuring even without the switch :/
When I motinor (using programmer + Serial) the result of the digitalread, there is no problem.
But as soon as I unplug the programmer, it is occuring.
That is why I thought of GND issue.
I'll get the oscilloscope on sunday morning
There is a new version of the PSU coming soon and I will test it as soon as I assemble some.
If you have updates please post here.
Interesting. Just to be clear, you're not turning on the pull-up and immediately reading the input are you? If you are the capacitance of the pin will delay the rise time, you need to add a couple of milliseconds or so to allow the pull-up to reach full potential before reading the input.
I'm dubious this is down to the power supply module, it's not something I'd expect to be a problem.
Mark.
Not really
I have this in the setup
pinMode(pin_bouton, INPUT);digitalWrite(pin_bouton, HIGH); //activate pullup
pinMode(pin_lum, OUTPUT);
Then later in a loop I check
!digitalRead(pin_bouton)
So even if the first read after the setup do not work properly, the next ones should be ok.
The problem occur randomly next without time limit..