Skip to content

Instantly share code, notes, and snippets.

@komuw
Last active July 23, 2025 06:34
Show Gist options
  • Save komuw/78f3934cae93552190ba90015d42d027 to your computer and use it in GitHub Desktop.
Save komuw/78f3934cae93552190ba90015d42d027 to your computer and use it in GitHub Desktop.
price of solar
# How many units of KPLC do you use per month?
# Go to https://www.stimatracker.com/, click on `prepaid`, then enter amount in KES you use per month.
# Click `calculate`, it will give you your consumption in kwh. Mine is KES 5000, which give ~150kwh
monthly_kplc_cost = 5000 # KES
price_per_kwh = 33 # kes per unit
consumption_per_month = int(monthly_kplc_cost/price_per_kwh) # kWh
assert consumption_per_month == 151 # kwh
consumption_per_month = 150 * 1000 # watt-hours
solar_panel_rating_in_watts = 545 # Watts. eg; https://shop.davisandshirtliff.com/products/dayliff-545w-monocrystalline-solar-module
price_per_panel = 10_085 # KES, eg; https://shop.davisandshirtliff.com/products/dayliff-545w-monocrystalline-solar-module
# Monocrystalline panels are generally more efficient than polycrystalline
number_of_hrs_of_sunlight = 5 #hours.
# for number_of_hrs_of_sunlight, various meteorological orgs can give you the exact value. But you can also just approximate based on you having lived in the region.
# It is important to use the average number of hours for a bad month(like july) in this calculation. ie, use worst case scenario.
# It is also important to note that sio jua kali pekee. Solar panels will also generate power when there's light but no sun.
# You can use https://footprinthero.com/peak-sun-hours-calculator to calculate number of sunlight hours.
# For example, that website says that for `sarit center in westlands`, peak solar is 6hrs in February and lowest is 4hrs in July.
# 15/100 # ie, 15%. Most residential panels are in between 13% to 22%. Check specification before buying.
# Note that this efficiency is different from the solar-panel-cell efficiency. That one is about 13%-22%.
# That one is about how well a panel can convert sunlight to electricity.
# However when a manufaturer rates a panel 120W, they've already factored in solar-panel-cell efficiency.
# The efficiency here is to take into account losses due to wires connections, battery inefficiency etc.
solar_panel_efficiency = 80/100
monthly_energy_production_of_solar_panel = (solar_panel_rating_in_watts * number_of_hrs_of_sunlight * solar_panel_efficiency) * 30
assert monthly_energy_production_of_solar_panel == 65_400 # watt-hours
number_of_solar_panels_required = int(consumption_per_month/monthly_energy_production_of_solar_panel) + 1 # plus one to roundup
assert number_of_solar_panels_required == 3
total_price_of_solar_panels = number_of_solar_panels_required * price_per_panel
# Remember to add price of inverter, labour, cables, etc. But the price of solar panels is the main one.
assert total_price_of_solar_panels == 30_255 # kes
# Assuming usage is spread evenly btwn day and night.
consumption_per_day = consumption_per_month/30
assert consumption_per_day == 5_000 # watt-hours
consumption_per_night = consumption_per_day/2
assert consumption_per_night == 2500 # watt-hours
# Lithium-ion (LiFePO4) batteries, you can safely discharge them much deeper, often up to 80-90%.
battery_discharge = 80/100 # percentage
inverter_efficiency = 90/100 # percentage
battery_capacity_wh = int(consumption_per_night / ( battery_discharge*inverter_efficiency) )
assert battery_capacity_wh == 3_472 # watt-hours
# If we go for a 48V battery system, the required Amp-hours (Ah) would be:
battery_capacity_ah = int(battery_capacity_wh/48)
assert battery_capacity_ah == 72 # Ah
# https://shop.davisandshirtliff.com/products/dayliff-75ah-48v-lifepo4-lithium-ion-battery-c-w-bms?_pos=2&_sid=66848d22b&_ss=r
battery_price = 140_000 # kes
# You need an inverter that can handle your peak instantaneous power consumption.
# ie, maximum amount of electricity your home demands at any single moment. When all the appliances are on.
# Sum the watt rating of those appliances. Tv(100w) + Microwave(2000w), etc = 3000W
peak_consumption = 5_000 # watt
# https://shop.davisandshirtliff.com/products/sunny-island-master-si6h-12-6kw-battery-inverter?_pos=10&_sid=9042e36a4&_ss=r
# That inverter is rated 6000W(6kw)
inverter_price = 177_350 # kes
total_price = total_price_of_solar_panels + battery_price + inverter_price
assert total_price == 347_605
number_of_years_to_break_even = int(total_price/monthly_kplc_cost)/12
assert number_of_years_to_break_even == 5.75
@komuw
Copy link
Author

komuw commented Feb 24, 2025

also see; https://gist.github.com/komuw/b598f718fc6af155249261a9bc35d702 (kenya electricity power back of envelope stats)

@komuw
Copy link
Author

komuw commented Jul 22, 2025

Using solar as base load; https://ember-energy.org/app/uploads/2025/06/Ember-24-Hour-Solar-Electricity-June-2025-6.pdf
To provide 1000MW for 24h/365d, you need 5GW solar panels and 17mwh battery. At a LCOE of $100 per mwh ($0.1/kwh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment