BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

LC Technology ESP8266-01 Relay modul

esp8266

#1

Hello Guys

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 ?


Garage Door: Transmit a hex code on the TX pin of ESP-01
#2

Serial.write() ? A basic Arduino method


#3

hm

i just have startet to do sth with blynk and i dont know really much about blynk and how i can wire an blynk button to an command on the esp modul


#4

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


#5

? i want to create an button in blynk which turns the relay on.

Normal Gpios can i use.

but the hex code must come out the tx pin


#6

You need to use Virtual in such a case.Also see note to my previous post. And using Virtual is nicely explained in docs, examples…


#7

What i want to do is bring this code

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


#8

sorry but i am pretty new to this area ^^


#9

This code is working?
if so, just go to sketch buider (top right) check a basic button sketch and add your code… thats all


#10

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?


#12

@dark_phoenix Please properly format any code you post here, or it may get deleted.

Blynk - FTFC


#13
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

byte relON[] = {0xA0, 0x01, 0x01, 0xA2};  
byte relOFF[] = {0xA0, 0x01, 0x00, 0xA1};

char auth[] = "xxxx";

int ledState = false;

char ssid[] = "xxxx";
char pass[] = "xxxx";

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();

}

void setup()
{
  
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  
}

void loop()
{  
    if (ledState == true) {
      Serial.write(relON, sizeof(relON));   
      ledState = false;
    } else {
      Serial.write(relOFF, sizeof(relOFF));  
      ledState = true;
    }    
  
}

But with this code the relay goes clicking like an heart attack


#14

That is because you are running all your code in the void loop() Only run the Blynk files there and use timers for other function loops.

Read through this and other Help Center documents.

PS, none of your code has anything to do with Blynk anyhow…


#15

Hm i said that i have no idea about that

i want to connect an serial write with an Virtual button from blynk


#16

Hmmm, that is what all those documents are for… to teach you :stuck_out_tongue_winking_eye:


#17

Yeah i know but i doesnt really check this documents


#18

Good time to start… we will help guide as you learn, but this is not a programming school or code mechanic shop.


#19

Ah thanks

then i will ask an other community

thanks any way


#20

Try here… perhaps they teach those that won’t read :wink:

https://forum.arduino.cc/


#21

Gunner is right as usual.
you have to get out your code from the loop,
and it will work fine!