BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

SonOff T1 Uk Relais switch

Hi,

The last time I was busy with my SonOff t1. I want to switch the relays on the SonOff via blynk so that I can turn my light on and off with my mobile and by hand.

To begin with, I flashed a LED Blink sketch, but it now automatically stays on and off without me doing anything.

Does anyone know what I’m doing wrong?

Thanks in advance :slight_smile:

Here is my code:

#define BLYNK_PRINT Serial


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

char auth[] = "####";
char ssid[] = "####";
char pass[] = "####";

WidgetLED led1(V1);
int Led13 = 13;

BlynkTimer timer;

void blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
     digitalWrite(Led13, LOW);
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    digitalWrite(Led13, HIGH);
    Serial.println("LED on V1: on");
  }
}

void setup()
{

  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  pinMode(Led13, OUTPUT);

  timer.setInterval(1000L, blinkLedWidget);
}

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

Well… first off, what does your issue have to do with your title?

Secondly, aside from a unique if (led1.getValue()) check that I haven’t seen used with a Blynk widget before, it looks like it is doing what you told it to do with your timer; flash ON and OFF without your intervention.

What is it you want it to do with the LEDs?

This Blynk example might be closer to what you need.
https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=Widgets%2FLED%2FLED_StatusOfButton

1 Like

I’ve played around with the Sonoff Basics, Duals and S20s quite a bit. They’re very simple to write code for and work very well.
The T1 is a totally different proposition. If you read this info, you’ll see why:


For me, using the T1 in my homes in either the UK or Spain is a non-starter without making significant changes to the mains wiring of the houses, as I don’t have a Neutral wire available in my light switch fittings, so this switch won’t work.

If I did fancy running Neutral wires to all of the light fittings then programming the T1 is much more complex than the Sonoffs that I’ve worked with previously. From the link above, it appears that the main chip in the T1 is an ESP8285 but that it uses an EFM8BB1 as well, to manage the touch switch interfacing and to store the button status. Reverse engineering the logic for this will be a challenge when writing your own software.

The device does work with the Tasmota firmware, but that doesn’t support Blynk (as far as I can see). You could try using the data from the link above and their Tasmota source code to write your own code, or you could set-up an MQTT server to act as a bridge between Tasmota and Blynk, like this:

The T1 also uses 433MHz wireless communication, so another option is to create a two-way 433/Blynk bridge device to control it.

Hope this helps,

Pete.

1 Like

Not necessary, but it is not a “newbie” task. But I think we don’t need to invent the wheel, as there are sources (and binaries) with working code. I did a reverse engineering of DUAL some time ago (by the way - discovered some commands not met before - a touch button handling) but then found easier way and flashed a bit adopted available firmware (compiled in platformio). Personally I’m using Espurna firmware on all Sonoffs I own. But this is not the only one, nor some special recommendation for it. Just first, correctly working that I’ve met.