The use of the ESP8266 in the world of IoT

User avatar
By theater
#8566 HI guys,
I have an application for ESP8266 where I use two ways to change the state of GPIO - HTTP and MQTT. Because I'd like to know the status for better visualization I currently use global variable but it's very annoying that I need to make sure it's always updated where I change the state of the GPIO.
Do you think it's safe to read the state of this GPIO with function GPIO_INPUT_GET(PIN_GPIO) even though the pin is set to output? (in Arduino I know it's safe btw) :)
It would make life way more easy.

Thanks,
K.
User avatar
By MK1888
#9766 Yes, you can read the state of an output in. The syntax depends on what you're programming in.

If you're using the NodeMCU firmware, check the wiki at https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en

If you're using AT commands you need the firmware that has GPIO support. I used it briefly, but moved on to the NodeMCU firmware with the LUA interpreter, and then to the Espressif SDK where you write your own firmware in C.