500W wind generator on the right, background solar1 with 18V 60W and left solar2 with 18V 3W next to solar3 12V 1W.
Control room setup:
Top: MPPT solar controller for solar1, Hybrid controller for wind and solar2 and box#1.
Bottom: Power box, box #2 and intelligent 20W load from diodes and solar controller.
2020/06/09
The mainboard with the TTGO T-Koala ESP32 microcomputer got the rectifying circuit for the 3 phase AC from the wind generator on top. The 6 1N4007 diodes are accompanied by a 100 µF capacitor and a 10 kOhm load to smooth some of the voltage. An blue LED with 10 kOhm is parallel as well. And below is the voltage divider with 1k : 10k as input voltage to pin 26.
In the middle the 100k : 100k voltage divider between GND and battery voltage can be seen as input for pin 13.
Bottom left are two green diodes that lower the positive voltage of the solar panel prior and after the 0.12 Ohm shunt in line with the positive line. Since positive is connected to 3.3V, the input voltage is 1.1 Volt or higher, if the solar panel provides current. Voltages are measured at pin 34 and 35 and are connected to the negative battery pin with 10 kOhm resistors (the two blue ones) for some 1.2 mA current.
Above the battery pin are the three voltage dividers 1 k : 10 K for solar panel (pin 32), the battery (33) and the load (14). Since all are connected on the positive pin, the voltage is measured against 3.3V and connected to the negative pin with the 10 kOhm resistor.
On the right corner is the small circuit for the second solar cell to charge the LiPo battery of the ESP32. It got its own 4.7k : 1k voltage divider connected to pin 12 and has a step down converter with USB output and a USB-C cable to the connector. The 5V pin of the board can't be used.
Pin assignment:
32 voltage solar
asdf
Software:
Wake up every minute to measure these voltages:
Every 5 minutes calculate the average of these 5 values, store in the today array
Fetch data from last 5 minutes from AISVN2
Upload data to Google Sheet with API
Update database for recent values
Every day upload the whole file to location x
Data collection:
Arrays in RAM:
long yesterday[288][8] 4.6 kByte with integer millivolt values for solar1, battery1, wind, load, solar2, battery2, solar3,
2020/06/05 - Friday, last day of school
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.
2020/06/03
I created a circuit diagram for the measurement box with the ESP32 T-Koala. It was drafted on paper, the scan looks like it originates from the last century:
But it worked! On Friday, June 5th it was finished physically and connected to solar panel and internet. And it collected data.
2020/06/18
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.
2020/05/19
The soldering of the PCB took the entire Friday, but by 4:00 PM it was finished. You can see the two red LEDs in the left corner to rise the ground level of A and B after the 1.5 Ohm and 0.1 Ohm resistors of the negative pole to the battery. The voltage divider for the solar panel on C can be seen with 47 kOhm and 10 kOhm. Another similar divider measures the battery voltage.
The green board is the voltage controller MP2307DN to provide the 5 Volt for the ESP32 from the battery voltage. And last on the right side is the 2SD613 npn transistor to switch on the load.
Because of a misalignment of 5 measurement pins I designed a riser board to reallign the setup. It was needed in any case since I switched to a DOIT DEVKIT V1 with higher power consumption, since I don't need the deep sleep mode anymore. The ESP32 now provides the AISVN2 network to recieve and transmit data from the AISVN1 box.
Pin assignment:
32 solar3 10k:10k -> 47k:10k maps 0-20V to 2-12V to 0.35-2.1V
33 battery2 47k:10k 5.7:1
34 currentA 1.5 Ohm diode 100k
35 currentB 0.1 Ohm diode 100k
25 output switch connects D-E or 6-9 to 2SD613 npn transistor
Software:
Measure every minute solar3, battery2, currentA and currentB
Every 5 minutes calculate the average of these 5 values, store in the today array
Fetch data from last 5 minutes from AISVN2
Upload data to Google Sheet with API
Update database for recent values
Every day upload the whole file to location x
Data collection:
Arrays in RAM:
long yesterday[288][8] 4.6 kByte with integer millivolt values for solar1, battery1, wind, load, solar2, battery2, solar3,
2020/06/01
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.
2020/06/02
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:
2020/06/08
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.
2020/06/10
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.
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.
Inside a 2.4W LED light illuminates the control room for 4 hours after sunset - and has almost no impact on the battery.
Within a month our setup expanded significantly:
2020/05/20
2020/06/12
2020/06/24
2020/05/20
2020/06/24
placeholder
2019/12/18
The initial setup from December 2019 requires a Laptop with Vernier software to measure just one data point. The circuit looks like this:
2020/05/17
First successful setup with WEMOS LoLin32 board, 2000 mAh battery and two 1kOhm voltage divider for input on pin 34. Voltage measurement every 2 minutes, upload via IFTTT and webhooks to google sheet, then deep sleep. Setup:
Power measurements with the WEMOS LoLin32 lite:
On 40 mA, regardless of LED on pin 22, 148 mW
WiFi 116 mA fluctuating (DHCP, http request), 430 mW, full cycle < 1 second (0.7 s average)
Sleep 0.06 mA, 0.22 mW - runtime with 1000 mAh battery: 16666 hours, or 694 days
2020/06/14
The module switched on at 10:52PM on May 16th and ran until 11:08AM on June 4th with a remaining battery voltage of 2.891 Volt. During these 18.5 days or 444 hours it transmitted 12475 data sets. For the 2000 mAh battery this results in an average current consumption of 4.5 mA or 17 mW power.
Let's do the math if this checks out. We assume 12475 submissions with 1 second for data collection with 40 mA and 1 second WiFi submission with 116 mA. This would require the following energy:
Measuring 40 mA × 12475 = 499000 mAs = 139 mAh
Submitting 116 mA × 12475 = 1447100 mAs = 402 mAh
Deep sleep 0.06 mA × 444 = 27 mAh
Check LiPo voltage with voltage divider 2× 10 kOhm (4 Volt / 20 kOhm = 0.2 mA) 0.2 mA × 444 = 89 mAh
The whole time should only have caused 657 mAh, but the battery has 2000 mAh. Second round: start June 15th. 50 days?
2020/06/15 - a new start
After almost 19 days the first round of measurements was over. With a new solar panel 5V that only needs a 1k:1k voltage divider and an additional temperature sensor LM35 the box was ready to set on the balcony. Now mounted vertically the temperature inside should not be as hot as in the past. And the resistors are inside now, too.
2020/06/30 - 14 days later
After two wees the data looks promising. I had to remove the temperature sensor ffrom 17th to 20th of June to install it in the school and get a replacement on the weekend. Other than that at least 30 days seem possible.
On 40 mA, regardless of LED on pin 22, 148 mW
WiFi 116 mA fluctuating (DHCP, http request), 430 mW, full cycle < 1 second (0.7 s average)
Sleep 0.06 mA, 0.22 mW - runtime with 1000 mAh battery: 16666 hours, or 694 days
I measured the data again in July 2020 and compiled it into a sheet for comparison. In light sleep all data in RAM is preserved, the battery lasts 26 days! And deep sleep with the ULP processor and 8 kByte slow_mem lasts 661 days. Almost two years.
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
This replaced my LoLin32 lite in Box #2 since I don't need the low power consumption and LiPo battery connector there.
Active 68~151 mA
Modem Sleep 38~56 mA with setCpuFrequencyMhz(80);
Light Sleep 17 mA with esp_light_sleep_start()
Deep sleep: 16 mA - all on USB.
Power measurements with LilyGo TTGO T-Koala with WROVER-B and USB-C 20200517 and 20200621:
WiFi 102 mA (spikes in oscilloscope, DHCP, http request), 370 mW, full cycle < 1 second (0.7 s average)
On 35.8 mA, power LED is always on, 133 mW
Light sleep 2.50 mA, 9.3 mW , data stays in RAM, 400 hours or 16 days with 1000 mAh battery
Deep sleep 0.79 mA, 2.9 mW - runtime with 1000 mAh battery: 1265 hours, or 53 days, power LED is ON
Comparison of measured data for entire board and published raw values just for ESP32:
Active 160~260 mA WiFi Tx packed, Rx listening 80~90mA vs. 50~131 mA
Modem Sleep 3~20 mA vs. 21~37 mA with setCpuFrequencyMhz(80);
Light Sleep 2.49 mA vs. 0.8 mA with esp_light_sleep_start()
Deep sleep: 0.827 mA vs. 0.01 mA with esp_deep_sleep_start()
Hibernation 0.826 mA vs. 0.0025 mA with esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
We run two ESP32 to collect, store and submit data. They are called AISVN1 and AISVN2
T-Koala with WROVER-B and 1000 mAh LiPo battery
Has 4 MByte PSRAM
Charged by solar3
Goes to light sleep in idle times
Measurements:
solar
solar3
wind
load
battery
LiPo
current_solar
power_solar
temp
NodeMCU with WROOM-32
Constant on, provides WiFi "SOLAR2"
Charged by solar2 and wind
Battery 14Ah lead
Measurements:
solar2
battery2
current_solar2
current_wind
power_wind
Additional average values for each hour:
failed connect to WiFi (5 seconds timeout)
complete upload time data
The voltage, current and power values are measured every minute. After 5 minutes the average of these values is calculated and stored in the local database of each ESP32. This gives 288 values per day. The database stores the last 7 days. Most values are stored as uint16_t and require 2 bytes for values 0-65535.
The data format is:
time_t as int32_t (works until 2038)
uint16_t for values in milliVolt: solar, solar2, solar3, battery, battery2, LiPo, wind
uint16_t for values in milliAmpere: current_solar, current_solar2, current_wind
uint16_t for values in milliWatt: power_solar, power_wind
int16_t for temperatures in centidegrees Celsius: temp (-327 °C to 327 °C)
Each row needs therefore 4 + 7 ⋅ 2 + 3 ⋅ 2 + 2 ⋅ 2 + 2 = 4 + 13 ⋅ 2 = 30 Bytes. Each day this requires 30 ⋅ 288 = 8640 Bytes. For a week that's 60480 Bytes and below the allocation limit of roughly 89640 Byte on one block for this implementation.
Redundant databases
The two stations AISVN1 and AISVN2 share their measurements. For this purpose AISVN2 runs as station and access point Wifi.mode(WIFI_AP_STA) as SOLAR2. AISVN1 submits its data and collects the remaining data every minute at second 10. AISVN2 has a RTC (ZS-042) in case ntp is not working in the school network.
AISVN1 is uploading the data to a Google Worksheet with the name of the actual year, using Google Apps Script and HTTPSRedirect Library API. The link to this data is found in DATA. AISVN2 uploads its data to a MySQL database at kreier.org/solar via JSON and a PHP script. A stack checks if the submission was successful and tries again in case of failure for 7 days. Lost power or internet at the location should therefore be covered.
Additional data
To reflect the challenges of many users in a WiFi we collect the failed attempts to connect to the WiFi per hour and the milliseconds for a successfull submission. The average for each our is stored in a second database.
Updated information on the website
To have a glimpse of the recent measurements and created energy the following data is updated each hour and published on the main page:
Solar energy created (in Wh): today, this week, this month, this year, the last 365 days
Wind energy created (in Wh): today, this week, this month, this year, the last 365 days
Time this website was last updated, tuptime AISVN1 and AISVN2, software revision (OTA is possible)
For the time being I use IFTTT and WebHooks to submit data. The Google API will take some time. Here documentation for streamline.
SolarAISVN_7 submits to IFTTT_aisvn with the T-Koala: solar, battery, current, load, wind, solar2, LiPo, bootCount
SolarAISVN2_2 submits to IFTTT_aisvn2 with LOLIN lite: battery2, current2 ±, temperature, load2, LiPo2, bootCount2
SolarPHUMY_7 submits to IFTTT_phumy with the T-Koala: solar, battery, current, load, wind, solar2, LiPo, bootCount
SolarPHYMY2_2 submits to IFTTT_phumy2 with LoLin32 lite: solar2, current2, power, temp, LiPo2, bootCount2