I did some tests with the individual LEDs, which I will then go to to comdarare the relays connected to the light bulb.
With this part of the code, the ESP-32 connects to the TP-Link by turning on the leds of the assigned pins
Code:
#include "WiFi.h"
const char* ssid = "MY-SSID";
const char* password = "MY-PSW";
#define N_CANALI 7
int ch;
int stato;
int chVal[N_CANALI+2] = {0};
int pins[] = {15, 2, 4, 16, 17};
void setup()
{
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
Serial.print(WiFi.localIP());
for (ch=0; ch<N_CANALI; ch++)
{
pinMode(pins[ch], OUTPUT);
digitalWrite(pins[ch], HIGH); //HIGH - LOW
}
Serial.begin(115200);
}
if what I composed it's good, now I should find the part of the "void loop ()" that can be read from the router and transmitted to the ESP.
Any advice to get started? or some other code I can take parts?
Bookmarks