The project started in December 2019 and got to its final state in July 2020. Here is a short documentation of the stages to get this comprehensive data collection and the obstacles and challenges on the way.
As topic for his EE Tom wants to investigate renewable energy in Vietnam. As for an EE (extended essay in the IB international baccalaureate) in physics an experiment should be included. And we can investigate the wind and solar power here in Nha Be on the roof of the 5th floor of the school building.
To collect data I created a new Google account as aisvn.data for emails and communication (MQTT, IFTTT).
The website sites.google.com/ais.edu.vn/solar is created. The measured data from the last 36 hours will be displayed in an interactive graph one day.
2019/12/14
I created a jupyter notebook with the first informations. The document can be found here. A copy is included in software.
For about an hour during assigned study we tried to measure the characteristics of a 12 Volt 6 Watt solar panel that the school provided. The values are measured with the Vernier voltage probe and the current probe. Unfortunately the voltage probe has a maximum voltage range of 10 Volt, while the solar panel provides up to 16 Volt without any load.
Solution 1: A voltage divider made of two 1 kOhm resistor divided the output by 2 and moved it into the voltage limit of the probe. A successful reading now indicated the second problem: Without any load the output voltage is almost constant, since it mainly derives from the band gap in the semiconductor. This is well illustrated in this graph from wikipedia:
Note that only the current increases during daytime. Since the power is a product of voltage and current, the power increases as well.
Solution 2: A MPPT (Maximum Power Point Tracking) involves a lot electronics that is well beyond the scope of IB physics. We chose to use a fixed load somewhere in the middle of the power curve. By measuring the voltage we would automatically measure the current and therefore the power.
First we had to estimate the correct resistance for the load. With the parameters of 12V and 6W one can calculate a current of I=500mA from P=VI and then apply Ohm’s law as R=U/I which results in a resistance of R=12/0.5=24 Ohm. Another way is the direct way of R=U²/P=12²/6=24 Ω. Half the power would be achieved with ca. 50 Ohm and 100 Ohm creates 25% of the maximum power on the load. Since we had plenty 1 kOhm resistors we soldered 9 of them in parallel and added 2 series of two 1 kOhm resistors from the voltage divider as well. The circuit diagram looks like this:
The school agreed to purchase some professional material for this investigation - and future experiments and demonstrations about the potential of renewable energy, especially here in Vietnam. We ordered:
60W photovoltaic solar panel 12V
500W wind generator 24 V JLS-500
1400W Hybrid Wind Solar Controller from Marsrock with 0-600W solar and 0-800W wind and dump load
12V 24Ah battery to store energy when neither wind nor solar power is available
ESP32 to measure relevant characteristics of the system and upload the data to the internet for further investigation
And a little outlook here: End of May and beginning of June three classes from grade 4 and two classes from grade 9 visited our solar and wind energy project. Especially the kids from Elementary school had a lot of questions about materials of solar panels, alternatives to silicon, sustainability and energy storage during the night. Some read this documentation and asked what an ESP32 is! We watched live the updated Google sheet lines with measurement in classroom 407B.
The hybrid wind solar power generator arrives - despite the corona virus outbreak in China. Declarations with customs and DHL took some time, but it’s now here. Other parts will be ordered locally. And this controller has the MPPT we mentioned in January included!
2020/03/18
I finally create a Github repository to document this project. The ESP32 were delivered some weeks ago. Now I got the LiPo batteries as well. Connector for the feather-style boards: JST PH 2pin for reference! Purcheased at ICDAYROI in Thủ Đức.
The ADC of the ESP32 is not very linear. But we want to use it to measure the voltage of the solar pannel under different load situations. There might be a compensation function. The procedure and measurement was done by Fernando Koyanagi from Florianópolis in Brazil and published in instructables.
For the future design of April 2020 the voltage is measured by the ESP32 and the value transfered to a database in the internet every 5 minutes. This gives 288 data points per day. An article at randomnerdtutorials explains the setup and programming very well;
Additionally there are 4 digital switches for different loads planned. The ESP32 is activating them prior to the measurement and can combine the switches for 16 different load values. The setup now looks like this:
With the 4 switches we can create 16 datapoints, that the ESP32 can read in 12 bit. Every 5 minutes we create therefore 24 byte of data. Over a day this accumulates to 6912 byte and in a year all data collected is 2.5 MByte.
The ordered TTGO ESP32 mainboard is pretty good! I ordered it on April 1st mainly for the included LiPo charger, but it as 2 extra buttons (GPIO0 and GPIO 35) to the reset button. And a 1.14 Inch display IPS ST7789V with 135x240 pixel. And there are 13 GPIO pins left to use for 4 switches and one voltmeter under different load conditions.
To program the display and some voltages, example code can be found at https://github.com/Xinyuan-LilyGO/TTGO-T-Display
Today the second TTGO ESP32 arrived (left, the T-Koala to be the main computer in the future) and is set to be programmed:
Without programming TTGO installed some software on the module. On the 135x240 display you get 22x30 characters with a 6x8 font. That’s almost as much as my first ZX81 with 32x24. You can scan for nearby 2.4GHz networks, check the power supply and go into sleep mode. The last one is of interest for our project and the power consumption with these standard settings will be tested next.
With an external power supply we can check the power consumption of the TTGO. The values over USB were rather high, but it has a 3.7 LiPo battery connector and the power consumption there is significantly lower, most likely because the 5V to 3.3V step-down converter is not needed. Here are the values for 3.7 Volt over battery:
Power on, start up and screen on: 68 mA
WiFi scan for nearby hotspots: 108 mA
Sleep, waiting for interrupt from key pressed: 0.35 mA
With a 1000 mAh battery and the given voltage we can calculate the power consumption and projected runtime:
Screen on: 252 mW, runtime 14 hours 42 minutes
WiFi on: 399 mW, runtime 9 hours 15 minutes
Hibernate: 1.3 mW, runtime 2857 hours - or 119 days
School is back open since May 4th, students are back since May 5th - and now we got the solar panel and the battery! Time to find a place on the roof in Nha Be and control software to collect and transmit data.
The wind generator arrived just one day later! Looked at location on top of the roof, 6th floor in Nha Be. Empty room for equipment is there, rain proved, and space for the 5 wired from solar and wind to the control unit. Maybe next week start first test setup?
Data: JLS-500 with 24V and 500 Watt. If you want so see how it looks inside, Quint opens one and lets us take a look inside. Here is his video: https://youtu.be/MlwK4kCrXB0?t=925
In another video he explains how the generator works and builds one from scratch: https://youtu.be/YLb4enCgnP4?t=303 And if you want to do something with aerodynamics, rotor blades, pitch angles: He investigates this as well: https://youtu.be/MlwK4kCrXB0?t=528
We installed the 60W solar module on the roof of our school AISVN and connected MPPT controller and 24Ah battery. Now charging over the weekend, then connect my 60W motorcycle lamp to drain the battery every night …
The stand for the 500W wind generator will be welded in the next week.
2020/05/20
The solar panel charged the battery over the weekend, now we display both voltages simultanoulsly in our data collection box. Below the green hybrid controller you can see the 60W H4 lamp from a motorcycle. It will drain the battery after it has been chared a day with the solar panel. It will be one more day to the first ESP32 measurement and upload to the internet into a Google sheet.
Left is solar panel with 20.8 Volt and right is battery with 13.2 Volt.
Above the controller is the 1 Ohm dump load to slow down the wind generator. On the floor the 24 Ah battery.
Our first program has only 57 lines and 47 sloc. Within a month it will be 3 times of that!
// Solarmeter first attempt (all Serial.print removed), inspired by
// https://randomnerdtutorials.com/esp32-esp8266-publish-sensor-readings-to-google-sheets/
#include <WiFi.h>
#include <Wire.h>
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";
const char* resource = "/trigger/value/with/key/create-one";
const char* server = "maker.ifttt.com";
uint64_t uS_TO_S_FACTOR = 1000000; // Conversion factor for micro seconds to seconds
uint64_t TIME_TO_SLEEP = 120;
int adcValue = 0;
void setup() {
delay(1000);
initWifi();
makeIFTTTRequest();
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_deep_sleep_start(); // start deep sleep for 120 seconds (2 minutes)
}
void loop() { // sleeping so wont get here
}
void initWifi() { // Establish a Wi-Fi connection with your router
WiFi.begin(ssid, password);
int timeout = 10 * 4; // 10 seconds
while(WiFi.status() != WL_CONNECTED && (timeout-- > 0)) {
delay(250);
}
}
void makeIFTTTRequest() { // Make an HTTP request to the IFTTT web service
WiFiClient client;
int retries = 5;
// raw and converted voltage reading
adcValue = analogRead( 34 );
String jsonObject = String("{\"value1\":\"") + adcValue + "\",\"value2\":\""
+ (adcValue * 2.4) + "\",\"value3\":\"" + millis() + "\"}";
client.println(String("POST ") + resource + " HTTP/1.1");
client.println(String("Host: ") + server);
client.println("Connection: close\r\nContent-Type: application/json");
client.print("Content-Length: ");
client.println(jsonObject.length());
client.println();
client.println(jsonObject);
int timeout = 5 * 10; // 5 seconds
while(!!!client.available() && (timeout-- > 0)){
delay(100);
}
client.stop();
}
We started with the measurement of the voltages of both solar panel and battery at 10:00 AM on May 21st, 2020. We soon realized that the MPPT from the hybrid controller only applies to the wind generator part and that we drain the battery completely with our 60W light bulb that was intended to shine 4 hours after sunset.
Recap: The MPPT does not apply for the solar panel, it is directly connected to the battery and looses therefore a lot of energy. Secondly: The floating limit for our battery was set too low at 13.8 Volt, so it was never really charged since installation on May 15th. New limit is 14.7 Volt floating and overvoltage limit 14.8 Volt. Third - the lower voltage limit was set too low at 10.8 Volt, it is adjusted now at 11.0 Volt. The load was reduced from 120 W to 60 W. Let’s see if the weekend brings an improvement.
The battery is fully charged. Therefore the controller disconnects the panel and you see the floating voltage of more than 20 Volt from the panel. Battery fully And you see the several attempts to connect to the WiFi for the ESP32 while students are in school. The load is now 5 Watt and programmed for 7 hours after sunset.
We put a 0.1 Ohm resistor in series with the positive wire of the solar panel to determine the current from the voltage drop. Even in the case of 3 Ampere this accounts only to 0.3 Volt and less than a Watt of heat loss.
The powerbox was finished. The total resistance is closer to 0.122 Ohm. The voltage drop reading has therefore to be multiplied by 8.2 to get the current reading for the solar panel input. That’s the finished box:
And I finished the soldering of the board with several voltage dividers and two LEDs to lower the voltage into the measurable range of the ESP32 to see the voltage difference over the 0.1 Ohm resistor in line with the solar panel.
For this project we used the T-Koala. It has some direct pins from the battery, for example. It’s easier to connect to them to determine the voltage of the LiPo. Picture and pinout:
And I finished the soldering of the board with several voltage dividers and two LEDs to lower the voltage into the measurable range of the ESP32 to see the voltage difference over the 0.1 Ohm resistor in line with the solar panel.
And I installed it after sunset to get the first measurements. It's installed parallel to the other ESP32 that operated just with 2 voltage dividers for the last 2 weeks - which will cause weird values because of wrong reference levels - and pin 26 of the ESP.
After a weekend of measurement the system is working and delivered the first measured current data - and some strange voltage behaviour once the load switched on.
We test a possible electronic circuit to measure the output of the wind generator. There is no meaningful connection between the voltages and the common plus (not ground!) of the controller. We create a different solution - that works!
The test setup is now soldered onto the mainboard and tested with other AC sources with and without the ESP32. The blue LED should indicate a working wind generator and pin 26 should measure 1/11 of the generated voltage. Details in setup.
The following day we got the first data from the wind turbine after we connected the wires at 2:00 PM. It first looked that there is not enough wind on the 6th floor in Nha Be to generate some electric energy - but for an hour from 4:00 PM to 5:00 PM we had a voltage of up to 12 Volt.
You can see the less noisy signal due to 100x multisampling. As soon as the 20W load lamp switches on the voltage of the battery drops, bust for some time the solar panel can provide the 1.6 Ampere needed, so the voltage stays constant. The clouds at 2:00 PM already indicated the coming storm - and the solar panel virtually started to produce any usable energy. Sunset is indicated at 6:20 PM.
2020/06/11
The LiPo battery of the T-Koala would be drained within 2 weeks - on a project with renewable energy! Unfortunately we can’t connect the microcontroller to the big 24 Ah battery, because the solar controller has no common ground, but the positive poles connected. Relative to the negative pole of the battery we get therefore either the full battery voltage during the night or negative voltages (-8 Volt) during the day. Not easy to fit into the 0-3.3 Volt range of the ESP32. Therefore we added a second small solar panel and measure this voltage as well. Here is a collection of our data:
So far we measure the voltages:
solar panel
wind generator
12V battery
load
secondary solar panel
LiPo battery to power the ESP32
The dump resistor is not yet connected. Additionally we measure the current from the solar panel.
Pin assignment:
// 32, 33, 34, 35, 14, 26, 27, 12, 13
// solar, battery, currentA, currentB, load, wind, dump, solar2, LiPo
int voltage[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; // all voltages in millivolt
int pins[9] = {32, 33, 34, 35, 14, 26, 27, 12, 13}; // solar, bat, c_A, c_B, load, wind, dp, solar2, LiPo
2020/06/12
The LiPo battery lasts only for a week of measurement with the T-Koala. So we added a second solar panel 12V 1W to recharge the battery. And another one with 2 Watt now supports the wind generator.
The incandesecent light sources are not very efficient - and we want to use our collected energy most efficiently. I got some 2.4 W white LED stripes for motorcycles and use it to illuminate our control room.
After recieving some solar panels in December 2019, I discussed with Tom a possible setup. Some limitations of the equipment were solved with voltage dividers, made of 1 kOhm resistors. We have many of them. To test the viability of this solution I placed two solar panels on the roof of building A in Nha Be on June 9th and started some measurements:
Two solar panels: 12 Volt 3 Watt and 6 Volt 1 Watt.
12 year old X200 with Windows 10 and Vernier Labquest Mini for 2 voltage sensors and one current sensor. Note the two voltage dividers as load.
The panel get very hot in the sunlight.
Measuring every 120 seconds (2 minutes) we can see the increasing voltage and current after sunrise at 5:20.
Data collection after 140280 seconds or 39 hours. Its rainy season - the afternoon gets cloudy. As for July 10th and 11th no rain, though.
Over the last two weeks we collected a decent amount of data. I compiled some values into a colorful graph. Note that from June 5th on we measure every minute. This doubles the amount of data. This is only for test purposes, we go back to every 2 minutes later in June.
From Monday, June 15th on we reprogrammed the T-Koala to submit data only every 2 minutes. It measures the temperature now as well, calculates the generated power and submits the data as floating point values instead of integer data in milliVolts and milliAmpere.
The effect of 100x multi-sampling can easily be seen in this voltage measurement of the LiPo battery for the ESP32. Just compare before (20 mV noise) and after (2 mV noise). Since one measurement is 9.5 µs the 100x multisample takes only a millisecond.
The second power box made a lot of progress. Mechanical parts are inside and the electronics works already as planned on the breadboard. The ESP32 can power a 2SD613 npn transistor to switch 1.5 Ampere of load with a 150 Ohm resistor from pin 25 3.3 Volt to the base. And the pin stays active in deep sleep with 4 lines of code related to the low power secondary RTC processor. Details in Software.
It took a whole day to finish the circuit board, the entire Friday, but by 4:00 PM it was finished:
I wondered why the readings were off and the LED would not switch on. I mismatched the 5 analog input pins by 3 locations. So I had to solder a riser board to transfer the pins, this took another hour!
Eventually I installed this last box to our setup on the sixth floor, finishing 7:00 PM:
The data in the lab looked promising (except the solar3 voltage) but because it was late I installed it anyways for the weekend. Back home I discovered the mistake of having only one voltage level as power switch indicator:
After connecting the board to the battery at 7:22PM the voltage sensor measured a voltage larger than 12.6 Volt, the limit, and switched on the 2.4 Watt LED light load. The voltage dropped to 12.4 Volt, when measured at 7:24PM and the ESP32 switched of the load. The voltage increased back to the higher voltage without the load, so at 7:26 PM the ESP32 determined it is time to switch on the load again - and this back and forward every two minutes continued until 2:00 AM the next morning.
After sunrise on 5:20 AM the next morning, the solar panel slowly started to charge the battery again - and the cycle repeated from 7:23 AM again. The crucial part in the code is this:
The next software update v0.3 will have a switch on voltage of 12.7 Volt and a seperate switch of voltage of 12.2 Volt. We'll see on Monday how this works.
The end of the 10k:10k voltage divider for pin C is connected to the negative pole of the battery. But for correct reference it should be the positive pole, since it is the common pin and the created voltage from the solar panel negative.
The second fix is the limits for switching on the load - line 66 to 74. Here is the new data:
The last wires are connected, aligned and bundled together. The screws are tightened. This installation should last for the next years to come to collect some data. Former project lasted years, but in different climate zones.
Left are the smaller 12V 1W solar panel for Box #1 charging and the 18V 3W panel for the hybrid controller. In the background our 18V 60W solar panel, looking directly into the sun. And the 500W wind generator on the right, providing a maximum of only 3 Watt so far. And a day after the rain some water is still on the roof.
And in the control room we have now 2 LED panels 2.4W on the toof. On the floor is left he 14 Ah battery for the hybrid wind and solar controller and right the 24 Ah battery for the MPPT solar controller. Above the 6 units you can see the dump load resistor in case of a storm to slow down the wind generator.
First row from left to right:
MPPT solar controller - orange
Hybrid wind and solar controller MarsRock - green
Box #1 with 13.9V solar and 13.3V battery. Has ESP32 AISVN1.
Second row from left to right
Power box to determine energy creation of the 60 W solar panel
Box #1 with ESP32 AISVN2. The 18V solar panel deliveres 17.6 Volt, ESP has 5 Volt power (orange) and the output is active (green) because the battery voltage is above 12.8 Volt.
Load controller with 4 1N4007 diodes prior to the solar controller with a 20 W load lamp