Connecting to a Waves Node with an ESP8266

Description: After a Wemos Lolin D1 Mini Pro V2 successfully connects to WiFi, it attempts to connect to a public Waves Node (nodes.wavesnodes.com) on Port 80 every 5 seconds. Two green LEDs should both turn ON if all goes well.

Connecting to a Waves Node with an ESP8266

Notes: Port 80 is used for an HTTP connection. It enables unsecured data transmission in plain text. Make sure to set the baud rate to 115200 in the Serial Monitor.

Serial Monitor connecting to a Waves Node

Supplies:

1 – Breadboard 400 Points
1 – Wemos Lolin D1 Mini Pro V2
2 – LEDs
1 – 220 Ohm Resistor

Arduino Code:

#include <ESP8266WiFi.h>

// Wi-Fi settings
const char *ssid = "Network Name";
const char *password = "password";

// Waves public node URI
const char *host = "nodes.wavesnodes.com";
const int port = 80;

#define led1 4
#define led2 5

void setup() {

  Serial.begin(115200);
  Serial.println();
  Serial.println();

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

   if (ssid == ""){
        Serial.println("WiFi ssid is empty.");
    }

    connectToWiFi();
}

void loop() {

   // Check WiFi connection and reconnect if needed
    if (WiFi.status() != WL_CONNECTED){
        WiFi.disconnect();
        digitalWrite(led1, LOW);
        digitalWrite(led2, LOW);
        connectToWiFi();
    }

    WiFiClient client;

        Serial.printf("\nConnecting to %s ... ", host);
        if (client.connect(host, port)) {
            Serial.println("connected");
            digitalWrite(led2, HIGH);   

        } else {
            Serial.println("connection failed");
            client.stop();
        }
        // Wait for the 5 sec. before next check
        delay(5000);
    
}

void connectToWiFi(){
  
    Serial.printf("Connecting to %s ", ssid);
    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    
    Serial.println(" connected");
    digitalWrite(led1, HIGH);

}

Leave a Comment

− 3 = 5