{"id":13780149,"url":"https://github.com/tuanpmt/espduino","last_synced_at":"2025-04-06T06:09:59.342Z","repository":{"id":77241208,"uuid":"28745178","full_name":"tuanpmt/espduino","owner":"tuanpmt","description":"ESP8266 network client (mqtt, restful) for Arduino","archived":false,"fork":false,"pushed_at":"2016-10-28T17:26:32.000Z","size":973,"stargazers_count":384,"open_issues_count":33,"forks_count":122,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-03-30T05:06:10.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://tuanpm.net/post/espduino","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuanpmt.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,"governance":null}},"created_at":"2015-01-03T14:02:08.000Z","updated_at":"2025-02-08T22:39:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"54387caa-8b8d-489b-b74d-302e24cef3b3","html_url":"https://github.com/tuanpmt/espduino","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Fespduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Fespduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Fespduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuanpmt%2Fespduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuanpmt","download_url":"https://codeload.github.com/tuanpmt/espduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441053,"owners_count":20939239,"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-08-03T18:01:12.792Z","updated_at":"2025-04-06T06:09:59.317Z","avatar_url":"https://github.com/tuanpmt.png","language":"C++","readme":"espduino\n========\n\n# WARNING: This project discontinue support, \n# if you want to play ESP8266 with arduino, please visit: [Arduino for ESP8266](https://github.com/esp8266/Arduino)\n\nThis is Wifi library (Chip ESP8266 Wifi soc) for arduino using SLIP protocol via Serial port\n\nYou can found the **Native MQTT client** library for ESP8266 work well here: \n[https://github.com/tuanpmt/esp_mqtt](https://github.com/tuanpmt/esp_mqtt)\n\nSource code bridge for ESP8266 can found here: [https://github.com/tuanpmt/esp_bridge](https://github.com/tuanpmt/esp_bridge)\n\nFeatures\n========\n- Rock Solid wifi network client for Arduino/mbed (coming soon)\n- **More reliable** than AT COMMAND library (Personal comments)\n- **Firmware applications written on ESP8266 can be read out completely. For security applications, sometimes you should use it as a Wifi client (network client) and other MCU with Readout protection.**\n- MQTT module: \n    + MQTT client run stable as Native MQTT client (esp_mqtt)\n    + Support subscribing, publishing, authentication, will messages, keep alive pings and all 3 QoS levels (it should be a fully functional client).\n    + **Support multiple connection (to multiple hosts).**\n    + Support SSL\n    + Easy to setup and use\n- REST module:\n    + Support method GET, POST, PUT, DELETE\n    + setContent type, set header, set User Agent\n    + Easy to used API\n    + Support SSL\n    + Support multiple connection\n    \n### To-Do:\n- WIFI AP  \n- Webserver module\n- NTP module\n- RTC + Memory\n- mDNS module\n\nInstallations\n========\n**1. Clone this project:**\n\n```bash\ngit clone https://github.com/tuanpmt/espduino\ncd espduino\n```\n\n**2. Program ESP8266:**\n\n- Wiring: ![Program Connection diagram](fritzing/program_esp8266_bb.png?raw=true)\n- Program release firmware:\n\n```python\nesp8266/tools/esptool.py -p COM1 write_flash 0x00000 esp8266/release/0x00000.bin 0x40000 esp8266/release/0x40000.bin\n```\n    \n- Or Program debug firmware (Debug message from ESP8266 will forward to debug port of Arduino)\n\n```python\nesp8266/tools/esptool.py -p COM1 write_flash 0x00000 esp8266/debug/0x00000.bin 0x40000 esp8266/debug/0x40000.bin\n```\n\n**3. Wiring:**\n![Program Connection diagram](fritzing/espdruino_bb.png?raw=true)\n\n**4. Import arduino library and run example:**\n\nExample read DHT11 and send to [thingspeak.com](http://thingspeak.com)\n=========\n- ```espduino/examples/thingspeak/thingspeak.ino```\n- Using DHT11 library from: [https://github.com/RobTillaart/Arduino](https://github.com/RobTillaart/Arduino)\n\n![](images/thingspeak.png)\n\nExample send pushbullet push notification:\n=============\n[http://tuanpm.net/pir-motion-detect-send-pushbullet-push-notification-with-esp8266/](http://tuanpm.net/pir-motion-detect-send-pushbullet-push-notification-with-esp8266/)\n\n\nExample for MQTT client\n=======\n\n```c\n/**\n * \\file\n *       ESP8266 MQTT Bridge example\n * \\author\n *       Tuan PM \u003ctuanpm@live.com\u003e\n */\n#include \u003cSoftwareSerial.h\u003e\n#include \u003cespduino.h\u003e\n#include \u003cmqtt.h\u003e\n\nSoftwareSerial debugPort(2, 3); // RX, TX\nESP esp(\u0026Serial, \u0026debugPort, 4);\nMQTT mqtt(\u0026esp);\nboolean wifiConnected = false;\n\nvoid wifiCb(void* response)\n{\n  uint32_t status;\n  RESPONSE res(response);\n\n  if(res.getArgc() == 1) {\n    res.popArgs((uint8_t*)\u0026status, 4);\n    if(status == STATION_GOT_IP) {\n      debugPort.println(\"WIFI CONNECTED\");\n      mqtt.connect(\"yourserver.com\", 1883, false);\n      wifiConnected = true;\n      //or mqtt.connect(\"host\", 1883); /*without security ssl*/\n    } else {\n      wifiConnected = false;\n      mqtt.disconnect();\n    }\n    \n  }\n}\n\nvoid mqttConnected(void* response)\n{\n  debugPort.println(\"Connected\");\n  mqtt.subscribe(\"/topic/0\"); //or mqtt.subscribe(\"topic\"); /*with qos = 0*/\n  mqtt.subscribe(\"/topic/1\");\n  mqtt.subscribe(\"/topic/2\");\n  mqtt.publish(\"/topic/0\", \"data0\");\n\n}\nvoid mqttDisconnected(void* response)\n{\n\n}\nvoid mqttData(void* response)\n{\n  RESPONSE res(response);\n\n  debugPort.print(\"Received: topic=\");\n  String topic = res.popString();\n  debugPort.println(topic);\n\n  debugPort.print(\"data=\");\n  String data = res.popString();\n  debugPort.println(data);\n\n}\nvoid mqttPublished(void* response)\n{\n\n}\nvoid setup() {\n  Serial.begin(19200);\n  debugPort.begin(19200);\n  esp.enable();\n  delay(500);\n  esp.reset();\n  delay(500);\n  while(!esp.ready());\n\n  debugPort.println(\"ARDUINO: setup mqtt client\");\n  if(!mqtt.begin(\"DVES_duino\", \"admin\", \"Isb_C4OGD4c3\", 120, 1)) {\n    debugPort.println(\"ARDUINO: fail to setup mqtt\");\n    while(1);\n  }\n\n\n  debugPort.println(\"ARDUINO: setup mqtt lwt\");\n  mqtt.lwt(\"/lwt\", \"offline\", 0, 0); //or mqtt.lwt(\"/lwt\", \"offline\");\n\n/*setup mqtt events */\n  mqtt.connectedCb.attach(\u0026mqttConnected);\n  mqtt.disconnectedCb.attach(\u0026mqttDisconnected);\n  mqtt.publishedCb.attach(\u0026mqttPublished);\n  mqtt.dataCb.attach(\u0026mqttData);\n\n  /*setup wifi*/\n  debugPort.println(\"ARDUINO: setup wifi\");\n  esp.wifiCb.attach(\u0026wifiCb);\n\n  esp.wifiConnect(\"DVES_HOME\",\"wifipassword\");\n\n\n  debugPort.println(\"ARDUINO: system started\");\n}\n\nvoid loop() {\n  esp.process();\n  if(wifiConnected) {\n\n  }\n}\n\n```\n\nExample for RESTful client\n=====\n```c\n/**\n * \\file\n *       ESP8266 RESTful Bridge example\n * \\author\n *       Tuan PM \u003ctuanpm@live.com\u003e\n */\n\n#include \u003cSoftwareSerial.h\u003e\n#include \u003cespduino.h\u003e\n#include \u003crest.h\u003e\n\nSoftwareSerial debugPort(2, 3); // RX, TX\n\nESP esp(\u0026Serial, \u0026debugPort, 4);\n\nREST rest(\u0026esp);\n\nboolean wifiConnected = false;\n\nvoid wifiCb(void* response)\n{\n  uint32_t status;\n  RESPONSE res(response);\n\n  if(res.getArgc() == 1) {\n    res.popArgs((uint8_t*)\u0026status, 4);\n    if(status == STATION_GOT_IP) {\n      debugPort.println(\"WIFI CONNECTED\");\n     \n      wifiConnected = true;\n    } else {\n      wifiConnected = false;\n    }\n    \n  }\n}\n\nvoid setup() {\n  Serial.begin(19200);\n  debugPort.begin(19200);\n  esp.enable();\n  delay(500);\n  esp.reset();\n  delay(500);\n  while(!esp.ready());\n\n  debugPort.println(\"ARDUINO: setup rest client\");\n  if(!rest.begin(\"yourapihere-com-r2pgihowjx7x.runscope.net\")) {\n    debugPort.println(\"ARDUINO: failed to setup rest client\");\n    while(1);\n  }\n\n  /*setup wifi*/\n  debugPort.println(\"ARDUINO: setup wifi\");\n  esp.wifiCb.attach(\u0026wifiCb);\n  esp.wifiConnect(\"DVES_HOME\",\"wifipassword\");\n  debugPort.println(\"ARDUINO: system started\");\n}\n\nvoid loop() {\n  char response[266];\n  esp.process();\n  if(wifiConnected) {\n    rest.get(\"/\");\n    if(rest.getResponse(response, 266) == HTTP_STATUS_OK){\n      debugPort.println(\"RESPONSE: \");\n      debugPort.println(response);\n    }\n    delay(1000);\n  }\n}\n```\n\nMQTT API:\n=======\n```c\nFP\u003cvoid, void*\u003e connectedCb;\nFP\u003cvoid, void*\u003e disconnectedCb;\nFP\u003cvoid, void*\u003e publishedCb;\nFP\u003cvoid, void*\u003e dataCb;\n\n\nMQTT(ESP *esp);\nboolean begin(const char* client_id, const char* user, const char* pass, uint16_t keep_alive, boolean clean_seasion);\nboolean lwt(const char* topic, const char* message, uint8_t qos, uint8_t retain);\nboolean lwt(const char* topic, const char* message);\nvoid connect(const char* host, uint32_t port, boolean security);\nvoid connect(const char* host, uint32_t port);\nvoid disconnect();\nvoid subscribe(const char* topic, uint8_t qos);\nvoid subscribe(const char* topic);\nvoid publish(const char* topic, uint8_t *data, uint8_t len, uint8_t qos, uint8_t retain);\nvoid publish(const char* topic, char* data, uint8_t qos, uint8_t retain);\nvoid publish(const char* topic, char* data);\n```\n\nREST API:\n==============\n\n```c\nREST(ESP *e);\nboolean begin(const char* host, uint16_t port, boolean security);\nboolean begin(const char* host);\nvoid request(const char* path, const char* method, const char* data);\nvoid request(const char* path, const char* method, const char* data, int len);\nvoid get(const char* path, const char* data);\nvoid get(const char* path);\nvoid post(const char* path, const char* data);\nvoid put(const char* path, const char* data);\nvoid del(const char* path, const char* data);\n\nvoid setTimeout(uint32_t ms);\nuint16_t getResponse(char* data, uint16_t maxLen);\nvoid setUserAgent(const char* value); //setUserAgent(\"Your user agent\"); \n// Set Content-Type Header\nvoid setContentType(const char* value); //setContentType(\"application/json\");\nvoid setHeader(const char* value);//setHeaer(\"Header1:value1\\r\\nHeader2:value2\\r\\n\");\n```\n\nAuthors:\n=================\n[Tuan PM](https://twitter.com/tuanpmt)\n\n\n\nDonations\n==================\nInvite me to a coffee\n[![Donate](https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=JR9RVLFC4GE6J)\n\nLICENSE - \"MIT License\"\n==================\nCopyright (c) 2014-2015 [Tuan PM](https://twitter.com/tuanpmt)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=JR9RVLFC4GE6J"],"categories":["Libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanpmt%2Fespduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuanpmt%2Fespduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuanpmt%2Fespduino/lists"}