Embedded systems · Renewable energy · IoT

Microsolar: a DIY solar energy router

A complete residential micro-solar prototype combining photovoltaic generation, real-time energy measurement, embedded control and a browser-based interface. The system prioritizes self-consumption and redirects surplus power to a water heater instead of exporting it to the grid.

ESP32embedded controller
≈ BGN 700prototype component cost
Up to 1,000 kWhestimated annual generation
Local web UIcontrol and configuration

Project overview

Microsolar is a practical engineering project designed to make small balcony or residential photovoltaic systems easier to understand, build and operate. It covers the complete workflow: selecting the electrical components, mounting the panels, assembling the controller, programming the firmware, measuring household power flow and configuring the finished system.

The controller continuously observes the direction and magnitude of grid power. When solar production exceeds immediate household demand, it controls a high-power AC dimmer and transfers the available surplus to a standard electric water heater. This increases local use of generated energy and reduces unwanted feed-in.

Embedded C++ESP32Energy meteringZero-export controlAC power controlWeb interfaceOTA updates3D-printed enclosure

Residential installations

Examples of compact photovoltaic installations on balconies and building façades.

How the system works

Generate

One or more photovoltaic panels feed a grid-tied microinverter.

Measure

A JSY-MK-194T energy sensor measures household import and export in real time.

Decide

ESP32 firmware calculates the available surplus and applies control rules.

Route

An AC dimmer proportionally transfers surplus energy to a water heater.

Engineering implementation

Hardware

  • ESP32 development board
  • JSY-MK-194T bidirectional energy meter
  • 40 A, 600 V AC dimmer with 3.3/5 V logic
  • 5 V / 30 A relay and isolated power supply
  • I²C OLED status display and local push button
  • Grid-tied microinverter and photovoltaic panels
  • Custom 3D-printed, flame-retardant PETG enclosure

Firmware and interface

  • Embedded C++ firmware developed with Arduino IDE
  • Serial communication with the power meter
  • Closed-loop surplus-power control
  • Manual relay override and scheduled operation
  • Local responsive web interface
  • Display and time-offset configuration
  • Browser-based OTA firmware updates

What I engineered

System integration

Selected and integrated the sensing, processing and power-control components into a functioning end-to-end prototype. Designed the wiring approach, enclosure layout and installation workflow.

Embedded software

Configured the ESP32 toolchain, integrated the measurement sensor, implemented control and scheduling logic, and exposed device functions through a local web interface.

Testing and documentation

Validated the system through staged bench and installation tests, documented component sourcing and assembly, and published downloadable firmware, libraries and enclosure files.

Product thinking

Optimized for affordability, understandable installation and practical household value while keeping the design modular enough for future improvements.

Step-by-step documentation

English build guide

This guide summarizes the complete build process for the Microsolar energy router, from component selection and ESP32 setup to enclosure assembly and operation. Read the full guide before starting and adapt the installation to your local electrical code.

0. Safety and scope

Danger: mains voltage can cause fire, serious injury or death. The low-voltage ESP32 work may be assembled and tested on a bench. Connections to the grid, microinverter, AC dimmer, relay, current transformer and water heater must be designed, installed and verified by a qualified electrician in accordance with local regulations. Isolate and prove dead before opening any enclosure.
  • Use correctly rated protective devices, wire sizes, terminals and enclosures.
  • Keep low-voltage logic physically separated from mains wiring.
  • Use strain relief, insulation, earthing and flame-retardant materials.
  • Confirm balcony load capacity, wind loading and panel anchoring.
  • Do not energize an incomplete or uncovered assembly.

1. Gather the components

Photovoltaic system

  • One or more photovoltaic panels (the prototype uses approximately 450 W panels)
  • Grid-tied microinverter matched to the panels and local grid
  • 6 mm² solar cable and compatible MC4 connectors
  • Solar crimping tool and insulated installation hardware
  • Structurally suitable mounting brackets

Energy router

  • ESP32 development board
  • JSY-MK-194T bidirectional energy meter
  • 40 A / 600 V AC dimmer with 3.3 V or 5 V logic
  • 5 V / 30 A relay
  • I²C OLED display, push button and isolated DC supply
  • M3 screws, heat-set inserts and wiring accessories
  • Flame-retardant, UL-rated PETG for the enclosure

The original prototype cost was approximately BGN 700. Prices, availability and required certifications vary by country.

Microsolar system architecture
System concept: PV generation, microinverter, household loads, measurement and surplus routing.

2. Configure Arduino IDE and test the ESP32

  1. Download and install Arduino IDE.
  2. Open File → Preferences and add this Board Manager URL:
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  3. Open Tools → Board → Board Manager, search for esp32 and install the Espressif Systems package. The original build used version 2.0.11; newer versions may require library updates.
  4. Connect the ESP32 with a data-capable USB cable. Select Tools → Board → NodeMCU-32S and choose the correct COM port.
  5. Upload the LED test below. A blinking onboard LED confirms that the board, USB driver and toolchain are working.
void setup() {
  pinMode(2, OUTPUT);  // Onboard LED
}

void loop() {
  digitalWrite(2, HIGH);
  delay(500);
  digitalWrite(2, LOW);
  delay(500);
}

3. Configure the JSY-MK-194T energy meter

The prototype changes the meter communication speed from 9600 baud to 38400 baud before loading the final router firmware.

  1. With the assembly unpowered from mains, connect the meter’s low-voltage communication pins to the ESP32 according to the diagram below.
  2. Download and upload the baud-rate conversion sketch.
  3. Run the sketch for several seconds. Power down the low-voltage setup before changing wiring.
  4. Use 38400 baud in the final firmware configuration.
JSY-MK-194T to ESP32 communication wiring
Low-voltage communication connection used to configure the JSY-MK-194T.

4. Install the libraries and program the router

  1. Download the library archive and extract its contents into your Arduino sketchbook libraries directory, normally C:UsersYourNameDocumentsArduinolibraries.
  2. Download and open Solar_router.ino in Arduino IDE.
  3. Set the Wi-Fi SSID and password in the firmware before uploading.
  4. Set setTimeOffset for your local UTC offset. The original Bulgarian installation uses UTC+3 in summer and UTC+2 in winter; daylight-saving adjustment is manual.
  5. Compile and upload the firmware to the ESP32.
Solar Router firmware open in Arduino IDE
The Solar Router firmware project in Arduino IDE.

5. Print and assemble the enclosure

  1. Download the two enclosure files and print them from flame-retardant, UL-rated PETG or another material approved for the intended environment.
  2. Install the M3 heat-set inserts and mount the low-voltage electronics securely.
  3. Maintain clearance, insulation and physical separation between low-voltage and mains-voltage sections.
  4. Have a qualified electrician complete and verify the mains wiring using the assembly diagram.
  5. Inspect every terminal, strain relief and protective earth connection before closing the enclosure.
Microsolar energy router assembly wiring diagram
Assembly overview. Mains wiring must be completed and verified by a qualified electrician.
Components fitted inside the Microsolar enclosure
Internal component placement.
Completed Microsolar energy router
Completed router enclosure.

6. Install and commission the system

  1. Panels: choose mounting hardware for the actual balcony or structure. Two standard panels can add roughly 50 kg of static load before wind and snow loads are considered. Obtain structural approval where required.
  2. Microinverter: mount it in a ventilated location protected from direct sun and rain, following the manufacturer’s instructions.
  3. Router: mount the closed enclosure securely, with the display at a readable height and suitable access for service.
  4. Current transformer: the clamp orientation determines the sign of measured power. In the original installation, its arrow points toward the grid input. Verify direction from live readings during commissioning.
  5. Functional test: start with low available solar power, confirm measurement polarity, then verify that routed power increases smoothly without exporting energy.

Do not commission the mains side alone unless you are qualified and legally permitted to perform this work.

7. Use the local web interface

After startup, the OLED displays the IP address assigned by your Wi-Fi router. Enter that address in a browser on the same local network.

  • Force Mode: manually activates the relay for testing or override.
  • Clock On/Off: enables scheduled operation, for example during a lower-cost electricity tariff.
  • Screen On/Off: controls the OLED display.
  • Time settings: configure the scheduled start time and UTC offset.
  • OTA update: open http://<device-ip>/update to upload a newly compiled .bin firmware file.
Microsolar local web interface main controls
Main controls in the local web interface.
Microsolar scheduling settings
Scheduling and configuration controls.
Known limitation: do not use Reset Wi-Fi Credentials unless you have confirmed that the firmware version installed on your device fully supports recovery and reconfiguration.

8. Final checks

  • Enclosure closed, secure and correctly labelled
  • All mains work inspected and tested by a qualified electrician
  • Measurement direction and power values verified
  • Web interface reachable from the local network
  • Relay, schedule, display and OTA page tested
  • Surplus routing verified under gradually increasing solar production

Once these checks pass, monitor the system closely during its first operating days and periodically inspect terminals, temperature and mounting hardware.

Safety note: This project involves mains voltage and high-current AC loads. Installation and testing must follow local electrical regulations and should be performed or reviewed by a qualified electrician.

Project resources

Explore the original Bulgarian build guide or download selected project files.

Bulgarian build guideESP32 firmwareLibrariesEnclosure files

Performance and cost figures are approximate and depend on the installation, solar exposure, component pricing and household consumption profile.

Scroll to Top