I wanted to adjust the solarcells according to the sun position.
While not having found a reasonable price for an actuator with a stepper motor, I decided to use the usual linear actuator and try another trick.
The idea that inspired my work was the fact that two ldr's shoul be enough to find out if the suns position is optimal or not. If not optimal, adjust the angel of the cells by activating the actuator accordingly until the suns position, from reading the ldr's, is perfect.
the blockly script
var Differenz;
console.log('Start');console.log(formatDate(new Date(), 'hh:mm:ss'));// Initialisiere WertesetState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false);setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false);Differenz = 0;// Only during daytimeif (compareTime('08:00', '20:00', 'between', null)) { console.log('Daytime'); on({ id: [].concat(['sonoff.0.LDR01.ANALOG_Illuminance1']).concat(['sonoff.0.LDR01.ANALOG_Illuminance2']), change: 'ne' }, async (obj) => { Differenz = (getState('sonoff.0.LDR01.ANALOG_Illuminance1').val + 7) - getState('sonoff.0.LDR01.ANALOG_Illuminance2').val; console.log('Loop 1'); console.warn(Differenz); if (Differenz != 0) { if (Differenz > 0) { console.warn('Up'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, true); } if (Differenz < 0) { console.warn('Down'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, true); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, false); } } else { console.error('Stop'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, false); } });}
console.log('Start');console.log(formatDate(new Date(), 'hh:mm:ss'));// Initialisiere WertesetState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false);setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false);Differenz = 0;// Only during daytimeif (compareTime('08:00', '20:00', 'between', null)) { console.log('Daytime'); on({ id: [].concat(['sonoff.0.LDR01.ANALOG_Illuminance1']).concat(['sonoff.0.LDR01.ANALOG_Illuminance2']), change: 'ne' }, async (obj) => { Differenz = (getState('sonoff.0.LDR01.ANALOG_Illuminance1').val + 7) - getState('sonoff.0.LDR01.ANALOG_Illuminance2').val; console.log('Loop 1'); console.warn(Differenz); if (Differenz != 0) { if (Differenz > 0) { console.warn('Up'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, true); } if (Differenz < 0) { console.warn('Down'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, true); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, false); } } else { console.error('Stop'); setState('sonoff.0.PVrelay01.POWER1' /* PVrelay01 POWER1 */, false); setState('sonoff.0.PVrelay01.POWER2' /* PVrelay01 POWER2 */, false); } });}
Results
14:12:02.608 | info | javascript.0 (2102691) Start javascript script.js.common.PV_Anlage.follow_the_sun |
14:12:02.621 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Start |
14:12:02.621 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 12:12:02 |
14:12:02.621 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Daytime |
14:12:02.622 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: registered 2 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions |
14:12:16.095 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:16.096 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 1 |
14:12:16.096 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:12:16.102 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:16.103 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 2 |
14:12:16.103 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:12:26.418 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:26.418 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 3 |
14:12:26.418 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:12:26.422 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:26.423 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 1 |
14:12:26.423 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:12:36.099 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:36.099 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: -2 |
14:12:36.100 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Down |
14:12:46.148 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:46.149 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 1 |
14:12:46.149 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:12:56.104 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:12:56.105 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 3 |
14:12:56.105 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Up |
14:13:11.788 | info | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Loop 1 |
14:13:11.789 | warn | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: 0 |
14:13:11.789 | error | javascript.0 (2102691) script.js.common.PV_Anlage.follow_the_sun: Stop |
14:13:15.581 | info | javascript.0 (2102691) Stop script script.js.common.PV_Anlage.follow_the_sun |