{"id":13763547,"url":"https://github.com/marcoschwartz/aREST","last_synced_at":"2025-05-10T17:30:34.634Z","repository":{"id":15810368,"uuid":"18549950","full_name":"marcoschwartz/aREST","owner":"marcoschwartz","description":"A RESTful environment for Arduino","archived":false,"fork":false,"pushed_at":"2023-10-28T17:31:15.000Z","size":375,"stargazers_count":1202,"open_issues_count":101,"forks_count":279,"subscribers_count":75,"default_branch":"master","last_synced_at":"2025-05-06T07:27:23.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://aREST.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcoschwartz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-04-08T07:58:59.000Z","updated_at":"2025-05-05T04:26:46.000Z","dependencies_parsed_at":"2022-07-22T23:32:56.448Z","dependency_job_id":"ffa7961b-53ee-4f45-9925-93210d94be33","html_url":"https://github.com/marcoschwartz/aREST","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoschwartz%2FaREST","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoschwartz%2FaREST/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoschwartz%2FaREST/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoschwartz%2FaREST/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoschwartz","download_url":"https://codeload.github.com/marcoschwartz/aREST/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253451525,"owners_count":21910725,"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-03T15:00:51.070Z","updated_at":"2025-05-10T17:30:34.615Z","avatar_url":"https://github.com/marcoschwartz.png","language":"C++","readme":"\u003ch1\u003eaREST\u003c/h1\u003e\n\n\u003cspan\u003e[![Build Status](https://travis-ci.org/marcoschwartz/aREST.svg?branch=master)](https://travis-ci.org/marcoschwartz/aREST)\u003c/span\u003e\n\u003cspan\u003e[![Backers on Open Collective](https://opencollective.com/arest/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/arest/sponsors/badge.svg)](#sponsors) [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=3Q73345CWMYE8)\u003c/span\u003e\n\n## Overview\n\nA simple library that implements a REST API for Arduino \u0026 the ESP8266 WiFi chip.\n\nIt is designed to be universal and currently supports REST calls via HTTP (using the CC3000 WiFi chip, the Arduino WiFi library or the Ethernet shield), via the Serial port (using the USB serial connection, Bluetooth, and XBee) and also via Bluetooth Low Energy. The library is also compatible with the Arduino MKR1000 board.\n\nIt also works with the ESP8266 WiFi chip using the ESP8266 processor, therefore working as an independent unit. It also works on the ESP32 WiFi chip.\n\nBoards running aREST can also be accessed from anywhere in the world via an API available at `cloud.arest.io`. Check the rest of this file and the examples ending with *_cloud* for more details. This currently only works with the Ethernet library for Arduino \u0026 the ESP8266 WiFi chip.\n\nIf you want to know more about aREST, go over to [http://arest.io/](http://arest.io/).\n\n## Contents\n\n- aREST.h: the library file.\n- examples: several examples using the aREST library\n- test: unit tests of the library\n\n## Supported hardware\n\n### Arduino/Genuino Boards\n\nThe library is at the moment compatible with the following Arduino boards: Uno, Mega, Due, Yun and Teensy 3.x. It is also compatible with the Arduino/Genuino MKR1000 board.\n\n### ESP8266/ESP32\n\nThe library is compatible with most of the ESP8266 modules \u0026 ESP8266 development boards, as well as most boards based on the ESP32 WiFi chip.\n\n### HTTP\n\nFor HTTP communications, the library is compatible with most CC3000 breakout boards, and was tested with the Adafruit CC3000 breakout board and the CC3000 WiFi shield. It was also tested with the Tiny Circuit WiFi shield (but in that case, you will have to change the pins configuration inside the example WiFi sketch. See the Tiny Circuit WiFi shield documentation for more details). The library is also compatible with the official Arduino Ethernet shield, with the official Arduino WiFi shield, and with the Arduino Yun via the embedded WiFi connection.\n\n### Serial\n\nFor Serial communications, the library has been tested with the direct USB serial connection on an Arduino Uno board, with the Adafruit BlueFruit EZ-Link Bluetooth module, and with XBee Series 1 devices.\n\n### Bluetooth LE\n\nFor Bluetooth Low Energy communications, the library has been tested with the Adafruit BLE nRF8001 breakout board.\n\n## Requirements\n\nTo use the library with Arduino boards you will need the latest version of the Arduino IDE:\n\n- [Arduino IDE 1.8.5](http://arduino.cc/en/main/software)\n\n### For WiFi using the ESP8266 chip\n\nTo use the library with the ESP8266 WiFi chip you will need to install the required module from the Boards Manager of the Arduino IDE. These are the steps to install the ESP8266 package inside the Arduino IDE:\n\n1. Start the Arduino IDE and open the Preferences window\n2. Enter `http://arduino.esp8266.com/stable/package_esp8266com_index.json` into the Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.\n3. Open the Boards Manager from Tools \u003e Board menu and install the esp8266 package (and after that don't forget to select your ESP8266 board from Tools \u003e Board menu).\n\n### For WiFi using the ESP32 chip\n\nTo use the library with the ESP32 WiFi chip you will need to install the board definitions for the Arduino IDE. These are the steps to install support for the ESP32 chip inside the Arduino IDE:\n\n1. Follow the install instructions from [https://github.com/espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)\n2. Restart the Arduino IDE\n3. Select your ESP32 board from Tools \u003e Board menu.\n\n### For WiFi using the CC3000 chip\n\n- [Adafruit CC3000 Library](https://github.com/adafruit/Adafruit_CC3000_Library)\n- [Adafruit MDNS Library](https://github.com/adafruit/CC3000_MDNS)\n- MDNS support in your operating system:\n  - For OS X it is supported through Bonjour, you don't have anything to install.\n  - For Linux, you need to install [Avahi](http://avahi.org/).\n  - For Windows, you need to install [Bonjour](http://www.apple.com/support/bonjour/).\n\n### For WiFi using the MKR1000 Board\n\nTo use aREST with the MKR1000 board, you first need to install the MKR1000 board definition from the Arduino IDE board manager. You also need to install the following library:\n\n- [WiFi 101 Library](https://github.com/arduino-libraries/WiFi101)\n\n### For Bluetooth Low Energy\n\n- [Adafruit nRF8001 Library](https://github.com/adafruit/Adafruit_nRF8001)\n\n### For Cloud Access\n\n- [PubSub Library](https://github.com/knolleary/pubsubclient)\n\n## Setup\n\nTo install the library, simply clone this repository in the /libraries folder of your Arduino folder.\n\n## Quick test (WiFi)\n\n1. Connect a LED \u0026 resistor to pin number 8 of your Arduino board\n2. Open the WiFi_CC3000 example sketch and modify the WiFi SSID, password \u0026 security\n3. Upload the sketch\n4. Go to a web browser and type `arduino.local/mode/8/o` to set the pin as an output\n5. Now type `arduino.local/digital/8/1` and the LED should turn on\n\n## Quick test (Ethernet)\n\n1. Connect a LED \u0026 resistor to pin number 8 of your Arduino board\n2. Make sure your computer is connected via Ethernet to the board and has the IP address 192.168.2.x\n3. Upload the sketch\n4. Go to a web browser and type `192.168.2.2/mode/8/o` to set the pin as an output\n5. Now type `192.168.2.2/digital/8/1` and the LED should turn on\n\n## Quick test (Serial)\n\n1. Connect a LED \u0026 resistor to pin number 8 of your Arduino board\n2. Open the Serial example sketch\n3. Upload the sketch\n4. Go to a the Serial monitor and set the options to \"BOTH NL \u0026 CR\" and \"115200 bauds\"\n5. Type `/mode/8/o` to set the pin as an output\n6. Now type `/digital/8/1` and the LED should turn on\n\n## Quick test (BLE)\n\n1. Connect a LED \u0026 resistor to pin number 8 of your Arduino board\n2. Open the BLE example sketch\n3. Upload the sketch\n4. Use the [BlueFruit LE Connect app](https://itunes.apple.com/fr/app/adafruit-bluefruit-le-connect/id830125974?mt=8) to connect to the BLE chip\n5. Type `/mode/8/o /` to set the pin as an output\n6. Now type `/digital/8/1 /` and the LED should turn on\n\n## Quick test (ESP8266/ESP32)\n\n1. Connect a LED \u0026 resistor to pin number 5 of your ESP8266/ESP32 board\n2. Open the ESP8266/ESP32 example sketch and modify the WiFi SSID \u0026 password\n3. Upload the sketch\n4. Open the Serial monitor to get the IP address of the board, for example 192.168.1.103\n5. Go to a web browser and type `192.168.1.103/mode/5/o` to set the pin as an output\n6. Now type `192.168.1.103/digital/5/1` and the LED should turn on\n\n## Cloud Access (Ethernet)\n\n1. Connect a LED \u0026 resistor to pin number 8 of your Arduino board\n2. Open the Ethernet_cloud example sketch and modify the MAC address, and also give a unique ID to your project, for example 47fd9g\n3. Make sure your shield is connected to the web via an Ethernet cable\n3. Upload the sketch to the board\n5. Go to a web browser and type `cloud.arest.io/47fd9g/mode/8/o` to set the pin as an output\n6. Now type `cloud.arest.io/47fd9g/digital/8/1` and the LED should turn on\n\n## Cloud Access (ESP8266)\n\n1. Connect a LED \u0026 resistor to pin number 5 of your ESP8266 board\n2. Open the ESP8266_cloud example sketch and modify the WiFi SSID \u0026 password, and also give a unique ID to your project, for example 47fd9g\n3. Upload the sketch to the board\n5. Go to a web browser and type `cloud.arest.io/47fd9g/mode/5/o` to set the pin as an output\n6. Now type `cloud.arest.io/47fd9g/digital/5/1` and the LED should turn on\n\n## API documentation\n\nThe API currently supports five type of commands: digital, analog, and mode, variables, and user-defined functions.\n\n### Digital\n\nDigital is to write or read on digital pins on the Arduino. For example:\n  * `/digital/8/0` sets pin number 8 to a low state\n  * `/digital/8/1` sets pin number 8 to a high state\n  * `/digital/8` reads value from pin number 8 in JSON format (note that for compatibility reasons, `/digital/8/r` produces the same result)\n\n### Analog\n\nAnalog is to write or read on analog pins on the Arduino. Note that you can only write on PWM pins for the Arduino Uno, and only read analog values from analog pins 0 to 5. For example:\n  * `/analog/6/123` sets pin number 6 to 123 using PWM\n  * `/analog/0` returns analog value from pin number A0 in JSON format (note that for compatibility reasons, `/analog/0/r` produces the same result)\n\n### Mode\n\nMode is to change the mode on a pin. For example:\n  * `/mode/8/o` sets pin number 8 as an output\n  * `/mode/8/i` sets pin number 8 as an input\n\n### Variables\n\nYou can also directly call variables that are defined in your sketch. Integer variables are supported by the library. Float and String variables are also supported, but only by the Arduino Mega board \u0026 by the ESP8266.\n\nTo access a variable in your sketch, you have to declare it first, and then call it from with a REST call. For example, if your aREST instance is called \"rest\" and the variable \"temperature\":\n  * `rest.variable(\"temperature\",\u0026temperature);` declares the temperature in the Arduino sketch\n  * `/temperature` returns the value of the variable in JSON format\n\n### Functions\n\nYou can also define your own functions in your sketch that can be called using the REST API. To access a function defined in your sketch, you have to declare it first, and then call it from with a REST call. Note that all functions needs to take a String as the unique argument (for parameters to be passed to the function) and return an integer. For example, if your aREST instance is called \"rest\" and the function \"ledControl\":\n  * `rest.function(\"led\",ledControl);` declares the function in the Arduino sketch\n  * `/led?params=0` executes the function\n\n### Log data to the cloud\n\nYou can also directly tell your board to log data on our cloud server, to be stored there \u0026 retrieved later or displayed on the [aREST cloud dashboard](https://dashboard.arest.io/). This is useful when you want for example to record the data coming from a sensor at regular intervals. The data is then stored along with the current date, the ID of the device sending the data, and also an event name that is used to identifiy the data. This can be done via the following commands:\n  * `rest.publish(client, \"temperature\", data);` logs the value of `data` with the event name `temperature`\n  * `https://cloud.arest.io/47fd9g/events` retrieves the last events logged by the device `47fd9g`\n  * You can also use the [aREST cloud dashboard](https://dashboard.arest.io/) to then display or plot this data in real-time on your dashboards\n  * Note that for devices not protected by an API key, the server will only store the last 10 measurements\n\n### Get data about the board\n\nYou can also access a description of all the variables that were declared on the board with a single command. This is useful to automatically build graphical interfaces based on the variables exposed to the API. This can be done via the following calls:\n  * `/` or `/id`\n  * The names \u0026 types of the variables will then be stored in the variables field of the returned JSON object\n\n### Status LED (BETA)\n\nTo know the activity of the library while the sketch is running, there is the possibility to connect a LED to a pin to show this activity in real-time. Simply connect a 220 Ohm resistor in series with a 5mm LED to the pin of your choice, and enter this line in the setup() function of your Arduino sketch:\n\n```c\nrest.set_status_led(led_pin);\n```\n\n### Lightweight mode (BETA)\n\nThere is the possibility to use a lightweight mode for aREST. This means that for commands to control the Arduino board (like digitalWrite commands), no data is returned at all. For commands that ask for data to be sent back (like asking for a variable), in this mode the library will only return the value of the data that was requested.\n\nThis mode was made for cases where the memory footprint of the aREST library has to be as small as possible, or with devices that can't send/receive a lot of data at the same time, like Bluetooth LE. To enable this lightweight mode, simply start your sketch with:\n\n```c\n#define LIGHTWEIGHT 1\n```\n\n## Troubleshooting\n\nIn case you cannot access your Arduino board via the CC3000 mDNS service (by typing arduino.local in your browser), you need to get the IP address of the board. Upload the sketch to the Arduino board, and then open the Serial monitor. The IP address of the board should be printed out. Simply copy it on a web browser, and you can make REST call like:\n\n```\n192.168.1.104/digital/8/1\n```\n\n## Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/arest/contributors.svg?width=890\" /\u003e\u003c/a\u003e\n\n\n## Backers\n\nThank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/arest#backer)]\n\n\u003ca href=\"https://opencollective.com/arest#backers\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/backers.svg?width=890\"\u003e\u003c/a\u003e\n\n\n## Sponsors\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/arest#sponsor)]\n\n\u003ca href=\"https://opencollective.com/arest/sponsor/0/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/1/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/2/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/3/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/4/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/5/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/6/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/7/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/8/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/arest/sponsor/9/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/arest/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n\n","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=3Q73345CWMYE8","https://opencollective.com/arest"],"categories":["Libraries","C++","ไลบรารีอื่นๆ"],"sub_categories":["ArduinoIDE C++ Library"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoschwartz%2FaREST","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoschwartz%2FaREST","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoschwartz%2FaREST/lists"}