Relay controlled by photocell with no wifi

I was looking at other options, but have discovered that I can turn off the wifi on the d1_mini via esphome so that makes this project attractive. The location is outside, I want a circuit that turns off my EV charge circuit via relay if the photocell does not have enough light. Mainly, to avoid paying expensive grid electricity if I forget to unplug it at night. So, I just program it with no wifi or ota section and it should work.

Because it’s outside, the wifi signal isnt good enough and I was afraid that the chip might have problems with an endlessly intermittent wifi signal. But I can program it on my raspberry pi via serial port and then simply put it outside. If I ever want to reprogram, I just have to bring it in and plug it in again.
So now, what I need to do is wire in a photocell and have the chip monitor the light level. When it drops below a certain level, it should shut off the relay (220v 25amp).
The relay is no problem but I havent connected a photocell to the chip. Can anyone give me pointers and possibly some yaml examples? Thanks in advance.

You could use the photoresistor in a voltage divider connected to ADC

The VCC could be the 5v or 3v but you would need to know the ohms of the photoresistor at max and min values to adjust the other R1 value so don’t destroy the ADC pin.

So if vcc is 3v PR is 1000000ohms and R1 10000ohms the voltage at ADC is about 0.03v but if PR is only 40ohms and R1 10000ohms the voltage is 2.98. I’m assumming you are using an esp32 that can take 3v at ADC rather than an esp8266 that can only take 1v. Use a multimeter to check all resistances and voltage.
You would need to pick a good relay to deal with 220v at 25 A.

This is beginning to sound dangerous…

Why not use the sun elevation?

Good point. The OP didn’t say why he gets charged more if there is insufficent light on the photoresistor. Perhaps he gets charged more if it’s cloudy rather than the position of the sun.

I get charged more after dark is all. A photocell will tell me when there is sufficient light to allow me to charge my EV from my solar panels. When the sun sets, I want the EV to stop charging, because that will be coming from the grid, at cost!
I could use a programmable timer, but that a PITA and would have to be changed weekly to adjust to dusk/dawn time changes. I could use a smart timer, but I don’t want this circuit to be on the internet (just because it’s a weak signal). I could have the d1-mini act as a smart timer also, but I don’t want the wifi to be on. So a d1_mini, with wifi off, seems like it could do the trick, and wait 60 seconds so as not to have the relay switching on and off continuously as dusk falls or the sun rises.

Here’s the relay: HiLetgo 2pcs SSR-25DA 25A 250V Solid State Relay Module: Amazon.com: Industrial & Scientific

No. I can always get an esp32, but I have 8266s on hand so I was thinking I would use one of them. Is that possible?

Honestly, I think unless you are an electrician working with 5.5kW is too dangerous.

It’s 3.5kw - 220v at 16 amps (thats my charger capacity on a NEMA 6; I use 25A relays just to be safe).
I’ve done plenty of these relay circuits on 220v machines at the woodshop I work at - 220v and 3 phase machines, table saws, 15 inch planers, dust collectors etc… You just unplug them and flip the breaker. I’ve automated the whole place so that when you turn on a machine, it opens a blast gate and turns on the correct dust collector. Using the 220v 25A relays as mentioned.
So the relay side is simple and I’ve already done it. d1_mini 5v pin and one other and its done. Yaml is easy.
It’s the photocell controller that I need to set up.

Use HA’s sun integration. It’s by far the easiest solution in this case.

Except for this…

image

1 Like

And measure the production from your solar cells isn’t a option?

Either use the esphome approach on your electric panel where you likely have EV charge line and wifi,
or if you need to do it on the charger without wifi, skip the d1-mini and connect the photocell directly to relay. More reliable especially if outdoors.

It probably is, but once again…

Unless you are thinking of manually tapping in to the PV system also?

We don’t know where his inverter is, inside, outside, with or without Wifi.

If you have 16 A available for the EV then you have a separate breaker for it in the breaker panel?
So a Shelly breaker is probably a lot easier to have someone install.
It really is a few minutes job.

16 A
Shelly Pro 1 – Shelly Europe

25A
Shelly Pro 2 – Shelly Europe

1 Like

Right, I incorrectly read “wifi” to mean “no internet” and that an ESPHome device would still be connected to an HA instance. I read the title and did a bad job of reading the very first sentence of the OP.

That said, ESPHome has a sun component too: Sun — ESPHome, which should work in this case.

1 Like

I will have a separate 20 or 30A breaker available for the EV.
But once again, I dont want something that requires a LAN, wifi or internet connection.
The simplest approach would be just a photocell and a relay, but I also don’t want it tripping on and off repeatedly. So what I think I would like to do is connect a d1_mini to the circuit so that it can set timers - ‘wait 10 minutes after photocell reaches xxx output, then switch relay’
Secondly, it seems like most of the photocell products out there are ‘dusk to dawn’ and I need dawn to dusk.
So what I really need to figure out his how to connect a photocell to the d1_mini.
Adding a relay is easy and I’ve done it before.

As far as tapping in directly to the PV system, it could probably be done but again, would most likely need to be a wifi or internet connection. I have a web based user interface that shows me solar output on my system (which uses LG panels with microinverters built in).

Here’s a simple way to add a photocell to the d1_mini, but it’s not an ESPhome approach, just arduino. Wemos and LDR example

Why to invent a wheel. You can see garden lights all around that turn on at dusk and turn off at sunrise. They usually use a $2 light sensor switch like I posted above.

I don’t believe it would work however since if this particular ESP has no network connection, it won’t be able to poll HA for the time, which is required for the Sun component to work.

# Example configuration entry
sun:
  latitude: 48.8584°
  longitude: 2.2945°

# At least one time source is required
time:
  - platform: homeassistant