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:
First, we need to include all the required libraries:
#include <ESP8266WiFi.h> #include <PubSubClient.h> #include <aREST.h> #include "DHT.h"
Next, we define which pin the DHT sensor is connected to:
#define DHTPIN 4 #define DHTTYPE DHT11
Next, we create an instance of the DHT sensor:
DHT dht(DHTPIN, DHTTYPE, 15);
After that, we create clients to connect to your cloud server:
WiFiClient espClient; PubSubClient client(espClient);
Next, we create the aREST instance. This is where you need to pass the IP address of your remote cloud server as an argument:
aREST rest = aREST(client, "192.168.0.103");
You also need to give an ID to your current device:
char* device_id = "01e47f";
Next, set the Wi-Fi name and password of the sketch:
const char* ssid...