Remotely controlled Power Socket 250V/10A

This is my first project which I put in here and I do not know if it does not happen again but it probably will not hurt :slight_smile:
I made thanks to BLYNK and esp8266 remotely controlled Power Socket via wifi and it looks like this




I used:
1x esp8266-01
1x 1-way 250V/10A relay switch
1x voltage stabilizer module ams1117 3.3v for esp8266
1x converter from 250V AC to 5V DC
1x PowerSupply case
and some wires
This is a schematic :stuck_out_tongue:

And example code:

#define BLYNK_PRINT Serial


#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[] = "";

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1);
}

BLYNK_WRITE(V1) {
  if (param[0] == 1) {
    digitalWrite(2, LOW);
  } else {
    digitalWrite(2, HIGH);
  }
}

void setup()
{
  digitalWrite(2, HIGH);
  pinMode(2, OUTPUT);
  // Debug console
  Serial.begin(9600);

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

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

Everything you need in the application is button widget of V1 to ON and OFF socket.
Enjoy!

2 Likes

It’s nice to make your own stuff sometimes, rather than buying the off the shelf options.

Can I suggest a few minor modifications…

  1. remove those unused plastic stand-offs to allow you to position the relay and the other stuff further apart, and fix everything down so that it can’t move.

  2. think about adding an LED to indicate things, like connecting to Wi-Fi/ Blynk, and the on/off status of the relay.

  3. think about adding a physical push button to allow control without the app. You’d need to synchronise the app button of course. You might also want to add a non-blocking routine so that the physical button can be used if the Wi-Fi or Blynk server are down.

  4. adding an OTA update routine would be handy if you want to update your code without disassembling the socket.

The LED, physical switch and OTA (but not non-blocking code) are included in the example code for these switches…

Pete.

3 Likes

Thanks Pete :slight_smile:
Thanks for advice. I thought about solutions like LED or button, but for that I would need a “larger lab” and a bigger contribution :stuck_out_tongue:
and for now, I’ve probably done it the easiest way to give others room to show off and give it as an example.
The OTA updates is something that I have to learn

Pete i have got a question.
does generic ESP-01 module have enough memory for AndroidOTA implementation?

If it has 1MB or 4MB then yes. There are some 512kB boards out there I think, and you wouldn’t manage OTA with them.

I think the Expressif Flash Download Tool will tell you for your board. It may list the memory size in Mbits. 512kB is 4Mbits, 1MB is 8Mbits and 4MB is 16Mbits.

If you have a 1MB board then flash itwith the option of 1MB (no SPIFFS).

I also forgot to mention that my preference is to have a Wi-Fi switch power-up in the Off mode, rather than syncing with the Blynk server on start-up. This is just for safety/economy in case you forget that an appliance is on in the app, but appears off because there has been a power interruption.

Pete.

1 Like

@zaborejszyn where can I find the case? Thanks! :blush:

1 Like

I bought the housing in my local store in Poland. Forgive me but I can not find something similar in a global store.
I can provide a link from my:


Type in “power socket case” in google and maybe you will find something similar

Available on eBay UK…

Pete.

1 Like

https://www.tme.eu/gb/katalog/#id_category=100628&search=enclosure+power+supplies&s_field=accuracy&s_order=DESC&visible_params=2%2C316%2C69%2C324%2C323%2C325%2C68&used_params=316%3A40311%3B

cheaper

1 Like