{"id":16516605,"url":"https://github.com/eadf/esp8266_easygpio","last_synced_at":"2025-08-24T01:13:03.371Z","repository":{"id":26515699,"uuid":"29968504","full_name":"eadf/esp8266_easygpio","owner":"eadf","description":"An easy way of setting up esp8266 GPIO pins","archived":false,"fork":false,"pushed_at":"2016-03-03T16:39:22.000Z","size":58,"stargazers_count":37,"open_issues_count":6,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-01T04:32:18.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eadf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-28T13:23:22.000Z","updated_at":"2023-03-16T17:52:57.000Z","dependencies_parsed_at":"2022-08-24T14:56:51.563Z","dependency_job_id":null,"html_url":"https://github.com/eadf/esp8266_easygpio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadf%2Fesp8266_easygpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadf%2Fesp8266_easygpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadf%2Fesp8266_easygpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadf%2Fesp8266_easygpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eadf","download_url":"https://codeload.github.com/eadf/esp8266_easygpio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244124198,"owners_count":20401685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:25:45.199Z","updated_at":"2025-03-21T08:31:45.472Z","avatar_url":"https://github.com/eadf.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esp8266_easygpio\nAn easy way of setting up esp8266 GPIO pins.\n\nI grew tired of juggling gpio pin numbers, gpio names and gpio functions. So i created this little helper library.\n\nTo setup a pin as a GPIO input you can now just do this:\n\n```\n#include \"easygpio/easygpio.h\"\n...\nbool easygpio_pinMode(0, EASYGPIO_NOPULL, EASYGPIO_INPUT);\n```\n\nSame thing with outputs:\n```\nbool easygpio_pinMode(1, EASYGPIO_NOPULL, EASYGPIO_OUTPUT);\n```\npullStatus does not apply to output pins.\n\nYou might still need the gpio_name and func. No problem:\n```\nbool easygpio_getGPIONameFunc(uint8_t gpio_pin, uint32_t *gpio_name, uint8_t *gpio_func)\n```\n\nYou can even setup an interrupt handler:\n```\nbool easygpio_attachInterrupt(uint8_t gpio_pin, EasyGPIO_PullStatus pullStatus, void (*interruptHandler)(void* arg), void *interruptArg)\n```\n\nYou can use the methods and macros defined in gpio.h (from the sdk) to access the 'standard' gpio pins (not GPIO16).\n```\n#include \"gpio.h\"\n...\nGPIO_OUTPUT_SET(gpio_no, bit_value) // GPIO_OUTPUT_SET(0,1) sets gpio0 to high\nGPIO_DIS_OUTPUT(gpio_no) // GPIO_DIS_OUTPUT(2) turns off output on gpio2\nGPIO_INPUT_GET(gpio_no) // GPIO_INPUT_GET(12) returns the input value of gpio12\n```\n\nTo access *all* of the pins in an uniform way you can use \n```\nuint8_t easygpio_inputGet(uint8_t gpio_pin);\nvoid easygpio_outputSet(uint8_t gpio_pin, uint8_t value);\n```\nHowever, you should not rely on that these methods will change input/output status of a pin (like the gpio.h macros does).\n\ne.g. if you call ```easygpio_outputSet``` on an input pin, the pin may or may not remain an input. This is because of performance and uniformity reasons. ```easygpio_outputSet(16,1)``` will never flip gpio16 to an output, and we can't have access methods with different semantics depending on pin number).\n\nSo if you need to change the input/output mode of a pin on the fly, you can use ```easygpio_outputDisable()``` or ```easygpio_outputEnable()```.\n\n###Available pins\n\nPin number | Note\n-----------|------\nGPIO0 \t   | this pin selects bootmode [(pull up for *normal* boot)](https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes)\nGPIO1      | normally UART0 TX \nGPIO2 \t   | this pin selects bootmode [(pull up for *normal* boot)](https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes)\nGPIO3      | normally UART0 RX (you can use [stdout](https://github.com/eadf/esp8266_stdout) to use it as GPIO)\nGPIO4      | sometimes mislabeled as GPIO5 (esp-12)\nGPIO5      | sometimes mislabeled as GPIO4 (esp-12)\nGPIO12     | \nGPIO13     |\nGPIO14     |\nGPIO15 \t   | this pin selects bootmode [(pull down for *normal* boot)](https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process#esp-boot-modes)\nGPIO16      | requires easygpio_inputGet() \u0026 easygpio_outputSet() access methods (no interrupt on this pin)\n\nAll the GPIOs mentioned in ```easgle_soc.h``` are supported, but maybe we should not mess with the internal SPI pins for GPIO.\n\n## Usage\n\nThe project has been designed for easy reuse, just create a folder with these files in it ([git subtree](http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree) works great for that purpose). Then point your ```MODULES``` variable (or whatever subdirectory construct you use) in the ```Makefile``` to that folder . If you find yourself manually copying these individial .c and .h files - you're doing it wrong.\n\nSee an example on how this library can be used [here](https://github.com/eadf/esp8266_digoleserial), [here](https://github.com/eadf/esp_mqtt_lcd), [here](https://github.com/eadf/esp8266_ping), [here](https://github.com/eadf/esp_mqtt_ports) - bha.. practically all of my esp projects uses it.\n\n## Todo\n* Find the correct ```READ_PERI_REG()``` address for ```easygpio_inputGet()```, now it's simply using ```GPIO_INPUT_GET()```\n\n## Required:\n\nesp-open-sdk-v0.9.5 or higher.\n\nI've successfully tested this with sdk v1.5.2 and v0.9.5 (linux \u0026 mac).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feadf%2Fesp8266_easygpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feadf%2Fesp8266_easygpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feadf%2Fesp8266_easygpio/lists"}