Reset after disconnect

I have a particle core connected to a relay to turn on a fan using Blynk. If Blynk disconnects when the fan is on, the fan goes off and stays off even after Blynk reconnects. The Blynk button stays on through the cycle. If this was more remote, I wouldn’t know if the fan was on or not based on Blynk. Does anyone have a solution to this?
I also have an ESP8266 connected to my coffee machine and I use Blynk to turn it on and off. If the main power goes off then on, the coffee pot goes on but Blynk still says it is off. Again, another problem if the ESP8266 is in a remote location and the connection is more critical than a coffee machine. The coffee machine also has a temp sensor for feedback. Does anyone have a solution to this?
This is the coffee machine sketch. The fan sketch is just blynk run():.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

float oldTemp;
char auth[] = “zzzzzzzzzzzzzzzzzzzzzzz”;
void setup()
while (Blynk.connect() == false) {
Blynk.notify(“Device started !”);
void loop()
float temp;
temp = DS18B20.getTempCByIndex(0);
Serial.print("Temperature: ");
while (temp == 85.0 || temp == (-127.0));
Blynk.virtualWrite(1, temp);;

Yes, add above setup():


At start up of the sketch it will get the latest value stored of V1 pin on the server and resume your fan :slight_smile:

Thanks, Uploaded and waiting for the next disconnect for a real world test, but the fan state does not rely on V1. The fan is on D5 so I added:
instead. Oh, and it looks like Blynk disconnects 6-7 times over a 6 hr period if my History Graph down spikes are an indication.

I’ll try this on my coffee machine also even though it is a different disconnect issue, mains vs Blynk.

Ok, that should do the trick. I think physical pins are synced too, but you got the idea :slight_smile:

Are you using SSR on your coffee machine? This solved one of my ‘mains vs coffee’ machine brawls…

I have a 2k dollar coffeemachine, so I’m not messing with mine xD

But an SSR seems the way to go. I had a relay to my old coffeemachine once, but it didn’t pan out as planned. There is still too much manual work involved like filling it, making it ready the evening ahead etc. So I just bought a really expensive lean and mean bean machine, of you get my drift, lol.

1 Like

@randobi99 I just added example showing how single value state could be stored and restored.

1 Like

I don’t switch the main power so no relay or SSR is needed. I have an optocoupler on GPIO 0 wired to the start brew button on the coffee maker so the blynk button acts just like the physical button and both work. What I have to figure out is why, when I plug it in for example, GPIO 0 goes high. It must be an ESP8266-01 issue because I don’t have that problem with my garage door opener using and ESP8266-12 wired the same way.
Thanks for your thoughts.

Don’t all ESP’s need GPIO 0 HIGH for sketches to run?
Are you using a different pin on the “12” compared with the “1”?
Once you have debugged everything you should be able to use the rx pin on the “1” (GPIO 3)

I made a board with both GPIO’s connected to transistors. Neither pin is pulled high while running. The ESP-12 uses GPIO 13 but no transistor since it only controls an optocoupler. Maybe the transistor on the “1” is the problem. Since I’m not controlling a relay I’ll wire around the transistor to see if that fixes the problem.
This should be a picture of the board.