Wemos/lolin Esp8266 and relay misbehaving

This is weird. I have two identical wemos d1’s with piggyback Ed wemos relays. They are powered from 5v USB outlets and run fine. On the blynk app I have a button widget set as an on/off switch that directly sets the digital output D1 high or low.
When the wemos is running if I press the app button I hear the relay click and the relay switches. But 6 to 10 seconds later the relay clicks off, but the app button says it is still on.
On one of the wemos d1’s the relay is set according to rules (for example, if target temp<room temp then set D1 to high, checked every 10seconds) and this seems to work.
I am assuming that the relays are not faulty. I am assuming that the normal action of directly controlling the digital outputs from the app should not cause this behaviour. There is plenty of power available from the USB supplies ~2.1amps.
Has anyone had a similar issue?

I have searched blynk for this issue which doesn’t seem to have been covered before.
Wemos d1 mini with relay shield, WiFi connection.
Samsung s9 running blynk and standard blynk server


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <TimeLib.h>
#include <Wire.h>
#include <WEMOS_SHT3X.h>


// Auth Token same as controlEsp
// This writes data to the same server as controlESP so make sure different pin numbers are used
char auth[] = "xxxxxxxxx”;

// WiFi details:
char ssid[] = "xxxxxxxx";
char pass[] = "xxxxxxxxx";

// Vars to hold data:
float t; // temperature
float h; // humidity
int up; // up time

BlynkTimer timer;
SHT3X sht30(0x45); // instance of sht30 temp/humidity sensor

void getSHT(){
 if(sht30.get()==0){
    t = sht30.cTemp;
    h= sht30.humidity;
    Blynk.virtualWrite(V10, t);
    Blynk.virtualWrite(V11, h);
  }
}

void espUptime() {
  up = millis()/10000;
  Blynk.virtualWrite(V122, up);
}

void setup(){
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);

  timer.setInterval(60000L, getSHT); // update temp & hum every 60 seconds
  timer.setInterval(10000L, espUptime);
  ArduinoOTA.setHostname("espAJPM6e6f");
  ArduinoOTA.begin(); // OTA initialization
}



void loop(){
  Blynk.run();
  timer.run();
  ArduinoOTA.handle();
}



This doesn’t make any sense, what you’re describing shouldn’t work.

In the Blynk app, when you choose a digital pin you have choices like this:

image
These are GPIO numbers, and don’t correspond to the numbers that are screen printed on to the Wemos D1 Mini.

Pin D1 on the Wemos (which is what the relay is connected to on the relay shield) is actually GPIO5

If what you meant to say is that you have a button connected to Digital Pin GP5 then the first part of your story would make sense.

Is this the case?

Also, what pins are your SHT30 (very appropriately named) sensors connected to?

Ans, can you confirm that the two Wemoses (if that’s the correct plural) are running code that uses different Auth codes?

Personally, I never do direct digital pin manipulation via the app, I always attach my switch widgets to virtual pins and handle the digital writes in code, but that’s a conversation for another day.

Pete.

Attached is a screenshot from the blynk app

The sht30 seems fine and is connected via another shield, not sure what cooections it uese but it seems to work.

The wemii’s(?) are using different Auth keys. Both have an override button on the app interface, really just for testing, however they both exhibit the same issue. I’m thinking it could be a hardware issue - the blynk app sets the output value, but hasn’t enough power to hold it open so the relay closes. The blynk app thinks it’s still open. My other app sends regular commands to set the output value (according to temperature and schedule checks but probably every 6 to 10 secs).
Has anyone else with wemos d1 and wemos relay board had a similar issue?

I’ve used a Wemos on a triple base with two relay shields (one modified to use a different GPIO) all powered via the Wemos micro USB without any problems.

It might be worth changing your power cable and a different power source though.

Pete.

That’s the weird thing. Both exhibit the same behaviour, one is powered from a 2.1a Samsung charger, the other from a USB equipped wall plate.
I’ll try different cables to see if it makes any difference.
Thanks for your input.

Try a basic sketch, with no Blynk code, that just activates the relay at startup and does nothing else.
You’ll soon no if you have a hardware issue.

Pete.