Access your Arduino from the Web

Make your Arduino accessible from anywhere via the Yaler relay.

Prerequisites

Setting up your device requires a relay domain. Please sign up to get one.

Setting up the hardware

This tutorial works with any Arduino setup supporting the Ethernet library, e.g. the EthernetShield.

Using another setup? See how to access your Arduino WiFi, the Arduino WiFi101, the Arduino CC3000 or the Arduino Yún.

Installing the library

Follow these steps to add the YalerEthernetServer library to your Arduino IDE.

  1. Download the library
    YalerEthernetServer.zip
  2. On Windows extract the ZIP to
    C:\Users\USER_NAME\Documents\Arduino\Libraries\YalerEthernetServer
    On Mac OS X extract the ZIP to
    ~/Documents/Arduino/libraries/YalerEthernetServer
  3. Close and re-open your Arduino IDE.

Trying a quick example

  1. Open the Arduino IDE and select the menu
    File > Examples > YalerEthernetServer > YalerWebService
  2. Replace RELAY_DOMAIN with your relay domain, e.g. for the relay domain gsiot-ffmq-ttd5 that would be
    YalerEthernetServer server("try.yaler.io", 80, "gsiot-ffmq-ttd5");
  3. Upload the example code to your Arduino
  4. Done. Now, see how to access your device from a Web browser or with Curl (and resolve errors).

Converting an existing Web service

How to adapt an existing Arduino Web service to make it accessible from the Web.

  1. Add the line
    #include <YalerEthernetServer.h>
  2. Replace the line
    EthernetServer server(80);
    
    with the line
    YalerEthernetServer server("try.yaler.io", 80, "RELAY_DOMAIN"); // Use YOUR relay domain
  3. If the existing code uses something like
    Ethernet.begin(mac, ip, gateway, subnet);
    replace it with the short version to enable DHCP
    Ethernet.begin(mac);
  4. Those changes together look something like this (all else remains the same)
    #include <Ethernet.h>
    #include <YalerEthernetServer.h>
    ...
    
    //EthernetServer server(80);
    YalerEthernetServer server("try.yaler.io", 80, "RELAY_DOMAIN"); // Use YOUR relay domain
    
    void setup() {
      //Ethernet.begin(mac, ip, gateway, subnet);
      Ethernet.begin(mac);
      ...
    }
    
    void loop() {
      ...
    }
  5. Done. Now, see how to access your device from a Web browser or with Curl or from iOS or from Android (and resolve errors).


Creative Commons License This work by Yaler GmbH is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.