[SOLVED][Rules] Rotary Encoder Counter use in Rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

[SOLVED][Rules] Rotary Encoder Counter use in Rules

#1 Post by CaWi » 01 Jul 2022, 11:38

Hi all,

my rule doesn't work as expected want to build a temperature controlled fan. The rotary encoder should be set the temperature level for switching on / off the relays board.

Hardware setup: esp8266, rotary encoder (RE01), display and a relay board (GPIO16).
I can show the rotary "counter" on my display but in the rules it does not work.
When I instead of "RE01#Counter" use numbers like 25,26, .. it works.
Can some one help me?

Code: Select all

on Sensor01#Temperature>RE01#Counter do
 GPIO,16,1
endon
on Sensor01#Temperature<RE01#Counter do
 GPIO,16,0
endon
Best regards ...Carsten
Last edited by CaWi on 01 Jul 2022, 16:35, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 1796
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Rules] Rotary Encoder Counter use in Rules

#2 Post by Ath » 01 Jul 2022, 13:32

This way you will compare the eventvalue with a task value:
- Sensor01#Temperature is the task value causing the event
- RE01#Counter is the value you want to compare it to, and that needs square brackets to be expanded to the current value

Code: Select all

on Sensor01#Temperature>[RE01#Counter] do
 GPIO,16,1
endon
on Sensor01#Temperature<[RE01#Counter] do
 GPIO,16,0
endon
/Ton

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [Rules] Rotary Encoder Counter use in Rules

#3 Post by CaWi » 01 Jul 2022, 14:06

Thanks for your reply ....

but it doesn't work did you have any other hint (in the display I use it with brackets)?

[EDIT] In the log seems all ok with numbers or [RE01#Counter]

User avatar
Ath
Normal user
Posts: 1796
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Rules] Rotary Encoder Counter use in Rules

#4 Post by Ath » 01 Jul 2022, 15:01

Instead of having 2 events, you'd better check the value in 1 event:

Code: Select all

on Sensor01#Temperature do
 if %eventvalue1%>[RE01#Counter]
   GPIO,16,1
 endif
 if %eventvalue1%<[RE01#Counter] // This implies a hysteresis of 1 degree (and that's good, to avoid 'flip-flopping'), as the counter is an integer value
   GPIO,16,0
 endif
endon
Edit: Removed a superfluous 'do' at the second 'if' statement.
Last edited by Ath on 01 Jul 2022, 16:45, edited 1 time in total.
/Ton

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [Rules] Rotary Encoder Counter use in Rules

#5 Post by CaWi » 01 Jul 2022, 15:28

Thanks for the hint,

if I understand right this rule
- ask for Sensor01#Temperature
- when the > rotary the power up the relays
- when the < rotary the power down the relay
- fin

I tried it ... but now it is always power up ... no matter what I set on the rotary, clearly at boot the RE = 0.
But when i change the RE value to 40 (ambient around 26) the relay don't go to power down. :-|
It seems for me that the second part of the does not reached.

Sorry for stupid questions (and my englisch) but I will learn how it works.

Best regards ...Carsten

[EDIT] Now randomly the RE value is reset to 0 :-(

[EDIT 2]
Found it .. the "do" was the problem, removed it and now it works :-) Many thanks for your helping, my wife will be happy now!!! :-)

Another question, is it possible to store the value for next reboot (like with long press)?

User avatar
Ath
Normal user
Posts: 1796
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Rules] Rotary Encoder Counter use in Rules

#6 Post by Ath » 01 Jul 2022, 16:48

CaWi wrote: 01 Jul 2022, 15:28 [EDIT 2]
Found it .. the "do" was the problem, removed it and now it works :-) Many thanks for your helping, my wife will be happy now!!! :-)
Sorry for the typo, I've corrected it.
CaWi wrote: 01 Jul 2022, 15:28 Another question, is it possible to store the value for next reboot (like with long press)?
What value do you want to store, the last used GPIO state, or the current value for RE01#Counter?
/Ton

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#7 Post by chromo23 » 01 Jul 2022, 17:14

if you want to store the rotary value you can do this like i mentioned here:
viewtopic.php?p=58393#p58393

In general i store values that don’t change very often with the Level Control plugin.
https://espeasy.readthedocs.io/en/lates ... /P021.html

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#8 Post by CaWi » 05 Jul 2022, 08:40

Thanks for the links, will take a look.

My wife says that the ESP restarts now randomly, more at the weekend. :-(

User avatar
Ath
Normal user
Posts: 1796
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#9 Post by Ath » 05 Jul 2022, 09:51

CaWi wrote: 05 Jul 2022, 08:40 My wife says that the ESP restarts now randomly, more at the weekend. :-(
Things to check:
- Power supply to the ESP: Use a stable 5V power supply, and check the type of LDO used on the board that supplies the 3.3V, it might be an under-sized one (unfortunately, many are) :(
- Power stability: Add a 100 uF electrolitic capacitor and a 100 nF (regular) capacitor, both between 5V and GND, close to the ESP for stabilization and filtering
/Ton

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#10 Post by CaWi » 20 Jul 2022, 12:07

Sorry for the delay but family first ;-)

Thanks for the hints, tried but no success with ESO8266 and changed to ESP32 Dev Kit.
Now it works with out the relays box on "cold boot" but with not, no WLAN. Only a push to the reset button makes working WLAN again. :-(

Should I open a new thread?

Storing the value is going after a solution.

Best regards ...Carsten
IMG_6037D.jpg
IMG_6037D.jpg (205.71 KiB) Viewed 839 times

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#11 Post by chromo23 » 20 Jul 2022, 12:48

Hey carsten,
Nice box you build there!
Can you give more additional infos about your setup and to the issue itself?
Like the firmeware version you use and maybe what is to which gpios connected. Maybe even a screenshot of your devices page.
Also a log would be nice...

Edit: you can also have a look at TD-er latest suggestions regarding WiFi
viewtopic.php?p=59106#p59106

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#12 Post by CaWi » 20 Jul 2022, 13:21

Thanks, I wil do ...
A log ok but how to do with external power supply (USB and ext PS should be not together applied)? My USB PS or USB port (on my Mac) is not powerful enough. :-(
The external PS is Meanwell 5v/5A.

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#13 Post by chromo23 » 20 Jul 2022, 13:35

CaWi wrote: 20 Jul 2022, 13:21 My USB PS or USB port (on my Mac) is not powerful enough.
Whats eating up all the energy? I only see a display, a relay and an encoder in the box.
Does the wifi issue also happen when you detach the esp32 and power it standalone?

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#14 Post by TD-er » 20 Jul 2022, 13:54

What is connected to what pin on the ESP?
Especially regarding pin states at boot.

Do you have an external WiFi antenna? If not, then I wonder how the WiFi signal should get out of that metal box.

Also, how is the ESP powered?
Some ESP32 boards do have issues when powering it via the pin labelled as 5V and some also have issues when powering only the 3V3 because the USB to serial chip may then enter some undefined state.

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#15 Post by CaWi » 20 Jul 2022, 15:42

@chromo23,
yes you are right, only +relais box and no more other hardware. USB port is via a USBC to USBA Adapter.
No, then it works as expected so I choose an externe PS.

@TD-er,
please take a look to the picture.
No, no external antenna but this is not a closed metal box. Front / Back / Top are printed with PLA (3D printed) and on the backside the antenna looks outside with around -61 to -65dBm, should be ok.
IMG_6038D.jpg
IMG_6038D.jpg (352.7 KiB) Viewed 800 times
ESP is powered via the 5V pin from a Meanwell SMPS 5V/5A
Yes, I found this info in some Espressif forum entries but all hints doesn't work (for me).


I think it the relays board on powering from cold, take to "much" voltage and takes the ESP in trouble (Assumption !!!) for correct WLAN init.
When powering it from warm (reset button) all works it should be.
Another observation ... when I powered up the ESP later (from the same PS) all is working as expected.

I don't know what to do for an boot log with external PS.
A normal log after pushing the the reset button make for me no sense because when I push the reset button (warm) all is working.
Any hints for al boot log with external PS are welcome, thanks.
IMG_6038D.jpg
IMG_6038D.jpg (352.7 KiB) Viewed 800 times
Attachments
Bildschirm­foto 2022-07-20 um 15.29.30.png
Bildschirm­foto 2022-07-20 um 15.29.30.png (107.82 KiB) Viewed 800 times

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#16 Post by chromo23 » 20 Jul 2022, 16:00

CaWi wrote: 20 Jul 2022, 15:42 I think it the relays board on powering from cold, take to "much" voltage and takes the ESP in trouble (Assumption !!!) for correct WLAN init.
I think this could be it. You probably need a buffer capacitor parallel to your powersource.

Edit: FYI, i power an esp32 with serveral i2c devices and 16relays. When all relais are switched on the whole setup uses 900ma...

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#17 Post by CaWi » 20 Jul 2022, 16:07

I tried it .. 450uF up to 2000uF all the same (on random places). :-(
And the other mod like bridging the diode and so on ... nothing (works for me).

I like to find the problems but is there another solution as "check WLAN after init of the ESP again and if not restart WLAN"?
Than would be also ok for me in this case.

[EDIT] 5V / 5A Meanwell so I think that is not the problem

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#18 Post by chromo23 » 20 Jul 2022, 16:12

there is WiFiDisconnect and WiFiConnect...
I think these commands do not work as expected but at least WiFiDisconnect disconnects and immediately reconnects the WiFi... you could try this

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#19 Post by CaWi » 20 Jul 2022, 16:19

WiFiDisconnect and WiFiConnect

Mmmh, will try it ans before a deep dive in the docs .. I think should be then in the rules?!

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#20 Post by chromo23 » 20 Jul 2022, 16:32

CaWi wrote: 20 Jul 2022, 16:19 WiFiDisconnect and WiFiConnect

Mmmh, will try it ans before a deep dive in the docs .. I think should be then in the rules?!
yes....
try this:

Code: Select all

On System#Boot Do
	TimerSet,1,2
Endon

On Rules#Timer=1 Do
	WiFiDisconnect
Endon 
   

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#21 Post by chromo23 » 20 Jul 2022, 16:38

Another suggestion:

Maybe your usb adapter is really, really shitty... you could also try to powering the esp through the pins to test this theory

Edit: since everything sits on a perfboard, this cable is an useless extra in my opinion since you could make traces directly fom the input to the esp.
Last edited by chromo23 on 20 Jul 2022, 16:42, edited 1 time in total.

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#22 Post by TD-er » 20 Jul 2022, 16:42

Just based on the idea of "warm boot" vs "cold boot" in relation to the WiFi connection issues makes me think the voltage on the ESP may rise too slowly.
So adding extra capacitors may make it even worse.

The ESP does measure the supplied voltage to the ESP module and uses it to adjust WiFi related parameters.
So when the voltage does rise too slow, it may base the WiFi parameters on the wrong assumptions.

What you probably need is a delayed WiFi connection, which is not yet implemented in the code.
But the suggestion made by Chromo23 is useful. You can call a WiFidisconnect at boot.
I guess you also need to check the "Restart WiFi Lost Conn:" checkbox on the tools->Advanced page as this will actually turn the WiFi off and on again when the connection is lost.
This also forces some re-init calls on the WiFi.

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#23 Post by chromo23 » 20 Jul 2022, 16:48

TD-er wrote: 20 Jul 2022, 16:42 So adding extra capacitors may make it even worse.
You are right..... :)

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#24 Post by TD-er » 20 Jul 2022, 16:54

One thing you may also want to check here.
I've seen comments about "5V/5A so that shouldn't be the problem here"
Just keep in mind that you can have even a "5V/100A" power supply, but when you have relative thin wires from that power supply to your ESP you may still have power related issues.
The ESP may take upto 500 mA when turning on WiFi.
These spikes are very short, but they may cause a significant voltage drop if you're using thin wires.

TL;DR
The external power supply doesn't tell the whole story ;)

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#25 Post by chromo23 » 20 Jul 2022, 19:48

By the way, i just realized i had a similar problem with one of my projects.
But the esp32 didn’t boot at all. So i added a mosfet for the relais modules to not turn on before the esp booted up. That solved it..

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#26 Post by chromo23 » 20 Jul 2022, 21:57

https://esp32.com/viewtopic.php?t=21386

just found this… a 10uf capacitor between en and gnd could also help

EDIT: i just tested it on my setup and it works quite wonderful!

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#27 Post by CaWi » 21 Jul 2022, 13:20

Thanks all for helping.
I tried all hints except the MOSFET ....but no no no :-(

@chromo23,
did you have sketch for this mod?
10uF mod I tried also but also without success (10uf, 220uF and 1000uf). :-(

I tested with two other ESP32 Dev C and all the same.
After all test is it now again powered via 5V pin + 10uF mod.

Software version: ESP_Easy_mega_20220616_normal_ESP32_4M316k Jun 16 2022
This is a "warm boot" log with 10uF + Rules hint + "Restart WiFi Lost Conn:" (1. cold boot, 2. EN button).

Code: Select all

34: ^^^INIT : Booting version: HEAD_56d3225 (ESP32 SDK v4.4.1)
35: INIT : Free RAM:282284
36: INIT : Cold Boot - Restart Reason: CPU0: Vbat power on reset CPU1: for APP CPU, reseted by PRO CPU
37: FS   : Mounting...
64: FS   : Mount successful, used 142066 bytes of 290156
85: CRC  : SecuritySettings CRC   ...OK 
91: INIT : I2C
92: INIT : SPI not enabled
94: WiFi : Start network scan all channels
197: WiFi : STA Started
5109: WiFi : Scan finished, found: 11
5113: WiFi : Best AP candidate: unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK
5114: WIFI : Connecting unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK attempt #0
5121: WIFI : Arduino wifi status: WL_DISCONNECTED 6 ESPeasy internal wifi status: DISCONNECTED
5144: INIT : Free RAM:239248
5320: QEI  : GPIO: 18 19 -1 
5399: INFO : Plugins: 47 [Normal] (ESP32 SDK v4.4.1)
5400: EVENT: System#Wake
5410: Rules : Read 14 lines from rules1.txt
5412: Cache rules event: rules1.txt pos: 0 On System#Boot Do
5412: Cache rules event: rules1.txt pos: 3 On Rules#Timer=1 Do
5413: Cache rules event: rules1.txt pos: 6 on Sensor01#Temperature do
5461: Rules : Read 0 lines from rules2.txt
5509: Rules : Read 0 lines from rules3.txt
5556: Rules : Read 0 lines from rules4.txt
5560: EVENT: System#BootMode=1,1,1,0
5567: Webserver: start
5579: EVENT: System#Boot
5586: ACT  : TimerSet,1,2
5692: WIFI : Disconnected! Reason: '(8) Assoc leave' Connected for 9 ms
5707: WiFi : Scan not allowed, unprocessed WiFi events:  disconn
5807: WIFI : Set WiFi to OFF
6033: WiFi : Best AP candidate: unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK
6034: WIFI : Connecting unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK attempt #1
6136: WIFI : Set WiFi to STA
6147: WiFi : STA Started
6251: WIFI : Arduino wifi status: WL_DISCONNECTED 6 ESPeasy internal wifi status: DISCONNECTED
6263: EVENT: TaskInit#Display01=1,1
7066: EVENT: TaskInit#Sensor01=2,1
7113: SI7021 : No read started !
7159: SW   : State 0.00
7249: EVENT: TaskInit#Relais01=3,1
7295: WIFI : Connected! AP: unbekannt (44:4E:6D:25:12:6A) Ch: 13 Duration: 1249 ms
7296: WIFI : Arduino wifi status: WL_IDLE_STATUS 0 ESPeasy internal wifi status: Conn. 
7575: WIFI : DHCP IP: 192.168.0.33 (ESP32-C8C9A3D244EC-1) GW: 192.168.0.254 SN: 255.255.255.0   duration: 48 ms
7589: UDP : Start listening on port 8266
7590: firstLoopConnectionsEstablished
7593: EVENT: TaskInit#RE01=4,1
7633: NTP  : NTP replied: delay 30 mSec Accuracy increased by 0.929 seconds
7635: Time set to 1658401965.929
7636: Current Time Zone:  DST time start: 2022-03-27 02:00:00 offset: 120 min STD time start: 2022-10-30 03:00:00 offset: 60 min
7638: Local time: 2022-07-21 13:12:45
7643: EVENT: Clock#Time=Thu,13:12
7672: SI7021 : Read Error !
7851: WD   : Uptime 0 ConnectFailures 0 FreeMem 220468 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
7861: EVENT: WiFi#Disconnected
8126: EVENT: Relais01#State=0
8157: SI7021 : Read Error !
8191: EVENT: Rules#Timer=1,1
8197: ACT  : WiFiDisconnect
8313: WIFI : Disconnected! Reason: '(8) Assoc leave' Connected for 923 ms
8328: WiFi : Scan not allowed, unprocessed WiFi events:  disconn
8428: WIFI : Set WiFi to OFF
8653: WIFI : Arduino wifi status: WL_NO_SHIELD 255 ESPeasy internal wifi status: DISCONNECTED
8655: WiFi : Best AP candidate: unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK
8656: WIFI : Connecting unbekannt 44:4E:6D:25:12:6A Ch:13 (-72dBm) WPA2/PSK attempt #2
8758: WIFI : Set WiFi to STA
8769: WiFi : STA Started
8884: EVENT: RE01#Counter=0
8971: EVENT: WiFi#ChangedAccesspoint
9728: EVENT: WiFi#ChangedWiFichannel
9838: EVENT: WiFi#Connected
9885: SI7021 : Temperature: 27.90
9886: SI7021 : Humidity: 46.40
9904: WIFI : Connected! AP: unbekannt (44:4E:6D:25:12:6A) Ch: 13 Duration: 1241 ms
9905: WIFI : Arduino wifi status: WL_IDLE_STATUS 0 ESPeasy internal wifi status: Conn. 
10188: WIFI : DHCP IP: 192.168.0.33 (ESP32-C8C9A3D244EC-1) GW: 192.168.0.254 SN: 255.255.255.0   duration: 96 ms
10299: EVENT: Time#Initialized
10308: EVENT: RE01#Counter=0
10395: EVENT: RE01#Counter=0
10669: EVENT: WiFi#Disconnected
10744: EVENT: RE01#Counter=0
10750: EVENT: Sensor01#Temperature=28
10765: ACT  : GPIO,16,1
10769: GPIO : port#16: set to 1
10786: EVENT: Sensor01#Humidity=46
10795: SW  : GPIO=16 State=1 Output value=1
10828: EVENT: WiFi#ChangedAccesspoint
10887: EVENT: WiFi#ChangedWiFichannel
10900: EVENT: WiFi#Connected
10909: EVENT: RE01#Counter=0
10935: SI7021 : Temperature: 27.90
10935: SI7021 : Humidity: 46.40
10953: EVENT: RE01#Counter=0
10959: EVENT: Relais01#State=1
10963: EVENT: Sensor01#Temperature=28
11009: ACT  : GPIO,16,1
11013: GPIO : port#16: set to 1
11064: EVENT: Sensor01#Humidity=46
11753: EVENT: RE01#Counter=0
12144: SI7021 : Temperature: 27.90
12145: SI7021 : Humidity: 46.40
12163: EVENT: Sensor01#Temperature=28
A cold boot log I don't know how to make. :-(

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#28 Post by chromo23 » 21 Jul 2022, 13:36

CaWi wrote: 21 Jul 2022, 13:20 @chromo23,
did you have sketch for this mod?
10uF mod I tried also but also without success (10uf, 220uF and 1000uf).
What do you mean with sketch?
This is just a 10uF capacitor between the enable and ground pin... no sketch needed

I recommend to systematically test your setup.
1. esp on the perfboard alone...all additional devices disconnected -> this already seems to work
2. one by one add devices and test -> so you probably get the device that’s interfering
3. you could also measure the voltage..not that you would see a short voltage drop but maybe it is from the beginning on to low

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#29 Post by chromo23 » 21 Jul 2022, 13:47

This board seems to have several issues as you can read here:
https://github.com/espressif/arduino-esp32/issues/1274

so please try the capacitor between en & gnd and also pulling gpio0 up as described there.
if it still doesn’t work try the 100nf 10k solution instead of the 10uf capacitor
I fixed the problem by adding a 10k pullup to IO0 (PROG) on my own board, the internal MCU pullup does not work reliable on reset. On EN I have also a 10k Pullup and a 100nF EN to GND. With this combination the power-on reset timing works for me.
Edit: and I can totally empathize. such errors can be very frustrating

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#30 Post by CaWi » 21 Jul 2022, 15:40

Thank you for your patience with me and thanks for sharing this link, seems really to be a crappy board. :-|

I'm not really fit in electronics can only "paint as numbers", so please excuse this.
With sketch I mean for FET and relays board ...

Ok, direct connection 3V3 zu GPIO doesn't work here. :-(

With pull-up means that this?

3V3 --- 10k ------------ GPIO0

3V3 ----10k --- EN
EN --- 100nF --- GND

Sorry for the amateur questions.

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#31 Post by TD-er » 21 Jul 2022, 16:06

This:

Code: Select all

3V3 ----10k --- EN
EN --- 100nF --- GND
What this does is that the EN pin is slowly pulled high and thus delaying the boot procedure.
Not sure if 100 nF & 10k is enough to delay it long enough for your setup.
But you can experiment with other values of the capacitor.
Changing the resistor will probably not make a lot of difference as I expert there is already a resistor present between 3V3 and EN pin.

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#32 Post by chromo23 » 21 Jul 2022, 16:20

CaWi wrote: 21 Jul 2022, 15:40 With pull-up means that this?

3V3 --- 10k ------------ GPIO0

3V3 ----10k --- EN
EN --- 100nF --- GND
Thats correct...
With sketch I mean for FET and relays board ...
The transistor would work like a switch. If it is really necessary a little experiment will tell you:
unplug the relayboard > power on your box > after 1-2 sec replug the relayboard.. if everything works as it should you could put a mosfet as a switch into your ciruit.
with a logiclevel mosfet this is pretty straight forward.just put the gate with a pulldown directly to a gpio. i can provide you later with an item number an schematics but try the pullup and capacitor approach first...

Edit: depending on what you want to switch you could get rid of the relayboard entirely...

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#33 Post by CaWi » 21 Jul 2022, 17:12

1. test:
Nothing works. :-(
I tried with 10, 220 and 1000uF or 10k, 20k or 47k ...all the same ... warm reboot and all working.
IMG_6041D.JPG
IMG_6041D.JPG (3.66 MiB) Viewed 631 times
2. test without any R or C and NO I2C Parts only rotary encoder and relay box:
It works!

3. Test only with display with rotary encoder and relay box:
It works!

4. test with display, sensor and rotary encoder and relay box:
NO more working!

It is a "SI7021" (GY-21 HTU2) sensor, when I remove this sensor all is working as should be, damm!


How to debugging this?

[EDIT] when I put the sensor later to the I2C bus it works also

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#34 Post by TD-er » 21 Jul 2022, 17:45

What pin is this sensor connected to?

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#35 Post by chromo23 » 21 Jul 2022, 18:03

Thats good news! It seems, that you found the problem....
So it´s either a sensor or an i2c problem.
As a non expert i would suggest to lower the i2c frequency to see what happens then... but if it now works you could also leave it as it is :)

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#36 Post by CaWi » 21 Jul 2022, 19:09

The sensor is connected to SDA: GPIO-4 & SCL: GPIO-5 and +- from ext PS.
Will try this tomorrow but if this not working that not not my goal to append the sensor after powering up. ;-)
[EDIT] with attaching the sensor after powering up is it now working also with the cheapest PS. :shock:

Hope the devs have a solution and I will help how I can.

User avatar
chromo23
Normal user
Posts: 408
Joined: 10 Sep 2020, 16:02
Location: germany

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#37 Post by chromo23 » 21 Jul 2022, 19:14

For adding the sensor later you could attach the sensors + to a gpio of the esp32 and put it high after a little delay...
The sensor draws so little current, that the pins of the esp32 can handle that without any extra circuitry.
Best option would be of course to find the actual issue but until then you could give it a try.. :)

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#38 Post by TD-er » 21 Jul 2022, 19:22

Please try other pins.
GPIO 4 & 5 are the default for ESP8266, but those are a truly bad choice for I2C on ESP32.
See:
https://espeasy.readthedocs.io/en/lates ... e-on-esp32
GPIO 4 has internal pull-down.

CaWi
Normal user
Posts: 22
Joined: 03 Jun 2022, 11:27

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#39 Post by CaWi » 21 Jul 2022, 20:16

Changed to GPIO21 & GPIO22 and ............ WOW!!! :!:
:D :D :D :D :D :D :D :D
Cold or warm boot ... it works!

Many many thanks to all helping guys, it was a rocky road for me, but now it's working! So start the next adventure .... to store some values for temp and hum, a second relay for the rain machine and hopefully something for the lights (dimming would be a dream). 8-)
And all for this little small terrarium, about 2,5m tail (not for the dog, she is really big and photo shy) :lol:
IMG_6042D.JPG
IMG_6042D.JPG (3.55 MiB) Viewed 602 times
Nice evening to all and regards ....Carsten

TD-er
Core team member
Posts: 6337
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [SOLVED][Rules] Rotary Encoder Counter use in Rules

#40 Post by TD-er » 21 Jul 2022, 21:48

Good to know this.

I wil still have a peek at the code to see why it might cause these issues.
It "only" should affect the I2C performance, like I2C devices not working reliable when using those pins.
Not causing the issues you're describing.

But anyway your setup now is working.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests