Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Niccolò Avogaro
Published © GPL3+

Control Every Device From Everywhere with aRest

Want to control every device from everywhere with a mobile phone or PC just for $5? Follow this ready-to-use guide!

BeginnerFull instructions provided4 hours8,029
Control Every Device From Everywhere with aRest

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
I suggest to newbies NodeMCU V3 with the base to program that's more ready to use
×1
Relay (generic)
×1
Power Supply 3.3V/5V
×1

Software apps and online services

aRest.io
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

scheme

Code

aRest pro code

Arduino
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <aREST.h>
WiFiClient espClient;
PubSubClient client(espClient);
aREST rest = aREST(client);
// aREST Pro key 
char * key = "YOUR API KEY";
// WiFi parameters
const char* ssid = "YOUR WIFI SSID";
const char* password = "YOUR WIFI PASSWORD";
int temperature;
int humidity;
void callback(char* topic, byte* payload, unsigned int length);
void setup(void)
{
 Serial.begin(115200);
 rest.setKey(key, client);
 client.setCallback(callback);
 temperature = 24;
 humidity = 40;
 rest.variable("temperature",&temperature);
 rest.variable("humidity",&humidity);
 rest.set_name("esp8266");
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");
 char* out_topic = rest.get_topic();
}
void loop() {
 rest.handle(client);
}
void callback(char* topic, byte* payload, unsigned int length) {
 rest.handle_callback(client, topic, payload, length);
}

Credits

Niccolò Avogaro

Niccolò Avogaro

4 projects • 24 followers
Italian student, iot lover

Comments