The relay has finally arrived

The SSR-40 DD Solid State Relay

So I’ve put the relay in place of the LED and connected it to the 12V supply for the peripheries and discovered a problem. Putting the ESP module into deep sleep switches the relay off – which is what you’d expect if you think about it.

So, here’s the original code adapted to stop that from happening, and I have changed it so that checks are done every minute rather than every 20 seconds. The ternary expression was also not suited to the job so I have replaced it with the standard and more flexible if else statement. This will not save as much energy as Serial.deepsleep but it’s only a few mAs rather than μAs:

void setup() {
Serial.begin(230400);
pinMode(D1,OUTPUT);
}
void loop() {
const int a=A0;
float b=0.8;
float c=0.0;
int d=0;
int e=0;
for(int i=0;i<10;i++){  
e=analogRead(a);
d=d+e;
delay(500);
}
c=(d*2*b)/1023.0;
if(c<=12.4){
digitalWrite(D1,0);
}else{
if(c>=13.0){
digitalWrite(D1,1);
}
}
delay(55e6);
}

And… it works! Now I can leave everything plugged in and the system will start charging the peripheries when there is sufficient charge in the leisure battery and stop when it gets too low at the end of the day or during low sunlight, thus maximising solar charging opportunities without me having to keep an eye on it.

Next project is to build the the step up transformer so that I can add the hand vac to the array for charging. Care has to be taken here so as not to overload the 12V system but I can easily swap out other peripheries while I’m around, and a good day is plenty of sunshine that charges everything by midday.