Page 1 of 1

Status of GPIO pin always 0

Posted: 14 Jul 2018, 00:20
by caco3
Hi

I have set GPIO13 as an input.
The devices page shows the value correctly as 1 or 0.
Also when I read http://<IP>/json, I can see the correct state:

Code: Select all

"Sensors":[
{
"TaskValues": [
{"ValueNumber":1,
"Name":"Switch",
"NrDecimals":0,
"Value":1
}],
How ever when I try to read the status using

Code: Select all

http://<IP>/control?cmd=status,GPIO,13
the state is always 0:

Code: Select all

{ "log": "", "plugin": 1, "pin": 13, "mode": "input", "state": 0 } 
What am I missing?

Re: Status of GPIO pin always 0

Posted: 14 Jul 2018, 08:23
by grovkillen
Have you previously used PWM on that pin? Do a PWM zero command and see if the same is happening? But it sounds like it's the same thing as reported here: https://github.com/letscontrolit/ESPEasy/issues/1551

Re: Status of GPIO pin always 0

Posted: 14 Jul 2018, 22:54
by caco3
Thanks for the reply!

I haven't used any PWM functionality, in fact its the first time I configure this device.
In fact it has exactly the same symptoms as in the mentioned bug report. I will further trace it down there.

As a workaround I did the following:
1. Configure a 2nd device, eg on GPIO2.
2. Add the following rule:

Code: Select all

on Switch#Switch do
    if [Switch#Switch]=0
        gpio,2,1
    else
        gpio,2,0
    endif
endon
Whenever GPIO13 changes, the rule gets executed which sets GPIO2.
GPIO2 now shows the correct state when it gets polled.