Connecting the ESP8266 board to your cloud server

We now actually want to test the server that we just deployed on the cloud. To do so, we are going to see how to configure the hardware we built earlier so it can connect to your own cloud server:

  1. First, we need to include all the required libraries:
    #include <ESP8266WiFi.h>
    #include <PubSubClient.h>
    #include <aREST.h>
    #include "DHT.h"
  2. Next, we define which pin the DHT sensor is connected to:
    #define DHTPIN 4
    #define DHTTYPE DHT11
  3. Next, we create an instance of the DHT sensor:
    DHT dht(DHTPIN, DHTTYPE, 15);
  4. After that, we create clients to connect to your cloud server:
    WiFiClient espClient;
    PubSubClient client(espClient);
  5. Next, we create the aREST instance. This is where you need to pass the IP address of ...

Get Internet of Things with ESP8266 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.