Connecting the robot to the cloud
Now that we are sure that the wheels are working correctly, we are going to connect the robot to the aREST cloud platform, so it can be controlled from anywhere in the world.
As the sketch is quite big and takes a lot from the motor test sketch we saw earlier, I will only go through the most important points here. You can of course find the complete sketch inside the GitHub repository for the book.
It starts by importing the correct libraries:
#include <ESP8266WiFi.h> #include <PubSubClient.h> #include <aREST.h>
Then, we create the client to communicate with the aREST cloud server:
WiFiClient espClient; PubSubClient client(espClient);
We also create an instance of the aREST client:
aREST rest = aREST(client);
Then, as we saw in earlier chapters, you need to give a unique ID to the device:
char* device_id = "40ep12";
You also need to set your Wi-Fi name and password here:
const char* ssid = "wifi-name"; const char* password = ...