T
T
tayanov2015-08-12 21:38:37
IDE
tayanov, 2015-08-12 21:38:37

How to handle change event on esp8266 GPIO?

There is esp2688. It seems like a simple task, without using an arduino. Only esp 2688.
You need to send request A when receiving a pulse on gpio0. those. momentary level change to gpio0.
and request B when receiving a pulse on gpio1 on gpio1.
And then wait for the next. either of the two impulses.
Actually, as far as I understood the so-called. there are no interrupts in esp 2688.
maybe some kind of tricky move will help?
PS impulse from water sensors.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tayanov, 2015-08-27
@tayanov

Using nodemcu:
In fact, this is the processing of a button press, already with bounce protection.

local pin = 4    --> GPIO2

function debounce (func)
    local last = 0
    local delay = 200000

    return function (...)
        local now = tmr.now()
        if now - last < delay then return end

        last = now
        return func(...)
    end
end

function onChange ()
    print('The pin value has changed to '..gpio.read(pin))
end

Solution found.

J
jcmvbkbc, 2015-08-12
@jcmvbkbc

Actually, as far as I understood the so-called. there are no interrupts in esp 2688.

I wonder how you figured it out?
Section 7.1 of document 2C-ESP8266__SDK__Programming Guide__EN_v1.2.0.pdf describes the functions for working with GPIO, among which are ETS_GPIO_INTR_ATTACH, ETS_GPIO_INTR_ENABLE and gpio_pin_intr_state_set.
Don't forget to also set up PINMUX before using the GPIO.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question