I bought LC Technologyy ESP8266-01 Relay Modules from Amazon.
They working !
But my problem is that an MCU is on the relay circuit board which wants an tx command (0xA0, 0x01 0x00, 0xA1 to turn on and 0xA0, 0x01 0x00, 0xA2 to turn off)
Does smb got an idea how i can send this hex codes over the tx/rx conectors of the esp8266-01 modul with blynk to the mcu ?
But here no Blynk need to be involved. I mean, you will not find any docs here regarding Serial.write(). It is in Arduino References. Serial port on ESP is defined the same way as with UNO, (for example).
Just a note: Serial port in such case needs to be reserved exclusively for external MCU. All debug outputs have to (or at least ought to) be disabled! So BLYNK_PRINT_SERIAL have to be redirected/disabled
byte relON[] = {0xA0, 0x01, 0x01, 0xA2}; //Hex command to send to serial for open relay
byte relOFF[] = {0xA0, 0x01, 0x00, 0xA1}; //Hex command to send to serial for close relay
int ledState = false;
unsigned long previousMillis = 0;
const long interval = 2000; // 2 seconds
// the setup function runs once when you press reset or power the board
void setup() {
// initialize serial:
Serial.begin(9600);
}
// the loop function runs over and over again forever
void loop()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == true) {
Serial.write(relON, sizeof(relON)); // turns the relay ON
ledState = false;
} else {
Serial.write(relOFF, sizeof(relOFF)); // turns the relay OFF
ledState = true;
}
}
}
in an connection with blynk but only to make the output set to toggle like on and off
It’s OK, so I advice you to read the docs.blynk.cc You will find there BLYNK_WRITE(VPIN) function description, and how to pass parameters (here- the button state). Just move the content of your loop function (without timers in this case) to BLYNK_WRITE(V0) and go on. The rest (i.e toggling the relay) you already have up, and working I assume?