-
Notifications
You must be signed in to change notification settings - Fork 8
Description
The 4 channel relay available on AliExpress comes with firmware on the nuvoTon chip on the PCB that expects the ESP01 module to respond to AT commands, but this app does not.
If you add some simple code to lie to the nuvoTon, then it thinks the module is operating as it expects and will then accept the binary commands to switch the relays. IF the nuvoTon chip does not get a repsonse to the AT commands, it will not do anything when it receives the switching command bytes.
This solution was concocted after monitoring the communication between the ESP01 module and the nuvoTon chip on the relay module with a couple of USB-serial adapters.
// pretend to be an AT device here
if(Serial.available())
{
stringIn=Serial.readStringUntil('\r');
Serial.flush();// flush what's left '\n'?
if(stringIn!="")
{
if(stringIn.indexOf("AT+")>-1)
Serial.println("OK");
if(stringIn.indexOf("AT+RST")>-1)
{
// pretend we reset (wait a bit then send the WiFi connected message)
delay(1);
Serial.println("WIFI CONNECTED\nWIFI GOT IP");
}
}
}
On boot nuvoTon sends:
AT+CWMODE=1
AT+CWMODE=1
AT+RST
RemoteRelay+ responds with "OK" to every AT command and this to the AT+RST command
WIFI CONNECTED
WIFI GOT IP
Once the nuvoTon sees WiFi is connected, it thinks its going to start the webserver with:
AT+CIPMUX=1
AT+CIPSERVER=1,8080
AT+CIPSTO=360
Now it will accept the 4 byte commands to close and open all four relays. You'll have to add code for the extra two channels, but its a bit of easy copy and paste.

