DIY Arduino consumption regulator build to use surplus solar power for auxiliary 'summer' heating. The solar power data are retrieved over SunSpec Modbus TCP. IoT monitoring with Blynk.
I have in the basement a small wellness room with a hot tub. The room has a floor heating and in the Winter there is pleasantly warm. But in Summer the floor was uncomfortable cold. After I bought a Fronius Symo Hybrid PV system in 2016, I discovered that I could use the surplus solar power in Summer to heat with a small 2kW electric heater the water of the floor heating of that room.
For the PWM regulation of "PWM to 'phase cutting' adapter box" I discovered Arduino. I am a professional software developer so the programming is the easy and fun part. And building the box was fun too. And it is still work in progress with improvements, additional functions and control. In Jun 2019 I replaced the PWM-to-phase-cutting module with Triac Dimmer module with the Triac directly controlled by the Arduino.
To regulate the water heater using surplus solar power Fronius has Ohmpilot, but it can't do the additional control which my regulator does, like commanding valves or turning off some other deferrable consumption.
I don't think someone could take this project and use it without changes, but the concept and many parts of the project can help to build a similar system. The source code is modular with multiple ino files. They are all like add-ons to the main Regulator.ino which handles only the core parts of the system. Most of the additional ino files can be simply removed, because they are special for my system or add only additional optional control and/or monitoring. I decided to go the multiple ino code separation way with almost no encapsulation of partial functionality. I could encapsulate functionality into classes with declarations in h files, but it would be only more work for me and harder to understand and reuse for a hobby coder.
- Arduino with some shield or module for networking and optional SD card reader for static web files and csv logging
- Seeed Grove Base Shield - the Grove connectors ensure firm connection of wires with simple assemble and disassemble and the shield supplies 5 V VCC for the Grove modules.
- Robotdyn AC Light Dimmer Module - Triac and zero crossing detector for direct AC phase cutting. I use additional heat sink, because for 2 kW the dimmer overheated. For 1.5 kW or less it should be good.
- Grove 30 A Relay module for Triac bypass at full power
- ACS712 20 A current sensor module
- Grove SSR V2 2 pcs for circulation pump and valves
- Grove Passive Buzzer - buzzer module for strong melody beeps
- Grove LED Bar - 10 LEDs with individual dimming requiring only any two digital pins
- 5 mm status LED with resistor as simple alternative to LED Bar
- Button - plain momentary push-button to be used with internal pin pull-up (do not use the Grove button module, it has a pull-down and when you disconnected it, the pin floats.
- Grove Wrapper - to fasten the Grove modules to a DIN rail mount (the Grove 30 A relays don't fit into Grove wrappers)
- Kemo M028N with Kemo M150 - to regulate the heating power with PWM signal.
- Grove Mosfet - for 5 V PWM with 3.3 V boards
- Grove I2C ADC module - to read the current sensor with esp8266
- Grove Temperature Sensor - it was measuring the next heating distributor to determine if the main heating is running
- Grove Relay - for 'valves back' circuit replaced with or Grove SSR V2
- Grove Dry-Reed Relay was for Balboa hot tub heating suspend activation
- any classic AVR Arduino in Uno or Mega format with some shield or module for networking
- Arduino Zero or M0 in Uno format with some shield or module for networking and with SD card to save events (no EEPROM)
- Arduino MKR board on Arduino MKR Connector Carrier (Grove compatible) with on-board WiFi, ETH Shield or other networking module
- It is neccessary for good current sensor readings to remove a capacitor on the A connector of Carier
- The An connectors have a very limited use so it doesn't have enough connectors for me.
- Nano 33 IoT with Nano Grove shield.
- Advantage of Nano IoT could be the small size and it can be used with Arduino IoT Cloud.
- The Nano IoT doesn't have external crystal oscillator. It runs on internal oscillator so millis() function and the RTC peripheral are not accurate. My looses 27 seconds in an hour.
- Additionally it would require to make an SD shield for Nano.
- TEZA2000 heating - this small electric heating is a local 'invention'
- circulation pump - set at 40 W
- Servo valves Lufberg ZV-2 - simple and cheap, it disconnects AC on end-stop
Copy the folder Regulator
from this GitHub repository into your sketch folder of Arduino IDE and the TriacLib folder goes into your libraries folder.
- Regulator.ino - core: global variables, setup() and loop() handling network, heating relays, main states
- Events.ino - data saved to EEPROM or SD for monitoring
- Modbus.ino - reads the PV SunSpec data and time
- Watchdog.ino - watchdog handling
- PowerPilot.ino - heater regulation with AC phase cutting to exactly consume the excess solar electricity calculated from SunSpec data.
- ManualRun.ino - unregulated timed heating, activated with a button or from a remote monitoring
- ElSens.ino - functions around the electricity sensor: checking expected consumption of the pump and heating and detecting disconnection by the heater's thermostat
- ValvesBack.ino - handles turning valves back to the main heating system, if EMS-ESP reports that the main heating is active
- TriacLib.h - AC dimmer module control
- Beeper.ino - Handles the speaker using tone() function. In loop handles the alarm sound if the system is in alarm state.
- Button.ino - handles push and long push ('manual run') of the physical button on the front panel
- LedBar.ino - handles visualization on the front panel LED Bar: blink, alarm, power level, count-down etc.
- StatusLed.ino - shows state with plain LED as simple alternative to LED Bar
- Telnet.ino - logging csv lines to telnet client and reading command characters sent from telnet client
- CsvLog.ino - logging heating regulation to csv files on SD card
- Stats.ino - count and store power consumption statistics
- WebServer.ino - JSON data for the web pages with optional serving of static web page files and csv files from SD card
- Blynk.ino - control from everywhere with Blynk. Screenshots of the Blynk dashboard and its configuration are in Wiki.
- ConsumptionMeter.ino - take data from secondary Fronius Smart Meter measuring this heater's consumption. Value is only logged to csv for evaluation (charts in Calc).
these are available in the git history:
- ExtHeater.ino - external/extension heater for additional consumption of surplus power
- BattSett.ino - SunSpec Modbus storage control
- SusCalib.ino - at 9 am sends 'calibration disable' for 3 hours
- Balboa.ino - defers hot tub heating if overall household consumption exceeds PV inverter's limit
- WemoInsight.ino - functions to access Belkin WiFi switch. Can be used as an alternative to ConsumptionMeter.ino.
The data subfolder contains static web pages of the regulator. The static web pages use data in json format requested from the WebServer implemented in WebServer.ino.
With Uno WiFi I had the static pages served by the esp8266 WebServer of WiFi Link firmware in the esp8266 on-board of the Uno WiFi. I added them to the SPIFFS data
folder of WiFi Link firmware.
WebServer.ino can serve the pages from SD card.
These static web pages can be started from a folder on a computer to show the data from Regulator. Only set the IP address of Arduino in script.js.
The complete project doesn't fit into the Uno flash memory. To run it, comment out less important functions in setup and loop and the builder leaves the code out.
2017/4 First board used in this project was Uno WiFi.
2018/5 Next board was Wemos D1 R2 esp8266.
2018/8 I wanted Ethernet and 32 bit MCU. I moved to Crowduino MO -SD with Ethernet Shield
2019/1 ENC28J60 Ethernet module
2019/5 secondary Fronius Smart Meter measures the heater for Fronius Solarweb
2019/6 I replaced the Kemo modules with the AC 'dimmer' module
2019/9 AVR ATmega1284p board and Ethernet Shield with W5500 (Seeed version with low profile RJ-45 connector)
2019/10 Grove Electricity Sensor CT replaced with ACS712 and Grove I2C ADC removed
2020/05 I bought Blynk points and updated the Blynk dashboard and I added charts
2020/10 I removed the temperature sensor which measured the main heating temperature for 'valves back' function. The temperature is now retrieved over network from the EMS-ESP Arduino, which adds IoT monitoring to my Buderus boiler.
2020/10 I removed code for esp8266 and nRF51 and code for power control over PWM with Kemo modules
2020/-- GitHub user stealth-ultd built his version of Regulator.
2021/02 I added extra relay for circ. pump to solve EMI from the pump motor at main relay switching
2021/03 ExtHeater.ino for more surplus consumption
2022/04 Removed separate circulation pump relay. It didn't solve EMI, which caused resets. 'Main' relay now controls only pump and valves so Triac module's ZC detector can detect zero crossing to time switching of the 'main' relay. The 2A Grove SSR module can now be the 'main' relay. EMI is solved.
2022/07 Networking with Grove UART WiFi (esp8266) on Serial with my WiFiEspAT library and ESP_ATMod sketch as firmware.
2022/08 Arduino Nano 33 IoT experiment.
2022/09 MKR Connector Carrier experiment with MKR1000 with WiFi101 library.
2023
I have no more surplus electricity because I can get back up to 2 MW of electricity fed to the network. They call it 'virtual battery'. It will likely cause downsizing of this project.
Blynk legacy ended so I migrate to Blynk IO, but because of the expected downsizing I stay limited to the Free Plan for now.
I removed ExtHeater.ino, BattSett.ino, SusCalib.ino, WemoInsight.ino, Balboa.ino