A RESTful environment for Arduino

aREST

Build Status Backers on Open Collective Sponsors on Open Collective Donate

Overview

A simple library that implements a REST API for Arduino & the ESP8266 WiFi chip.

It 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.

It 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.

Boards 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 & the ESP8266 WiFi chip.

If you want to know more about aREST, go over to http://arest.io/.

Contents

  • aREST.h: the library file.
  • examples: several examples using the aREST library
  • test: unit tests of the library

Supported hardware

Arduino/Genuino Boards

The 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.

ESP8266/ESP32

The library is compatible with most of the ESP8266 modules & ESP8266 development boards, as well as most boards based on the ESP32 WiFi chip.

HTTP

For 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.

Serial

For 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.

Bluetooth LE

For Bluetooth Low Energy communications, the library has been tested with the Adafruit BLE nRF8001 breakout board.

Requirements

To use the library with Arduino boards you will need the latest version of the Arduino IDE:

For WiFi using the ESP8266 chip

To 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:

  1. Start the Arduino IDE and open the Preferences window
  2. 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.
  3. Open the Boards Manager from Tools > Board menu and install the esp8266 package (and after that don't forget to select your ESP8266 board from Tools > Board menu).

For WiFi using the ESP32 chip

To 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:

  1. Follow the install instructions from https://github.com/espressif/arduino-esp32
  2. Restart the Arduino IDE
  3. Select your ESP32 board from Tools > Board menu.

For WiFi using the CC3000 chip

For WiFi using the MKR1000 Board

To 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:

For Bluetooth Low Energy

For Cloud Access

Setup

To install the library, simply clone this repository in the /libraries folder of your Arduino folder.

Quick test (WiFi)

  1. Connect a LED & resistor to pin number 8 of your Arduino board
  2. Open the WiFi_CC3000 example sketch and modify the WiFi SSID, password & security
  3. Upload the sketch
  4. Go to a web browser and type arduino.local/mode/8/o to set the pin as an output
  5. Now type arduino.local/digital/8/1 and the LED should turn on

Quick test (Ethernet)

  1. Connect a LED & resistor to pin number 8 of your Arduino board
  2. Make sure your computer is connected via Ethernet to the board and has the IP address 192.168.2.x
  3. Upload the sketch
  4. Go to a web browser and type 192.168.2.2/mode/8/o to set the pin as an output
  5. Now type 192.168.2.2/digital/8/1 and the LED should turn on

Quick test (Serial)

  1. Connect a LED & resistor to pin number 8 of your Arduino board
  2. Open the Serial example sketch
  3. Upload the sketch
  4. Go to a the Serial monitor and set the options to "BOTH NL & CR" and "115200 bauds"
  5. Type /mode/8/o to set the pin as an output
  6. Now type /digital/8/1 and the LED should turn on

Quick test (BLE)

  1. Connect a LED & resistor to pin number 8 of your Arduino board
  2. Open the BLE example sketch
  3. Upload the sketch
  4. Use the BlueFruit LE Connect app to connect to the BLE chip
  5. Type /mode/8/o / to set the pin as an output
  6. Now type /digital/8/1 / and the LED should turn on

Quick test (ESP8266/ESP32)

  1. Connect a LED & resistor to pin number 5 of your ESP8266/ESP32 board
  2. Open the ESP8266/ESP32 example sketch and modify the WiFi SSID & password
  3. Upload the sketch
  4. Open the Serial monitor to get the IP address of the board, for example 192.168.1.103
  5. Go to a web browser and type 192.168.1.103/mode/5/o to set the pin as an output
  6. Now type 192.168.1.103/digital/5/1 and the LED should turn on

Cloud Access (Ethernet)

  1. Connect a LED & resistor to pin number 8 of your Arduino board
  2. Open the Ethernet_cloud example sketch and modify the MAC address, and also give a unique ID to your project, for example 47fd9g
  3. Make sure your shield is connected to the web via an Ethernet cable
  4. Upload the sketch to the board
  5. Go to a web browser and type cloud.arest.io/47fd9g/mode/8/o to set the pin as an output
  6. Now type cloud.arest.io/47fd9g/digital/8/1 and the LED should turn on

Cloud Access (ESP8266)

  1. Connect a LED & resistor to pin number 5 of your ESP8266 board
  2. Open the ESP8266_cloud example sketch and modify the WiFi SSID & password, and also give a unique ID to your project, for example 47fd9g
  3. Upload the sketch to the board
  4. Go to a web browser and type cloud.arest.io/47fd9g/mode/5/o to set the pin as an output
  5. Now type cloud.arest.io/47fd9g/digital/5/1 and the LED should turn on

API documentation

The API currently supports five type of commands: digital, analog, and mode, variables, and user-defined functions.

Digital

Digital is to write or read on digital pins on the Arduino. For example:

  • /digital/8/0 sets pin number 8 to a low state
  • /digital/8/1 sets pin number 8 to a high state
  • /digital/8 reads value from pin number 8 in JSON format (note that for compatibility reasons, /digital/8/r produces the same result)

Analog

Analog 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:

  • /analog/6/123 sets pin number 6 to 123 using PWM
  • /analog/0 returns analog value from pin number A0 in JSON format (note that for compatibility reasons, /analog/0/r produces the same result)

Mode

Mode is to change the mode on a pin. For example:

  • /mode/8/o sets pin number 8 as an output
  • /mode/8/i sets pin number 8 as an input

Variables

You 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 & by the ESP8266.

To 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":

  • rest.variable("temperature",&temperature); declares the temperature in the Arduino sketch
  • /temperature returns the value of the variable in JSON format

Functions

You 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":

  • rest.function("led",ledControl); declares the function in the Arduino sketch
  • /led?params=0 executes the function

Log data to the cloud

You can also directly tell your board to log data on our cloud server, to be stored there & retrieved later or displayed on the aREST cloud dashboard. 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:

  • rest.publish(client, "temperature", data); logs the value of data with the event name temperature
  • https://cloud.arest.io/47fd9g/events retrieves the last events logged by the device 47fd9g
  • You can also use the aREST cloud dashboard to then display or plot this data in real-time on your dashboards
  • Note that for devices not protected by an API key, the server will only store the last 10 measurements

Get data about the board

You 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:

  • / or /id
  • The names & types of the variables will then be stored in the variables field of the returned JSON object

Status LED (BETA)

To 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:

rest.set_status_led(led_pin);

Lightweight mode (BETA)

There 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.

This 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:

#define LIGHTWEIGHT 1

Troubleshooting

In 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:

192.168.1.104/digital/8/1

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Comments
  • ESP8266 hangs/stops responding when sent commands from different devices

    ESP8266 hangs/stops responding when sent commands from different devices

    Hi, first off thanks for your amazing work on this library!

    I'm having some teething issues - I loaded the ESP8266 example sketch and successfully switched an LED on/off via GPIO2.

    The serial terminal (115200/NL&CR) reads: r [unintelligible - couldn't copy using ctrl-c] üü‚n„bà... WiFi connected Server started 192.168.1.134

    and http://192.168.1.134/... ...mode/2/o ...digital/2/0 ...digital/2/1 ...all work as expected

    However, the device will stop responding if I send .../digital/2/0 from my computer, and then .../digital/2/1 from my phone. I don't know if this is known behaviour, or if there is some problem handling connections from multiple devices?

    I don't know how to output debugging information in browser or serial terminal either. I tried AT commands but I don't think they work.

    Sorry to bother you with my noobness!

  • compilie error by making a WiFi Weather Station With Arduino and the CC3000 chip

    compilie error by making a WiFi Weather Station With Arduino and the CC3000 chip

    I use the example from your website.

    on // Handle REST calls Adafruit_CC3000_ClientRef client = restServer.available(); rest.handle(client);

    i got an error : no matching function for call to 'aRest::handle(Adafruit_CC3000_ClientRef&)' It looks like : it do not compile at a start at // Start server restServer.begin(); displayConnectionDetails(); because i also have an error with that displayConnectionDetails(); the error say, he don´t found it in dht22???

    /Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:79: error: redefinition of 'class aREST' /Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:79: error: previous definition of 'class aREST' dht22.ino: In function 'void loop()': dht22:116: error: no matching function for call to 'aREST::handle(Adafruit_CC3000_ClientRef&)' /Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:242: note: candidates are: void aREST::handle(HardwareSerial&) /Users/matthias/Documents/Arduino/libraries/aREST-master/aREST.h:258: note: void aREST::handle(char*)

  • Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

    Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

    HI!, I keep getting this message from the serial monitor "Attempting MQTT connection...failed, rc=-2 try again in 5 seconds"

    I am using the Huzzah Feather. I have all three of the libraries installed and updated. I have internet connectivity. I've tried different device names. and successfully pinged aREST from a computer on the same network.

    From Serial Monitor:

    ..... WiFi connected Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, r..................

    Any assistance would be appreciated and Thank You in advance. :)

    ~Noobz

    The code is loaded as follows with exception of network credentials:

    // Control ESP8266 anywhere

    // Import required libraries #include <ESP8266WiFi.h> #include <PubSubClient.h> #include <aREST.h>

    // Clients WiFiClient espClient; PubSubClient client(espClient);

    // Create aREST instance aREST rest = aREST(client);

    // Unique ID to identify the device for cloud.arest.io char* device_id = "Fg3yz3";

    // WiFi parameters const char* ssid = "zzzzzzzzzz"; const char* password = "zzzzzzzzzz";

    // Functions void callback(char* topic, byte* payload, unsigned int length);

    void setup(void) { // Start Serial Serial.begin(115200);

    // Set callback client.setCallback(callback);

    // Give name and ID to device rest.set_id(device_id); rest.set_name("relay_anywhere");

    // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected");

    // Set output topic char* out_topic = rest.get_topic();

    }

    void loop() {

    // Connect to the cloud rest.loop(client);

    }

    // Handles message arrived on subscribed topic(s) void callback(char* topic, byte* payload, unsigned int length) {

    rest.handle_callback(client, topic, payload, length);

    }

  • Compile error with Adafruit_CC3000 WIFI

    Compile error with Adafruit_CC3000 WIFI

    See:

    $ ino clean && ino build
    Searching for Board description file (boards.txt) ... /usr/share/arduino/hardware/arduino/boards.txt
    Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
    Detecting Arduino software version ...  1.0.5 (1.0.5)
    Searching for Arduino core library ... /usr/share/arduino/hardware/arduino/cores/arduino
    Searching for Arduino standard libraries ... /usr/share/arduino/libraries
    Searching for Arduino variants directory ... /usr/share/arduino/hardware/arduino/variants
    Searching for make ... /usr/bin/make
    Searching for avr-gcc ... /usr/bin/avr-gcc
    Searching for avr-g++ ... /usr/bin/avr-g++
    Searching for avr-ar ... /usr/bin/avr-ar
    Searching for avr-objcopy ... /usr/bin/avr-objcopy
    src/sketch.ino
    Searching for Arduino lib version file (version.txt) ... /usr/share/arduino/lib/version.txt
    Detecting Arduino software version ...  1.0.5 (1.0.5)
    Scanning dependencies of src
    Scanning dependencies of arduino
    Scanning dependencies of SPI
    Scanning dependencies of aREST
    Scanning dependencies of CC3000_MDNS
    Scanning dependencies of Ethernet
    Scanning dependencies of Adafruit_CC3000
    src/sketch.cpp
    Linking libaREST.a
    CC3000_MDNS/CC3000_MDNS.cpp
    lib/CC3000_MDNS/CC3000_MDNS.cpp: In member function 'bool MDNSResponder::begin(const char*, Adafruit_CC3000&, uint32_t)':
    lib/CC3000_MDNS/CC3000_MDNS.cpp:153:22: error: 'AF_INET' was not declared in this scope
         int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                          ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:153:31: error: 'SOCK_DGRAM' was not declared in this scope
         int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                                   ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:153:43: error: 'IPPROTO_UDP' was not declared in this scope
         int soc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                                               ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:158:5: error: 'sockaddr_in' was not declared in this scope
         sockaddr_in address;
         ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:158:17: error: expected ';' before 'address'
         sockaddr_in address;
                     ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:159:13: error: 'address' was not declared in this scope
         memset(&address, 0, sizeof(address));
                 ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:161:34: error: 'htons' was not declared in this scope
         address.sin_port = htons(5353);
                                      ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:162:66: error: 'htonl' was not declared in this scope
         address.sin_addr.s_addr = htonl(cc3000.IP2U32(224, 0, 0, 251));
                                                                      ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:163:5: error: 'socklen_t' was not declared in this scope
         socklen_t len = sizeof(address);
         ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:163:15: error: expected ';' before 'len'
         socklen_t len = sizeof(address);
                   ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:164:20: error: 'sockaddr' was not declared in this scope
         if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                        ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:164:29: error: expected primary-expression before ')' token
         if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                                 ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:164:56: error: 'bind' was not declared in this scope
         if (bind(soc, (sockaddr*) &address, sizeof(address)) < 0) {
                                                            ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp: In member function 'void MDNSResponder::update()':
    lib/CC3000_MDNS/CC3000_MDNS.cpp:178:3: error: 'fd_set' was not declared in this scope
       fd_set reads;
       ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:178:10: error: expected ';' before 'reads'
       fd_set reads;
              ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:179:12: error: 'reads' was not declared in this scope
       FD_ZERO(&reads);
                ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:179:17: error: 'FD_ZERO' was not declared in this scope
       FD_ZERO(&reads);
                     ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:180:29: error: 'FD_SET' was not declared in this scope
       FD_SET(_mdnsSocket, &reads);
                                 ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:181:55: error: 'select' was not declared in this scope
       select(_mdnsSocket + 1, &reads, NULL, NULL, &timeout);
                                                           ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:182:36: error: 'FD_ISSET' was not declared in this scope
       if (!FD_ISSET(_mdnsSocket, &reads)) {
                                        ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:188:55: error: cannot convert 'uint8_t (*)[20] {aka unsigned char (*)[20]}' to 'uint8_t* {aka unsigned char*}' for argument '2' to 'int16_t recv(SOCKET, uint8_t*, int16_t)'
       int n = recv(_mdnsSocket, &buffer, sizeof(buffer), 0);
                                                           ^
    lib/CC3000_MDNS/CC3000_MDNS.cpp:203:53: error: too many arguments to function 'uint16_t send(SOCKET, const uint8_t*, uint16_t)'
             send(_mdnsSocket, _response, _responseLen, 0);
                                                         ^
    In file included from lib/CC3000_MDNS/CC3000_MDNS.h:47:0,
                     from lib/CC3000_MDNS/CC3000_MDNS.cpp:32:
    /usr/share/arduino/libraries/Ethernet/utility/socket.h:11:17: note: declared here
     extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP)
                     ^
    .build/uno/Makefile:43: recipe for target '.build/uno/CC3000_MDNS/CC3000_MDNS.o' failed
    make: *** [.build/uno/CC3000_MDNS/CC3000_MDNS.o] Error 1
    Make failed with code 2
    
    
  • Python calls to Library

    Python calls to Library

    First of all thank you for the libraries and the documentation, they have been very helpful. I have an issue though. I am trying to make rest calls to the CC3000 and it doesn't seem to work even though I can ping it. I have also created my own variables and were able to retrieve them through the URL. EX. http://192.168.0.100/temperature. I want to access it through Python so I tried:

    import urllib2 response = urllib2.urlopen('http://python.org/') html = response.read() print html

    We even tried to output this to a file and retrieve it with a browser and we can't retrieve anything from the CC3000 it just hangs. This python code will work though. We were able to get html pages from the Raspberry Pi web server in this manner.

    I know java script might work but I really want to use Kivy with python and retrieve my variables from the CC3000 so I can display them with python. Any help would be appreciated.

  • Error when compiling ESP8266.ino

    Error when compiling ESP8266.ino

    In file included from ESP8266.ino:10:0:
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:879:24: error: '__FlashStringHelper' does not name a type
     void addToBuffer(const __FlashStringHelper *toAdd){
                            ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:879:45: error: ISO C++ forbids declaration of 'toAdd' with no type [-fpermissive]
     void addToBuffer(const __FlashStringHelper *toAdd){
                                                 ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::send_http_headers()':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:132:188: error: 'F' was not declared in this scope
       addToBuffer(F("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: POST, GET, PUT, OPTIONS\r\nContent-Type: application/json\r\nConnection: close\r\n\r\n"));
                                                                                                                                                                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'bool aREST::send_command(bool)':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:528:40: error: 'F' was not declared in this scope
          Serial.println(F("Sending command"));
                                            ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:545:45: error: 'F' was not declared in this scope
            addToBuffer(F("{\"message\": \"Pin D"));
                                                 ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:556:58: error: 'F' was not declared in this scope
           if (!LIGHTWEIGHT){addToBuffer(F(" set to input\", "));}
                                                              ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:566:60: error: 'F' was not declared in this scope
            if (!LIGHTWEIGHT){addToBuffer(F(" set to output\", "));}
                                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:581:44: error: 'F' was not declared in this scope
             addToBuffer(F("{\"return_value\": "));
                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:589:44: error: 'F' was not declared in this scope
            if (!LIGHTWEIGHT) {addToBuffer(F("{"));}
                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:599:29: error: 'F' was not declared in this scope
                addToBuffer(F(","));
                                 ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:602:31: error: 'F' was not declared in this scope
                addToBuffer(F("\"D"));
                                   ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:619:46: error: 'F' was not declared in this scope
             addToBuffer(F("{\"message\": \"Pin D"));
                                                  ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:638:44: error: 'F' was not declared in this scope
             addToBuffer(F("{\"return_value\": "));
                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:645:44: error: 'F' was not declared in this scope
            if (!LIGHTWEIGHT) {addToBuffer(F("{"));}
                                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:655:29: error: 'F' was not declared in this scope
                addToBuffer(F(","));
                                 ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:658:31: error: 'F' was not declared in this scope
                addToBuffer(F("\"A"));
                                   ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:673:43: error: 'F' was not declared in this scope
          addToBuffer(F("{\"message\": \"Pin D"));
                                               ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:688:28: error: 'F' was not declared in this scope
             addToBuffer(F("{\""));
                                ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:720:41: error: 'F' was not declared in this scope
          addToBuffer(F("{\"return_value\": "));
                                             ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:732:40: error: 'F' was not declared in this scope
           addToBuffer(F("{\"variables\": {"));
                                            ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:758:24: error: 'F' was not declared in this scope
           addToBuffer(F("{"));
                            ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:764:26: error: 'F' was not declared in this scope
          addToBuffer(F("\r\n"));
                              ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:769:32: error: 'F' was not declared in this scope
          addToBuffer(F("\"id\": \""));
                                    ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:777:51: error: 'F' was not declared in this scope
          Serial.print(F("State of buffer at the end: "));
                                                       ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(char*)':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:839:39: error: 'F' was not declared in this scope
         Serial.print(F("Added to buffer: "));
                                           ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(uint16_t)':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:853:23: error: 'itoa' was not declared in this scope
       itoa(toAdd,number,10);
                           ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::addToBuffer(int)':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:862:23: error: 'itoa' was not declared in this scope
       itoa(toAdd,number,10);
                           ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In member function 'void aREST::sendBuffer(T&, uint8_t, uint8_t)':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: error: there are no arguments to 'F' that depend on a template parameter, so a declaration of 'F' must be available [-fpermissive]
             Serial.print(F("Sent buffer: "));
                                           ^
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
    ESP8266.ino: In function 'void setup()':
    ESP8266.ino:37:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    ESP8266.ino:38:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    ESP8266.ino:41:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    ESP8266.ino:44:18: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    ESP8266.ino:45:26: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    In file included from ESP8266.ino:10:0:
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h: In instantiation of 'void aREST::sendBuffer(T&, uint8_t, uint8_t) [with T = WiFiClient; uint8_t = unsigned char]':
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:251:27:   required from here
    /Users/Kanin/Documents/Arduino/libraries/aREST/aREST.h:934:39: error: 'F' was not declared in this scope
             Serial.print(F("Sent buffer: "));
                                           ^
    Error compiling.
    

    I think it is about Arduino ESP8266 IDE doesn't support __FlashStringHelper right?

  • ESP8266WiFi.h: No such file or directory

    ESP8266WiFi.h: No such file or directory

    $ git clone https://github.com/esp8266/Arduino.git
    $ cd Arduino/build
    $ ant dist
    $ ...
    $ cd arduino-1.6.1/libraries
    $ git clone https://github.com/marcoschwartz/aREST
    

    I got this error : ESP8266.ino:9:25: fatal error: ESP8266WiFi.h: No such file or directory

  • relay anywhere sketch

    relay anywhere sketch

    I loaded the relay anywhere sketch and changed the required parameters. Using the DOIT ESP12E DEVKIT. Well several days ago it was actually working pretty darn good. Now it no longer works at all. Have reloaded it many times and found one thing weird. If my device_id is less than 11 characters the browser will eventually just time out. However if my device_id is 11 characters or longer I will at least get a message back as follows {"message":"Requested device not found"}. But thats is as far as it goes. No matter the combination of letters and numbers in the device_id, as long as it is less than 11, the browser will simply time out with that 504 error I think it is. Weird stuff for sure. Thank you Darryl...

  • Eliminate or Debug Error 504 Gateway time-out

    Eliminate or Debug Error 504 Gateway time-out

    Problem

    I've got a recurring #152 problem with server. That error is in summary: after continuos use, device ID becomes unusable. My ID is 000000 . I can change device's ID, however problem will persist.

    Warning

    I think If someone creates a random ID's generator, all ID's will break in no time.

    Possible Solutions

    1. I think it's necessary to add a way for debugging, maybe a message like:
    {"message":"ERROR_XXX: there are X devices using the same ID, please use another one."}
    

    of maybe:

    {"message":"ERROR_XXX: server error, please try again later."}
    
    1. Add a SECRET KEY on device, and prevent other devices to use the same ID for X hours.

    Thank you for your time.

  • Wemos D1 and Pinout

    Wemos D1 and Pinout

    Hey guys! awesome work, just trying to set this up on my wemos D1 R2 board, got it working via web browser via the could.arest.io and by IP address. but here's the catch, I still cannot control the Led via D1-D8. I know the led is set up right because if i plug it in D4 it lights up, (still not controllable).

    Anyone seen this sort of thing before? Is it a issue with the board?

  • Compilation Error:  conversion from 'String' to 'char*'

    Compilation Error: conversion from 'String' to 'char*'

    Hello,

    I am currently working from the Arduino Home Automation Projects book in chapter 1. When I load the following code, I get a compilation error as shown below:

    I'm using the IDE 1.5.8 if that helps. Thank you for any guidance.

    Code: // Libraries

    include <SPI.h>

    include <aREST.h>

    // Motion sensor ID String xbee_id = "2";

    // Create ArduREST instance aREST rest = aREST();

    void setup() {

    // Start Serial Serial.begin(9600);

    // Give name and ID to device rest.set_id(xbee_id); }

    void loop() {

    // Handle REST calls rest.handle(Serial);

    }

    Error Message:
    HomeAuto_Chap1_RevA.ino.ino: In function 'void setup()': HomeAuto_Chap1_RevA.ino.ino:17:22: error: no matching function for call to 'aREST::set_id(String&)' HomeAuto_Chap1_RevA.ino.ino:17:22: note: candidate is: In file included from HomeAuto_Chap1_RevA.ino.ino:3:0: E:\Documents\Arduino\Sketches\libraries\aREST/aREST.h:714:6: note: void aREST::set_id(char_) void set_id(char *device_id){ ^ E:\Documents\Arduino\Sketches\libraries\aREST/aREST.h:714:6: note: no known conversion for argument 1 from 'String' to 'char_' Error compiling.

  • rest.function() bug:  command is improperly passed to function

    rest.function() bug: command is improperly passed to function

    I am using modified Ethernet example (code below). I use postman to send GET request on following url: http://192.168.0.192/led?command=1 I should be always getting the same result: { "return_value": 1, "id": "008", "name": "dapper_drake", "hardware": "arduino", "connected": true } but 50% of requests have correct return value: 1. and the other half have return value 0 or I get 3000 lines of garbage see here: https://pastebin.com/vY1vcL4t.

    Could you direct me to what can be causing this issues?

    arduino code:

    #include <SPI.h>
    #include <Ethernet.h>
    #include <aREST.h>
    #include <avr/wdt.h>
    
    // Enter a MAC address for your controller below.
    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xFE, 0x40 };
    
    // IP address in case DHCP fails
    IPAddress ip(192, 168, 0, 20);
    
    // Ethernet server
    EthernetServer server(80);
    
    // Create aREST instance
    aREST rest = aREST();
    
    void setup(void)
    {
      // Start Serial
      Serial.begin(115200);
    
      // Function to be exposed
      rest.function("led",ledControl);
    
      // Give name & ID to the device (ID should be 6 characters long)
      rest.set_id("008");
      rest.set_name("dapper_drake");
    
      // Start the Ethernet connection and the server
      if (Ethernet.begin(mac) == 0) {
        Serial.println("Failed to configure Ethernet using DHCP");
        // no point in carrying on, so do nothing forevermore:
        // try to congifure using IP address instead of DHCP:
        Ethernet.begin(mac, ip);
      }
      server.begin();
      Serial.print("server is at ");
      Serial.println(Ethernet.localIP());
    
      // Start watchdog
      wdt_enable(WDTO_4S);
      
    }
    
    void loop() {
    
      // listen for incoming clients
      EthernetClient client = server.available();
      rest.handle(client);
      wdt_reset();
    }
    
    // Custom function accessible by the API
    int ledControl(String command) {
      Serial.print("passed command: ");
      Serial.println(command);
      // Get state from command
      int state = command.toInt();
      return state;
    }
    

    This is serial monitor output:

    server is at 192.168.0.192
    passed command: 1
    passed command: 
    passed command: 1
    passed command: ! @[email protected]!1 1
    Asar!Aae`t  @oataa`Ran`iae!7 2!.
    passed command: 1
    passed command: 
    passed command: 1
    passed command: 
    passed command: 1
    passed command: 
    passed command: 1
    passed command: 
    passed command: 1
    
    
  • Feat h cpp files

    Feat h cpp files

    Standard structure of h and cpp file allows for using this library in more complex projects where several libraries need to link this file. aims at fixing #278. Note: the code has not been changed as to my best knowledge, except, I needed to add another "include ethernet.h " in line 75 of the header file for my compiler to work. Might need to be changed

    The tcc file contains all implementations of template functions. This avoids the need to specifically instantiate each template for each variable type, see

    link1-definition

    link2-explanation

    This code has been tested with an arduino mega 2560 and the default ethernet example and works well at least in this setup. Other setups have not been tested so far.

  • To support Ethernet2.h library, this should be

    To support Ethernet2.h library, this should be "ethernet_h"

    This line:

    https://github.com/marcoschwartz/aREST/blob/bcb3e3583cf75890598bf68612b5c36d324d2dd8/aREST.h#L574

    Should include the Ethernet2.h support and thus the variable "ethernet_h" should be also added.... (ethernet_h_ || ethernet_h)

    Is there any other reason why this variable was not included but the release 2.7.4 says that is supports Ethernet2?

  • Multiple warnings ISO C++ forbids converting a string constant to 'char*' [-Write-strings]

    Multiple warnings ISO C++ forbids converting a string constant to 'char*' [-Write-strings]

    Been getting multiple warnings in my IDE when calling declaring the rest function.

    This code: rest.function("button1", pushButton1); // Chapel projector power on

    generates the warning 'ISO C++ forbids converting a string constant to 'char*'.

    I am of the programming mind to avoid even warnings in my code, because today's warnings may be tomorrow's errors. One thing I did was change the code to this: rest.function((char*)"button1", pushButton1); // Chapel projector power on This did get rid of the warning, but I have not tested it yet. (Need to go to my church to implement it. (The Arduino Mega is there with the equipment I am working on.)

    Is there a reason that the scripted examples are causing these warnings?

Related tags
Arduino library for making an IHC in or output module using an Arduino

Introduction This is an Arduino library for making an IHC in or output module using an Arduino. (IHC controller is a home automation controller made b

Mar 26, 2020
ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT Cloud

ArduinoIoTCloud What? The ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT

Dec 16, 2022
Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.
Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.

107-Arduino-MCP2515 Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames. This library is prepared to interface easily

Nov 16, 2022
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.
Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

107-Arduino-NMEA-Parser Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages. This library

Jan 1, 2023
Arduino library for providing a convenient C++ interface for accessing UAVCAN.
Arduino library for providing a convenient C++ interface for accessing UAVCAN.

107-Arduino-UAVCAN Arduino library for providing a convenient C++ interface for accessing UAVCAN (v1.0-beta) utilizing libcanard. This library works f

Jan 2, 2023
Arduino web server library.

aWOT Arduino web server library. Documentation 1. Getting started Hello World Basic routing Application generator Serving static files 2. Guide Routin

Jan 4, 2023
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485
Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485

ABB Aurora protocol You can refer the complete documentation on my site ABB Aurora PV inverter library for Arduino, esp8266 and esp32 I create this li

Nov 22, 2022
MCP2515 CAN Controller Driver for Arduino

MCP2515 CAN Controller Library for Arduino Compatibility with the ACAN library This library is fully compatible with the Teensy 3.x ACAN library https

Dec 13, 2022
Arduino library for the MCP2515 CAN Controller

MCP2515 CAN Controller Library for Arduino Compatibility with the ACAN library This library is fully compatible with the Teensy 3.x ACAN library https

Dec 18, 2022
Arduino CAN driver for MCP2517FD CAN Controller (in CAN 2.0B mode)

MCP2517FD CAN Controller Library for Arduino (in CAN 2.0B mode) Compatibility with the other ACAN libraries This library is fully compatible with the

Dec 22, 2022
Distribution of Arduino driver for MCP2517FD CAN controller (CANFD mode)

MCP2517FD and MCP2518FD CAN Controller Library for Arduino (in CAN FD mode) Compatibility with the other ACAN libraries This library is fully compatib

Dec 21, 2022
CAN / CANFD Arduino Library for Teensy 4.0

CAN Library for Teensy 4.0 / 4.1 It handles Controller Area Network (CAN) for CAN1, CAN2 and CAN3, and Controller Area Network with Flexible Data (CAN

Dec 9, 2022
Unified interface for selecting hardware or software SPI implementations on Arduino platforms

AceSPI Unified interface for selecting hardware or software SPI implementations on Arduino platforms. The code was initially part of the AceSegment li

Oct 22, 2021
Unified interface for selecting different implementations for communicating with a TM1637 LED controller chip on Arduino platforms

AceTMI Unified interface for communicating with a TM1637 LED controller chip on Arduino platforms. The code was initially part of the AceSegment libra

Feb 2, 2022
Unified interface for selecting different I2C implementations on Arduino platforms

AceWire Wrapper classes that provide a simple, unified interface for different I2C implementations on Arduino platforms. The code was initially part o

Dec 14, 2022
Analog Devices Analog Digital Converter AD7173 Arduino library

AD7173-Arduino Analog Devices AD7173 analog digital converter Arduino library Mostly tested setup for this library: 1007 data rate external crystal co

Nov 20, 2022
Arduino library for nRF51822-based Adafruit Bluefruit LE modules

This library is for all nRF51 based Adafruit Bluefruit LE modules that use SPI or UART. Current nRF51 based Bluefruit LE products include: Bluefruit L

Nov 6, 2022
Arduino library for the Adafruit FONA

Adafruit FONA Library This library requires Arduino v1.0.6 or higher This is a library for the Adafruit FONA Cellular GSM Breakouts etc Designed speci

Dec 15, 2022
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.

Adafruit IO Arduino Library This library provides a simple device independent interface for interacting with Adafruit IO using Arduino. It allows you

Dec 23, 2022