ESP32 ProjectsIOT Projects

IoT based Solar Power Monitoring System with ESP32 over cloud

Learn how to build an IoT based solar power monitoring system using ESP32 and monitor data over Arduino IoT cloud.

In this article let’s learn how to Effortlessly Monitor Your Solar Power Generation system with Our ESP32 IoT based solar power monitoring system. ESP32 can be programmed to collect data from sensors which we connect to the solar panel, such as voltage, current, temperature, and sunlight intensity and transmit this data over the internet to a cloud server or a local server. This data can then be accessed and analyzed using a web interface or a mobile app, allowing you to monitor the performance of your solar panel in real-time.

There are several reasons to monitor the performance of your solar panels such as: To optimize energy production, To detect problems early, To reduce energy costs, To ensure safety and more. Solar energy is becoming increasingly popular around the world as a way to reduce reliance on fossil fuels and combat climate change. Many countries are investing in solar energy infrastructure and implementing policies to promote the adoption of solar energy.

Project Introduction:

In this project we will monitor voltage, current, temperature and sunlight intensity with help of sensors which send the data to ESP32 microcontroller. We display the data over Arduino IoT cloud server and also on 16X2 LCD display which is connected to the micro controller. Lets see which sensors we are using for what and their respective pinout diagram below.

Voltage:

For Measuring voltage we are using 0-25v DC voltage sensor. This sensor uses the voltage divider which reduces the voltage by 5 times using 2 resistors R1= 30000Ω and R2=7500Ω. As we all know Arduino ADC input voltage ranges from 0-5v but ESP32 has a maximum input of 3.3v only. So with the help of this voltage divider we can measure from 0-16v with ESP32.

  • 3.3vX5times=16.5v(MAX)

voltage detection sensor module pinout

For more detailed information read: Arduino Voltage Sensor which measures up to 25V DC.

Current:

For measuring current we are using ACS712 5A current sensor. This sensor uses hall effect principle to measure the current, there are 3 variants 5A, 20A and 30A choose according to your need. For this board lower capacity one’s give more accurate results than the higher variants. For this sensor we need to use the voltage divider to reduce the sensor output from 5v to 3.3v. So we use 2 resistors R1= 1kΩ and R2= 2kΩ.

ACS712 Current sensor module application circuit

For a detailed information read: interfacing ACS712 current sensor with ESP32.

Temperature:

To measure temperature we are using DS18B20 temperature sensor. This sensor has the capacity to measure temperature values between -55ºC to +125ºC. We need a 4.7kΩ resistor to connect to the signal from 5v supply. This sensor has very low power consumption of nearly 1mA. We can use waterproof or non water proof sensor according to the requirement.

DS18B20 temperature sensor pinout diagram

For more details read: Interfacing DS18B20 Temperature sensor with Arduino,ESP8266 and ESP32.

Sunlight intensity:

To measure sunlight intensity we are using BH1750 light intensity sensor which can measure Lux range with a high resolution from 1 to 65535lx. But direct sunlight intensity is higher than 100000lx, we can use filters to reduce the light and compensate the amount of it. But sometimes this sensor measures lux values more than 1 lakh. Here in our case we just need to know weither the light intensity is high or not.

BH1750 light intensity sensor pinout diagramFor more details read: Interfacing BH1750 Light intensity sensor with Arduino.

Bill of Materials:

Product NameQuantityamazon logoamazon logo india
ESP32 Microcontroller1https://amzn.to/3s0Sut6https://amzn.to/3Kw2np2
Voltage sensor 0-25v1https://amzn.to/3WHDBslhttps://amzn.to/3QeGHlk
ACS712 current sensor module1https://amzn.to/3v4ok8yhttps://amzn.to/3EaJ9Dz
DS18B20 Temperature sensor1https://amzn.to/3VIAtLyhttps://amzn.to/3WJhjql
BH1750 Ambient light intensity sensor1https://amzn.to/33C6aRThttps://amzn.to/3J0WRKw
LCD 16X2 module with or without I2C adapter1https://amzn.to/3BNSRuphttps://amzn.to/363ki7F
1k,2k and 4.7k ohm resistors1 eachhttps://amzn.to/3hBlqlqhttps://amzn.to/3sXBKmI
5V power supply (Micro USB or External).1https://amzn.to/3s1a8g3https://amzn.to/364yInH
Few Connecting Wireshttps://amzn.to/3H2BV4ehttps://amzn.to/3J0WVu2
You can buy the required components from the given best buy links. We choose the components according to value for money.

Circuit Diagram:

Now connect all the required components as shown in the below schematic diagram to build an ESP32 based solar power monitoring system.

iot based solar power monitoring system using esp32 circuit diagram
Click to enlarge

As you can see from the above circuit diagram we connected 4 sensors, 1 LCD display with ESP32. You can use an external 5v power supply to give all the components a stable voltage without heating up our ESP32.

Read below to easily understand the circuit connections with out any confusion

Voltage sensor with ESP32:

Voltage sensor has 3 pins +, -, and S. + and – pins are connected to 5v and GND terminals of 5v power supply. S pin which is signal pin, connected to analog pin D27 of ESP32.

We need to connect the solar panel terminals in parallel with screw terminals of sensor to measure the voltage of it.

ACS712 current sensor with ESP32 :

ACS712 has 3 pins VCC, OUT and GND. VCC and GND pins are connected to 5v and GND terminals of 5v power supply. OUT of ACS712 is connected to D34 of ESP32 along with a voltage divider to reduce the voltage from 5v to 3.3v for ADC.

DS18B20 temperature sensor with ESP32:

Here we used a non waterproof version as we stick it to the solar panel. it has 3 pins VCC on the Right, Signal on the center and GND on the left. VCC and GND pins of DS18B20 are connected to 3.3V and GND pins of ESP32 respectively. Signal pin is connected to D15 of ESP32 along with a 4.7K ohm resistor to pull up the signal.

BH1750 light sensor with ESP32:

BH1750 sensor uses I2C communication so the data pins SDA and SCL are connected to D21 and D22 of ESP32 respectively. And powered with 5v power supply.

LCD display with ESP32:

LCD display also uses I2C communication so we are connecting SDA and SCL pins of LCD to the same D21 and D22 of ESP32. We can differentiate devices with the I2C address.

That’s it all for connection, its time to write the code and upload to ESP32.

Program Code to just display on LCD Display:

To get the data from the sensors to process them and output the required values we need to upload the program code to ESP32 using Arduino IDE. Our program need few libraries listed below, you can install them directly through the library manger of Arduino IDE or download from the below links and place them in Arduino libraries directory.

Required Libraries:

  • Download LiquidCrystal_I2C – Link
  • Download BH1750 Library: Link
  • Download Dallas Temperature Library: Link

Program Code:

Code to just display on LCD display. Download this code.

Output on LCD display:

After uploading the code through Arduino IDE you can see the sensor values on LCD display as shown in the below image.

solar power monitoring system on LCD display using ESP32

How to setup and code Arduino IoT Cloud for Solar power monitoring system:

Account setup:

Step1: Open Arduino IoT cloud using following Link : https://create.arduino.cc/iot

Step2: Signup for a new account or login if you already have an account by providing credentials.

Step3: Click on Create thing, to get a setup page to configure project name, board, variables, and network according to the below image.

iot based solar power monitoring system using esp32 arduino cloud dashboard

Device setup:

Click on select device button, and choose setup a 3rd party device as we are not using Arduino board. Now from the radio buttons choose ESP32. From the dropdown select ESP32 wrover module . Next click on continue to name the device and download or copy the Device ID and Secret Key PDF for further reference in the code as shown in the below screenshot.

Arduino IoT cloud web setting up device with secret key

Next go to sketch tab and paste the code given below.

Download complete code: here

File: IoT_based_Solar_Power_Monitoring_System_with_ESP32_jan04a.ino

Next create 4 variables in_voltage, AmpsRMS, temp, lux, variable names should be same as the variables in the code as shown in the below image keep them read only as we are just reading the data from the sensors.

arduino iot cloud variable setup

Next link the device. Then click on network to add the WiFi SSID, password and secret key which you obtained while creating a device ESP32 Wrover.

Create a dashboard, and add 4 widgets for voltage, current, temperature, and light intensity as value, link them with created variables.

arduino iot cloud adding widgets in the dashboard

That’s it play with it to know more functions. For detailed setup check here: Getting started with Arduino IoT Cloud.

You can check the serial monitor of Arduino IoT and the sensors data will be displayed as the below screenshot.

solar power monitor with esp32 using arduino iot cloud serial monitor

Now the data is shown through the dashboard also, Open the previously created dashboard to view the data as shown in the below image. You can also download Arduino IoT Cloud Remote on your Android mobile to remotely monitor health data over internet.

solar power monitoring system dashboard on android iot cloud

Not only using Arduino IoT Cloud but you can also use other cloud platforms like ThingSpeak.

If you like this project please subscribe to our YouTube Channel “Circuit Schools to encourage us to publish more interesting projects. If you have any doubts write to us from below comment section.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button