Page 1 of 1
Door control not working propperly
Posted: 15 Jun 2021, 08:32
by xxx_turbo_xxx
Hi everybody,
I have a problem which is driving me crazy! I have a "chicken house" with an automated door. It is pretty simple but for whatever reason it does noct work reliable!
- Huehnerklappe_Schema.JPG (55.51 KiB) Viewed 11977 times
Code:
Code: Select all
// 0=aktiv, 1=inaktiv
On System#Boot do
GPIO,3,1 // G3: Taster_Stopp aus
GPIO,12,1 // G12: Taster_auf aus
GPIO,13,1 // G13: Taster_zu aus
GPIO,14,1 // G14: Reed_oben aus
GPIO,2,1 // G2: Reed_unten aus
Endon
On Taster_auf#State=0 Do
if [Reed_oben#State]=0
WemosMotorShieldCMD,0,Brake
else
WemosMotorShieldCMD,0,Forward,50
endif
EndOn
On Taster_zu#State=0 Do
if [Reed_unten#State]=0
WemosMotorShieldCMD,0,Brake
else
WemosMotorShieldCMD,0,Backward,30
EndOn
On Clock#Time=All,%sunrise% do // Klappe auf bei Sonnenaufgang
if [Reed_oben#State]=0
WemosMotorShieldCMD,0,Brake
else
WemosMotorShieldCMD,0,Forward,50
endif
EndOn
On Clock#Time=All,21:30 do // Klappe zu bei 21:30
if [Reed_unten#State]=0
WemosMotorShieldCMD,0,Brake
else
WemosMotorShieldCMD,0,Backward,30
EndOn
On Taster_Stopp#State=0 Do
WemosMotorShieldCMD,0,Brake
EndOn
On Reed_oben#State=0 Do
WemosMotorShieldCMD,0,Brake
EndOn
On Reed_unten#State=0 Do
WemosMotorShieldCMD,0,Brake
EndOn
- Huehnerklappe_Hardware.JPG (155.34 KiB) Viewed 11977 times
- Reed.JPG (36.88 KiB) Viewed 11977 times
It looks likt that the reed sensor starts to toggle from 0 to 1 at one stage and this leads the system to freeze/crash. No matter which butten I press then the system does not respond anymore! What di I miss in my code or is there some other error?
Re: Door control not working propperly
Posted: 15 Jun 2021, 09:03
by TD-er
I don't see a time scale on your chart, so it is hard to tell in what order of magnitude the switching frequency is.
Reed switches are not only reacting to a magnetic field, but also to mechanical vibration.
Apart from mechanical vibration, you may also pick up noise via the wires to the switch.
A few things you can do to limit the effect of noise:
- Twist the wires, just like is done in pairs in UTP network cable
- Increase the current through the switch by lowering the pull-up resistor value.
- Add some capacitor over the GPIO pin and the ground
With a high resistance pull-up resistor, you don't need a lot of energy to switch the logic state due to noise.
I would suggest something like 1k - 3k3 so you have a current of 3 ... 1 mA at 3.3V
The wires act as an antenna. By twisting the wires you reduce the effect of noise as noise induced signal picked up on one part of the wire is inverted at the next twist.
Adding a small capacitor at the ESP side you introduce some kind of delay in the signal. Thus very short pulses cannot increase the voltage fast enough to switch states.
I would start with somethig like 10 nF, but the value also depends on the used pull-up resistor.
Re: Door control not working propperly
Posted: 15 Jun 2021, 10:01
by xxx_turbo_xxx
Thanks for your quick reply! Reading your answer I would guess the problem might be caused by the fact that I did not install any resistors (due to missing knowledge). My layout looks like this. I havent found the wemos motor shield in the library but I hope you can understand it anyway!
- shematics.JPG (118.82 KiB) Viewed 11970 times
Here the komponents I use...
- Taster.jpg (3.88 KiB) Viewed 11970 times
- Reed_.jpg (4.87 KiB) Viewed 11970 times
- D1Z_MOTODRIVER_01.jpg (32.24 KiB) Viewed 11970 times
The buttons and reed contacts are configured like this...
- Taster_config.JPG (74.69 KiB) Viewed 11970 times
Do I need to insert some restistors?
Re: Door control not working propperly
Posted: 15 Jun 2021, 10:04
by xxx_turbo_xxx
Forgot to mention that dte toggle between 0 and 1 from the reed is approximately within 15 zo 20 sec.
Re: Door control not working propperly
Posted: 15 Jun 2021, 10:19
by Micha_he
First, I would enable the "Internal PullUp", if you didn't use extenal pullup's. Otherwise the signal floats somewhere between 0 and 3.3V.
In a second step, you can set the debounce time to about 100-300ms. If this not help and a little (~500ms) delay is exceptable, than you can set the "Longpress interval" to 500ms and use the longpress-events (10/11) to react in the rules.
Re: Door control not working propperly
Posted: 15 Jun 2021, 10:25
by TD-er
You should not use GPIO-15 for this switch as that pin needs to be in a specific state during boot.
So better use other pins.
GPIO-0, -2 and -15 are special as they need a specific state at boot.
You can first try to check the "Internal PullUp" checkbox in the settings, but those only can pull up slightly as the internal pull-up resistors are between 50k - 80k
Better use 10k (or 12k), the value doesn't matter a lot.
But 12k is used on most ESP boards as typical pull-up for GPIO-0 and -2.
Maybe on longer cables you may need to get lower pull-up resistors, but let's start first with the 10k-ish ones.
Re: Door control not working propperly
Posted: 16 Jun 2021, 07:46
by xxx_turbo_xxx
So it looks like it stays stable either on 1 or on 0! Thanks for your help so far...
But...
I recognised a second issue. The controller hangs/crashes from time to time. I guess it is due to the fact that the WIFI connection is pretty poor. I'm sending the states via MQTT to a Raspi to log the data in a database. I have the impression that if the WIFI looses connection the system gets overloaded somehow which has the effect that the Wemos is not responding anymore neither on pressing button nor on reaching the device via HTTP.
How can I fix this?
- Screenshot 2021-06-16 074546.png (20.08 KiB) Viewed 11946 times
Re: Door control not working propperly
Posted: 16 Jun 2021, 08:08
by Micha_he
TDer works to stabilizate the WLAN connection.
The last versions from this month seems better in the WLAN-connecction.
Maybe you can test this version:
https://github.com/letscontrolit/ESPEas ... s/67516566 (you need a Github-account) from 2021-06-14 or wait for the next release...
Re: Door control not working propperly
Posted: 16 Jun 2021, 08:51
by TD-er
Or try this beta test for web flashing:
https://td-er.nl/ESPEasy/
Builds are made yesterday.
Re: Door control not working propperly
Posted: 16 Jun 2021, 10:19
by xxx_turbo_xxx
I just flashed the recommended bin. Let's see if it helps
Thanks again for your quick reply!
Re: Door control not working propperly
Posted: 17 Jun 2021, 08:06
by xxx_turbo_xxx
Update: Don't want to be too excited already but until now it works flawlessly! Hope it will remain like this
Thanks guys!
Re: Door control not working propperly
Posted: 17 Jun 2021, 08:25
by TD-er
Great, good to hear the WiFi part does seem to work better now.
Re: Door control not working propperly
Posted: 23 Jun 2021, 11:06
by chromo23
I recognised a second issue. The controller hangs/crashes from time to time. I guess it is due to the fact that the WIFI connection is pretty poor. I'm sending the states via MQTT to a Raspi to log the data in a database. I have the impression that if the WIFI looses connection the system gets overloaded somehow which has the effect that the Wemos is not responding anymore neither on pressing button nor on reaching the device via HTTP.
I have exactly the same issue with my chicken door.
Great, good to hear the WiFi part does seem to work better now.
Thank you! I´ll give this a try too....