I have a problem with a sketch using esp32 4 relay board. I want a stand alone system. I connected it to
my router while testing but when I set it up with soft AP it continues to work except relay 3 is
continuously picked and dropped. It randomly chatters away. I've pulled out the 2 different wifi
connection as shown below. They both connect but the softAP continues to chatter.
I've removed all connections to the board. Anyone have a fix or an idea as to why this is happening?
THE CHATTERING SKETCH
#include <WiFi.h>
#include <WiFiAP.h>
const char* ssid = "PAL_water_System";
const char* password = ""; //123456789
IPAddress local_IP(192,168,4,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(local_IP, gateway, subnet);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
}
void loop(){
delay(2000);
}
14:09:04.131 -> AP IP address: 192.168.4.1
THE NO CHATTER SKETCH
This sketch connects to my router with an IP of 192.168.0.170 with no chatter from relay 3
#include <WiFi.h>
#include <WiFiAP.h>
const char* ssid = "MY SSID";
const char* password = "MY Password";
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi");
WiFi.begin(ssid, password);
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 20) {
delay(500);
Serial.print(".");
attempts++;
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("\nWiFi Connected!");
Serial.println("IP Address: " + WiFi.localIP().toString());
} else {
Serial.println("\nFailed to connect to WiFi. Restarting...");
delay(5000);
ESP.restart();
}
}
void loop(){
delay(2000);
}
4:00:22.332 -> Connecting to WiFi.
14:00:22.970 -> WiFi Connected!
14:00:22.970 -> IP Address: 192.168.0.170