Things used in this project

Hardware components:
Nodemcu
NodeMCU ESP8266 Breakout Board
×1
Software apps and online services:
Messenger
Logo transp
Das Coisas Taurus Platform

Code

NodeMCU codeArduino
/**
 * Leonardo Gonçalves - Das Coisas IoT Solutions
 *
 *
 *
 */

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;
String ID = "ACTUATOR_ID";
int VAR = 0;
String GET, GETCREATE;
String V;
void setup() {

  USE_SERIAL.begin(115200);
  // USE_SERIAL.setDebugOutput(true);
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  USE_SERIAL.println();
  USE_SERIAL.println();
  USE_SERIAL.println();
  digitalWrite(BUILTIN_LED, HIGH);
  for (uint8_t t = 4; t > 0; t--) {
    USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
    USE_SERIAL.flush();
    delay(1000);
  }

  WiFiMulti.addAP("SSID", "PASSWORD");

}

void loop() {
  // wait for WiFi connection
  if ((WiFiMulti.run() == WL_CONNECTED)) {
    HTTPClient http;
    URL();
    USE_SERIAL.print("[HTTP] begin...\n");
    // configure traged server and url
    //http.begin("192.168.1.12", 443, "/test.html", true, "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
    http.begin("104.131.189.228", 80, GET); //HTTP
    USE_SERIAL.print("[HTTP] GET...\n");
    // start connection and send HTTP header
    int httpCode = http.GET();
    if (httpCode) {
      // HTTP header has been send and Server response header has been handled
      USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

      // file found at server
      //if(httpCode == 200) {
      String payload = http.getString();
      int posicao = payload.indexOf(ID);
      if (posicao == -1 && httpCode == 200)
      {
        //CREATE();
      }
      String dado = payload.substring(posicao + 5, posicao + 6);
      USE_SERIAL.print("Dado: ");
      USE_SERIAL.println(dado);
      if (dado == "1")
      {
        digitalWrite(BUILTIN_LED, LOW);//ANODO COMUM, ACENDE COM LOW
      }
      if (dado == "0")
      {
        digitalWrite(BUILTIN_LED, HIGH);
      }
      USE_SERIAL.println(payload);
      //}
    } else {
      USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n");
    }
  }
  delay(1000);
}

void URL(void)
{
  GET = "http://104.131.189.228/ws/webresources/GetDigitais?key=SERIAL"; // Put your Taurus Serial Here!
  String estado = ",0)";
  GETCREATE = "http://104.131.189.228/ws/webresources/Create?key=SERIAL&&load=(";// Put your Taurus Serial Here!
  GETCREATE = GETCREATE + ID + estado;
  /*
  VAR++;
  V = String(VAR);
  USE_SERIAL.println(V);
  GET=GET+V;*/
}
void CREATE(void)
{
  URL();
  HTTPClient http;
  USE_SERIAL.println("Componente não existente, criando ...");
  http.begin("104.131.189.228", 80, GETCREATE); //HTTP
  USE_SERIAL.print("[HTTP] GET...\n");
  // start connection and send HTTP header
  int httpCode = http.GET();
  if (httpCode) {
    // HTTP header has been send and Server response header has been handled
    USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

    // file found at server
    //if(httpCode == 200) {
    String payload = http.getString();
    int posicao = payload.indexOf(ID);
  }
}

Credits

1510947 574075536015733 1458936564 n
Leonardo Ribeiro Gonçalves

Master Degree Student at Federal University of Itajuba - Brazil / Telecommunications Engineer graduated at Inatel - Minas Gerais - Brazil

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Ultrasonic Sensor with Blynk and NodeMcu
Easy
  • 229
  • 4

Protip

Interfacing ultrasonic sensor with NodeMcu and displaying the distance in the Blynk app.

Arduino WiFi Quality Signal Display
Easy
  • 204
  • 3

I wanted to understand the my home WiFi signal, so I built a device for it.

Win the Challenge: How Can You Tune Your Fidget Spinner?!
Easy
  • 4,651
  • 11

Fidget Spinners are everywhere - one of the challenges is to get the fastest spinning and longest running Spinner...build a sensor!

Control Volumio Speaker by Voice Using Google Assistant
Easy
  • 145
  • 1

Using Google Assistant to power on/off, switch tracks, change volume, and pause or play music on your Volumio speaker.

Blynk Power Meter
Easy
  • 601
  • 6

Full instructions

A simple Power Meter you can use to measure 0-26V & up to 3.2A. Add to any project to monitor voltage, current, power and energy used.

Peltier controlled from an Android App
Easy
  • 1,061
  • 6

Full instructions

Arduino temperature control sketch, managed from an Android

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login