ESP-01 and HW-655 Relay not working with Virtual Pin

Also, GPIO1 on the ESP-01 is the Serial TX pin, so pulsing this with HIGH/LOW data bits will mess-up the serial communications.
Also, if you’ve added a pinMopde(1,OUTPUT) statement (which would be needed to turn the LED on/off via digitalWrite commands) then you need to remove it, as this will also corrupt the serial data communications.


I have reset the baud rate to 9600 because it made no difference. It did communicate as a relay blink without Blynk at this rate.

V0 has the serial statement

I only added digitalWrite(1,LOW); as a test.

I do have a second button which is GP1 that I was testing the communication by activating the LED. I will remove this button tonight.

As your working sketch (which you didn’t share until later) uses 9600 then this is the correct baud rate and is what you MUST use.

Yes, anything that messes with GPIO1 will be a problem.



Thank you. You have solved my issue. As soon as I have taken out the GPIO button on the Blynk app the relay works perfect.

Now I want to use a GPIO input to see if the garage door is open or closed with a reed switch. I should use GPIO00 or GPIO02 for that?

Thanks again

GPIO2 is safer. If GPIO0 is pulled LOW at start-up then it will prevent the ESP-01 from booting correctly.



Didn’t listen. Used GPIO0 and if the reed switch was closed when I energised the ESP-01 it would not connect to the wifi. Easy. Open the garage then power it on. This worked.

Then I thought I would take the suggestion. Moved it to GPIO2. It does the same thing.

Any ideas what I should check please.

Difficult to say without seeing your latest sketch and having some info about how you’ve wired the reed switch.


 * *
 *   Magnetic switch 
 *   Blynk App project setup:
 *   LED widged attched to V4
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "***********";
char pass[] = "**********";

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 StatMagSwitch = 0; // switch status setting to 0 or LOW initially, door closed
int PreviousStatus = 0; // this variable holds previous door status, 0: closed, 1: open
#define MAGPIN 2            // pin for magnetic switch
BlynkTimer timer;          // Initializing blynk
WidgetLED ledDoor(V4);     //Setting led widget as virtual pin 4 first
// This function sends Arduino's up time every second to Virtual Pins (4).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App
void sendReadings()
{ int DoorChanged = 0; // this variable will check whether door has changed, 1 if changed 
  StatMagSwitch = digitalRead(MAGPIN);  // Reading Magnetic switch status 
  if (StatMagSwitch != PreviousStatus)
   DoorChanged = 1; 
  if (StatMagSwitch==1 && DoorChanged==1)
  {; //turning off if magnet is far away, i.e. Switch is HIGH
    Blynk.notify("Garage door just closed");
  if (StatMagSwitch==0 && DoorChanged==1)
    ledDoor.on(); //turning on if magnet is close, i.e. Switch is LOW
    Blynk.notify("Garage door just opened");
  PreviousStatus = StatMagSwitch;
void setup()
  Serial.begin(9600); // See the connection status in Serial Monitor
  pinMode(MAGPIN, INPUT_PULLUP); // Defining magnetic switch pin as input_pullup
  Blynk.begin(auth, ssid, pass);
  // Setup a function to be called every second
  timer.setInterval(1000L, sendReadings);

// Relay on off 
BLYNK_WRITE(V0) { int button = param.asInt(); // read button 
  if (button == 1) { 
  Serial.write(relON, sizeof(relON));
  else { Serial.write(relOFF, sizeof(relOFF)); 

void loop()
{; // Initiates Blynk; // Initiates SimpleTimer

The reed switch is NO when the garage door is open.

Okay, neither pin is really suitable for this, its just that GPIO2 is somewhat more suitable…

With your reed switch connected to GPIO2 and GND, and using an INPUT_PULLUP pinMode command, then I’d expect your device to boot correctly if the door is closed.



I will try again.

It does boot if the door is open. The only risk if the power goes off and it doesn’t boot then I can not open it with the ESP-01.

Will let you know how I get on.

I think the problem is that you’re limiting your options by using this ESP-01 relay combo.
Do you actually need two relays to open/close your garage door?

The better solution may be a Wemos D1 Mini or NodeMCU.



I only need one relay to open or close the door. Apart from it being on an app, the real value is being able to see if the door is open or not (wife sometimes thinks it may not have closed properly)

If I went to OTA updates and not Serial.begin(9600); do you think I could then use GPIO1 or GPIO3 without locking up the unit?

At the moment I am using a NO reed switch. If the door is closed then it wants to put the ESP-01 into flash mode. One option I have thought of is going to NC reed switch so with the door closed it would be happy. This would mean if I have a power failure and the door is closed it would all reset happily.


In other posts on this forum the honorable @PeteKnight has suggested 433mhz door sensors that talk to a esp8266 running a 433 listener (simpler than it sounds) and sending that info to Blynk. I have been meaning to ask him a question personally. There are apparently some devices that send Low Batter, Door Opening, and Door Closing codes. My searches on AliExpress haven’t give me a clue to which those are.

Like this. NZ$ 5.15 10% Off | 1/5/10 PCS 433MHz Wireless Magnetic Contact Switch Sensor to Detect Door Open for House Security Alarm System

Looks very interesting. I am interested to know too

The relays are controlled via serial commands, so I don’t see how this would work.

My advice would be to use a Wemos D1 Mini (or D1 Mini Pro if you need an external antenna) and a Wemos relay module. These can stack on top of each other, or be mounted on a double base.
This would give you all the pins you need.

The Wemos D1 Mini/Pro and accessories are discussed in depth towards the end of this topic:


@daveblynk @flyonly some info about 433MHz door/window contacts…

BTW, @flyonly I don’t see this as a solution to your issue with the HW-655 relay module.

I use these wireless switches:

The important thing is that they have a sticker on the back that says “Door/window contact with door open/close code 433Mhz”

This means that they send a different code when the magnet is offered-up to the side of the sensor to when it’s taken away from the sensor.
Some devices send the same code in both situations, which makes life more difficult.
There is no mention of low battery notification, but connecting the sensor to a bench PSU and slowly reducing the voltage from 1.5v causes a different code to be transmitted.
Each sensor will give different codes, so that multiple ones can be used together, but the one I have to hand does this:

700422 Low Battery
700423 Tamper switch activated (back cover removed)
700426 Open (magnet removed)
700430 Closed (magnet present)

Note that these codes are transmitted once, when a change of state occurs, not constantly.
This means that you have to constantly listen for and remember, the last code that was received. This will probably mean storing the door status in SPIFFS or LittleFS, and will require you to be able to manually reset a low battery warning when the batteries are changed, and maybe do an open/close cycle of the door if ever it’s opened manually when the MCU is offline.

These type of switches are great for domestic doors & windows if you’re building a security or ‘granny monitoring’ system, but in a garage door scenario I think I’d go for hard-wires reed or microswitches as surface mounted wiring and unsightly looking switches aren’t really such an issue, and hard-wired switches have the advantage of being able to be read at any point.


Thank you for the information. Just had a random thought. The ESP-01 is cheap. I could use one to run the relay and a second one to monitor the reed switch and have them both talking to the one blynk app?

The ESP-01 is cheap, but NodeMCU and Wemos D1 Mini dev boards aren’t exactly going to break the bank.
In the UK an ESP-10 will cost around £3.10 including postage, and a Wemos D1 Mini is around £3.70

The issue you’re going to have is that if you use two ESP-01’s then it’s very easy to display data from both in the same app project, but if you need one ESP-01 to talk directly to the second ESP-01 (to stop driving the door motor when the door is closed for example) then you’ll need to use Bridge code on both ESP-01s. Many people find this type of code difficult to comprehend (even though it’s actually quite straightforward) and for me it just adds an unnecessary degree of complexity to what should be a straightforward project.

The other issue is that the ESP-01 which controls the motor will only know if the door is closed if both ESP-01s have a connection to the Blynk server, as the communication between the two devices is via the Blynk server.
Personally, in this type of application, I’d prefer my MCU to be working autonomously, and not relying on a connection to WiFi and the Blynk server for it to control the motor in the the correct way.