Accurate measurement of solar irradiance is one of the most critical steps in solar photovoltaic system design, performance evaluation, and educational experimentation. Solar irradiance directly determines how much electrical power a solar panel can generate at a given location, tilt, and orientation. While professional irradiance meters and pyranometers provide high accuracy, they are often expensive, bulky, and inaccessible to students, hobbyists, and small-scale solar installers.
The DIY Solar Power Meter was developed to address this gap by offering a compact, low cost, and portable solution that can be used for quick field measurements, educational demonstrations, and experimental solar studies. The project focuses on practicality rather than laboratory-grade precision, providing sufficiently accurate readings for comparative analysis, panel alignment, and real-world learning.
This device combines a calibrated solar cell for irradiance estimation with orientation sensing for tilt and azimuth, all integrated into a handheld, battery-powered unit with a real-time OLED display. The complete system is built using widely available components and programmed using the Arduino platform, making it easy to understand, modify, and reproduce.
System Overview:The DIY Solar Power Meter is built around an ESP32 microcontroller, which serves as the central processing unit for sensor data acquisition, calculations, and display control. The ESP32 was selected for its low power consumption, strong processing capability, and wide support within the Arduino ecosystem.
A precision current and voltage monitoring IC measures the electrical output of the solar cell. The short-circuit current is calculated from these measurements and converted into an irradiance value using a calibration constant derived from real outdoor testing.
To support proper solar panel alignment, the system also includes a combined accelerometer and magnetometer module. This sensor provides real-time tilt and azimuth readings, allowing the user to orient the device toward the sun or align solar panels accurately.
All data is displayed on a compact OLED screen, ensuring excellent readability even under bright outdoor conditions. A single button interface allows the user to navigate between display modes, keeping the user interaction simple and intuitive.
Solar Irradiance MeasurementThis irradiance meter works on the short-circuit current (Isc) principle.
A silicon solar cell produces current proportional to the sunlight falling on it. At Standard Test Conditions (STC), 1000 W/m² of irradiance produces a known short-circuit current.
The irradiance is calculated using:
Irradiance (W/m²) = (Measured Isc / Rated Isc) × 1000
Because this method directly uses a solar cell, it naturally:
- Matches the solar spectrum
- Exhibits good cosine response
- Correlates well with actual PV performance
In this irradiance meter, a silicon solar cell is used as the primary sensing element to measure solar irradiance by exploiting the direct relationship between incident sunlight and the short-circuit current generated by the cell. Unlike optical light sensors, this method closely represents the behavior of actual photovoltaic modules and therefore provides physically meaningful measurements for solar applications.
The solar cell is operated under controlled short-circuit conditions using a MOSFET-based switching arrangement. The MOSFET is placed in the current path between the solar cell and the current sensing circuit, allowing the microcontroller to electrically connect or disconnect the solar cell as required. When the MOSFET is turned ON, the solar cell terminals are effectively shorted through the shunt resistor and the INA226 current measurement input, enabling accurate measurement of the short-circuit current. When the MOSFET is turned OFF, the solar cell is electrically isolated, preventing unnecessary current flow and reducing idle power consumption.
The generated short-circuit current flows through the INA226 current sensor and send to MCU for further processing. The electrical connection of the solar cell, MOSFET, and INA226 is shown in the schematic.
At Standard Test Conditions (STC), an irradiance of 1000 W/m² corresponds to the rated short-circuit current of the solar cell. By comparing the measured short-circuit current with the rated Isc value, the incident irradiance is computed in firmware.
Instructables: https://www.instructables.com/DIY-Solar-Power-Meter/
PCB Gerber Files: https://shorturl.at/4DUio
STL files: https://www.printables.com/model/1603265-diy-solar-power-meter
Short Circuit Current MeasurementThe short-circuit current flowing from the solar cell passes through a precision shunt resistor, across which a small differential voltage is developed. This voltage is measured by the INA226 current sensor, which measures high-resolution digital current data via the I2C interface. The current value is internally calculated by the INA226 using the measured shunt voltage and the known shunt resistance. The corresponding solar cell, MOSFET, and INA226 connections are shown in the schematic.
At Standard Test Conditions, an irradiance of 1000 W/m² corresponds to the rated short-circuit current of the selected solar cell. The firmware computes irradiance by normalizing the measured Isc against this rated value. Because the measurement is performed under controlled short-circuit conditions and with precision current sensing, the resulting irradiance values are stable, repeatable, and closely correlated with real photovoltaic module behavior.
Tilt and Azimuth MeasurementIn this design, both tilt and azimuth are measured using the GY-511 sensor module, which is based on the LSM303DLHC. This module combines a 3-axis accelerometer and a 3-axis magnetometer, allowing the device to determine its inclination as well as its compass direction.
Tilt MeasurementWhen the device is stationary, the accelerometer mainly senses gravity. The sensor provides three acceleration values:
ax, ay, and az, representing gravity components along the X, Y, and Z axes.
From these values, the program calculates pitch and roll using trigonometric relationships (as shown in the diagram above).
- Pitch represents forward or backward tilt
- Roll represents left or right tilt
During calibration, the device is placed flat and the corresponding pitch and roll values are stored as zero references. These offsets are subtracted from future readings to remove mounting and alignment errors. A second reference angle, such as 90 degrees, is then used to calculate a scale factor to improve accuracy.
The final tilt angle displayed on the OLED is calculated by combining pitch and roll into a single value:
Tilt Angle = sqrt( Pitch*Pitch + Roll*Roll )
This gives a clear indication of how much the device deviates from a perfectly level position.
Azimuth (Compass Direction)The magnetometer inside the GY-511 measures the Earth’s magnetic field along the X and Y axes. From these values, the program calculates the azimuth angle, which represents the direction the device is facing relative to magnetic north.
The azimuth value is displayed like a digital compass, helping the user align the irradiance meter toward the desired direction, such as true south or true north, depending on the installation practice.
PCB DesignThe PCB for the solar irradiance meter is designed to be compact and low-noise to ensure accurate measurement of the solar cell short-circuit current.
- The layout is divided into functional blocks: power supply, current measurement, microcontroller, and I2C peripherals, which helps reduce noise and simplifies routing.
- The solar current path from the solar cell through the MOSFET, and INA226 is kept short with wide copper traces to minimize unwanted resistance.
- The XC6220 LDO regulator and its capacitors are placed close together to provide a clean and stable 3.3 V supply.
- I2C lines for the OLED and accelerometer are kept short and routed away from the current path to ensure reliable communication.
- The battery voltage sensing divider is placed near the MCU ADC pin for stable battery readings.
- Push button, and mounting holes are positioned to align with the enclosure and allow easy access.
The PCB assembly includes a combination of SMD components, through-hole (TH) components, and header pins for mounting external modules. Small resistors, capacitors, and other parts such as the LDO regulator and MOSFET are implemented as SMD components to keep the board compact and neat.
Modules such as the INA226 current sensor and LIS3DH tilt sensor are mounted on the PCB using header pins, which allows easy replacement, testing, and future upgrades.
The SMD components were soldered using a Miniware MH50 hot plate, which provides precise temperature control and is well suited for soldering small pads and fine components.
After completing the SMD assembly, a standard soldering iron was used to solder the through-hole components, including the header pins and the power switch.
Prepare the INA226 Current SensorOn the INA226 module, desolder the pre-soldered R100 (0.1 Ω) shunt resistor carefully using a soldering iron or hot air.
Solder an R500 (0.5 Ω) shunt resistor in place of the original R100. Ensure the resistor is firmly seated and the solder joints are clean.
Cut two short pieces of 22 AWG wire and solder them to the IN+ and IN− terminals of the INA226 module. These wires will carry the short-circuit current from the solar cell.
Solder the free ends of these two wires to the corresponding pads on the main PCB.
Finally, mount the INA226 module onto the PCB, making sure the orientation is correct and all pins are properly seated.
Upgrade on 25.02.2026: OLED to LCD Display (New Version)In this updated version of the project, the display has been upgraded from a small OLED screen to a Waveshare 1.54-inch LCD (ST7789 SPI, 240×240). This significantly improves readability, user experience, and enables a more professional interface.
Why This Upgrade?The earlier OLED display worked well for basic data, but had limitations:
- Small screen size
- Limited graphics capability
- Poor outdoor visibility in sunlight
The new LCD solves these issues:
- Larger display area (240×240)
- Bright and colorful interface
- Better visibility in outdoor solar applications
- Better UI (gauges and compass)
The LCD version firmware can be downloaded from Github repository.
3D Printed EnclosureThe enclosure for this irradiance meter is designed in Autodesk Fusion 360 and fully customized to fit the PCB, solar cell, and user interface ( Button and OLED display). To keep the design modular and easy to assemble, the enclosure is split into four 3D printed parts, along with a separate acrylic visor.
Bottom Body:
The bottom body is the main housing that holds the PCB. It includes mounting pillars and screw holes so the PCB can be fixed securely without movement. Cutouts are provided on the sides for the power switch and USB port.
Top Cover:
The top cover forms the front face of the device. It includes openings for the OLED display, the push button, and the solar sensor area. The display window is recessed slightly to give a clean finish and protect the screen from scratches during use.
Solar Cell Holder:
A dedicated solar cell holder is used to position the solar cell correctly on the top surface. This ensures the solar cell sits flat and aligned, which is important for consistent irradiance measurement. The holder also helps isolate the cell from mechanical stress.
Button:
The button was printed as separate part and fit into the top cover. This gives a smooth button press and a neat external appearance without exposing the switch directly.
Acrylic Visor:
To protect the solar cell, a 2 mm thick clear acrylic visor (56 x 38mm) is placed above it. This visor protects the cell from dust, scratches, and accidental contact, while still allowing sunlight to pass through with minimal loss.
Software & LibrariesThe firmware for this project is developed using the Arduino platform and can be compiled and uploaded using the Arduino IDE.
This project supports two display versions:
OLED Version (Basic & Compact)
Uses a monochrome OLED display with essential features.
LCD Version (Advanced & Professional UI)
Uses a high-resolution ST7789 color display with enhanced graphics
Both versions share the same core logic for irradiance measurement and sensor interfacing, but differ in display handling and UI features.
The firmware for this project is developed using the Arduino platform and can be compiled and uploaded using the Arduino IDE.
Common Libraries (Required for both versions)- Wire (built-in)
- INA226
- Adafruit GFX
- Adafruit Unified Sensor
- Adafruit LIS2MDL (Magnetometer)
- Adafruit LSM303 Accel (Accelerometer)
- OneWire
- DallasTemperature
- Adafruit SSD1306
- Adafruit ST7789
- SPI (built-in)
Calibration of the irradiance meter can be done in two practical ways, depending on the tools available. Both methods are valid, and they can also be used together for best results.
1. Calibration Using the Solar Cell Datasheet
In this method, calibration is based on the electrical characteristics of the solar cell used as the irradiance sensor. The solar cell datasheet specifies the short-circuit current (Isc) at Standard Test Conditions (STC), which correspond to an irradiance of 1000 W/m².
From the datasheet, the short-circuit current at 1000 W/m² is taken as the reference value. Since the short-circuit current of a solar cell is approximately proportional to irradiance, a linear relationship is assumed between measured current and irradiance.
The firmware measures the short-circuit current of the solar cell and converts it into irradiance using a calibration constant derived from the datasheet value.
Irradiance (W/m²) = Isc(measured) × K
Where K is the calibration constant derived from the datasheet value:
K = 1000 W/m² / Isc(STC)
K ≈ 1000 / 84 ≈ 11.9 W/m² per mA
In practice, small losses due to acrylic cover, cell temperature, enclosure shading, and wiring resistance slightly reduce the measured current. To account for this, the calibration constant is fine-tuned experimentally.
This method is simple and does not require any external equipment. It provides reasonably accurate results for general measurements and learning purposes.
2. Calibration Using a Reference Irradiance Meter
For higher accuracy, calibration can be performed using a commercial reference irradiance meter along with a linear regression method. In this approach, the DIY irradiance meter and the reference meter are placed side by side under uniform sunlight, with both sensors aligned to the same tilt and orientation.
Multiple measurements are taken at different irradiance levels throughout the day. For each measurement point, the DIY meter records the short-circuit current, and the reference meter provides the corresponding irradiance value.
These paired values are then used to perform linear regression using the relationship:
G = k × Isc + c
Where:
G is the irradiance in W/m²
Isc is the measured short-circuit current in mA
k is the calibration constant
c is a small offset term
In most practical cases, the offset term c is very small and can be ignored, simplifying the relationship to:
G ≈ k × Isc
The regression-based value of k accounts for optical losses, temperature effects, and enclosure influences. Once determined, this calibration constant is updated in the firmware so that the DIY meter closely matches the reference meter across a wide irradiance range.
Firmware SummaryWhen the device is powered ON, the ESP32 microcontroller initializes the SPI interface for the LCD display and the I2C bus for all connected sensors. The firmware loads the required drivers for the ST7789 LCD display, INA226 current sensor, and the LIS2MDL magnetometer along with LSM303 accelerometer used for tilt and azimuth measurement. If connected, the DS18B20 digital temperature sensor is also initialized. Calibration data is stored in non volatile memory, so once calibrated, the device retains its settings even after being switched off.
During startup, the device performs a quick self check and displays a boot screen indicating successful initialization of the display and sensors. If calibration data is missing, or if the push button is held during startup, the firmware enters the calibration mode.
Calibration is performed by asking the user to cover the solar cell, allowing the system to measure and store the dark current offset for accurate zero current correction. The calibration data is then saved in EEPROM for future use.
In normal operation, the ESP32 briefly switches ON a MOSFET to safely short the solar cell through the shunt resistor. Multiple current samples are taken using the INA226 and averaged to improve accuracy. The stored offset is applied, and the corrected current is converted into solar irradiance (W/m²) using a calibration constant. A digital filter smooths the readings to ensure stable and flicker free display.
The LSM303 accelerometer and LIS2MDL magnetometer continuously provide tilt and azimuth data. Tilt compensation is applied to improve the accuracy of azimuth calculation, and a fixed correction factor is included in the firmware to match the physical orientation of the PCB, ensuring correct compass direction.
If the DS18B20 sensor is connected, the firmware reads the temperature and displays it on a dedicated page, allowing the user to monitor module temperature.
The LCD display shows multiple pages of information. The main screen displays real time solar irradiance along with battery status. A second screen shows the minimum and maximum irradiance values recorded during operation. A third screen displays the tilt angle and azimuth. A fourth screen provides a graphical compass with a circular scale and a moving needle indicating direction. An optional page displays temperature when the sensor is connected.
A single push button is used to control all functions. A short press is used to change pages, while a long press is used to initiate calibration.
Update - 15.02.2026 : Upgrade to LSM303AGRInitially, I purchased a module locally that was labeled as GY-511 LSM303DLHC for tilt and azimuth measurement. However, during testing I repeatedly faced issues with it. Most of the time, the magnetometer was not detected on the I2C bus, even though the accelerometer section was working. This caused unreliable azimuth readings and inconsistent behavior in the firmware. Despite checking wiring, pull-ups, and addresses multiple times, the problem persisted.
After several failed attempts and inaccurate measurements, I decided to replace the module with a more reliable sensor, the LSM303AGR. The LSM303AGR provides stable accelerometer data for tilt measurement and works reliably with the magnetometer over I2C, eliminating the detection issues I faced earlier.
In the firmware, the accelerometer readings (ax, ay, az) are used to calculate pitch and roll for tilt measurement. The magnetometer readings (mx, my) are used to compute azimuth using the atan2 function. The heading is normalized between 0 and 360 degrees before being displayed. Calibration offsets are applied to improve accuracy and remove installation errors.
After switching to the LSM303AGR, the tilt and azimuth readings became stable and repeatable, significantly improving the overall reliability of the irradiance meter.
The updated code with LSM303AGR implementation is available on my Github repository
How to Use the DevicePower ON the device using the power switch. The LCD display will turn ON and the device will perform a quick self check with a boot screen.
Place the device under open sunlight. Ensure there are no shadows from your hand, nearby objects, or structures falling on the solar cell.
Hold the device flat or place it on a level surface. Check the tilt value on the display and adjust the position so that the tilt is close to zero for best measurement accuracy.
Wait a few seconds for the reading to stabilize. The irradiance value will automatically settle once sunlight conditions become steady.
Read the irradiance value displayed in W/m² on the screen. This represents the available solar energy at that location and time.
Use the push button for navigation and functions:
- Short press to switch between different pages (Irradiance, Min Max, Tilt Azimuth, Compass, Temperature)
- Long press to perform calibration by covering the solar cell
Additional information such as minimum and maximum irradiance, tilt angle, azimuth direction, compass orientation, and temperature can be viewed by navigating through the pages.
Check the battery level on the display. Recharge the device when the battery percentage becomes low.
Power OFF the device after use to conserve battery.












Comments