Monday on the farm — Jumatatu ya kupanga: Plan your week and check your numbers. Learn more ↗
Back to blog
· 8 min read

Powering Your Farm IoT on KPLC — Voltage, Plugs, UPS, and Why ESP32 Is Safe

How to safely power a Raspberry Pi, sensors, and irrigation valves on Kenyan 240V mains — without frying anything or risking a fire. UPS sizing, brownout pro...

Share:

Powering Your Farm IoT on KPLC — Voltage, Plugs, UPS, and Why ESP32 Is Safe

Most of the questions farmers ask about IoT are about software. Most of the failures are about power. KPLC brownouts, the wrong charger from AliExpress, a UPS that lies about its capacity, a 12V power supply running 50 metres of cable — these are the things that take a working setup down for a weekend.

This post is the power-engineering basics every Kenyan farmer setting up IoT should know. It is the post to read before you buy a single adapter.

Kenya's electrical standards in 30 seconds

  • Voltage: 240V AC (with brownouts as low as 180V common in rural areas)
  • Frequency: 50 Hz
  • Plug type: Type G — the three large rectangular pins, same as the UK
  • Earth: Yes, all wall sockets should have a working earth pin The single most important label on any adapter you plug into a Kenyan wall:

<blockquote> INPUT: 100-240V ~ 50/60Hz

</blockquote> If an adapter says "INPUT: 110-120V only" — do NOT use it in Kenya. It will burn out within seconds.

The voltage cascade — from 240V wall down to 3.3V sensor

The trick to safe farm IoT is understanding that only one or two things in your whole setup touch 240V. Everything else runs on low voltage that cannot hurt you.

Here is the cascade for a typical farm setup:

VoltageLives wherePowers
240V ACWall socket → UPS → Pi PSU brickUPS, Pi PSU, 12V irrigation PSU
12V DCController boxSolenoid valves, motorised dampers
5V DCUSB output from Pi PSU and chargersPi 4, USB sensors
3.3V DCESP32 GPIO pinsESP32 board itself, most sensors
Variable DCLiPo / 18650 cellsField nodes, animal tags

Notice the pattern. 240V never touches a sensor. It goes into a PSU brick, comes out as 5V or 12V, and from there it cascades down. The mains-voltage parts of your system are the UPS, the Pi PSU, and the irrigation controller PSU. That is it.

Why the ESP32 is safe — even outdoors

The ESP32 is the matchbox-sized computer in every field node. People worry about putting them outdoors, near children or animals.

The reality:

  • An ESP32 runs internally on 3.3V DC
  • It is powered through a USB cable from a phone charger, or directly from an 18650 battery
  • It never touches mains voltage at any point
  • A field-deployed ESP32 with solar power has no connection to mains at all To put it in perspective: the voltage in an ESP32's wiring is less than a single AA battery (1.5V). A person or animal contacting the wiring on a field node is in less electrical danger than touching a TV remote control.

The mains-voltage risk is in the controller box at your homestead — not in the field. Treat that box like any electrical installation: secured, dry, on a circuit breaker, with cabling rated for the job.

UPS — what to buy and how to size it

A UPS is non-negotiable for the Raspberry Pi. Brownouts will corrupt the microSD card if the Pi loses power abruptly. The UPS is the buffer.

Sizing. For a Raspberry Pi 4 plus a 4G dongle, you need:

  • Power draw: ~10W continuous (Pi 4 idle + 4G dongle)
  • Spike on boot: ~30W for a few seconds
  • A 500VA UPS handles this with 30–60 minutes of runtime That is enough for the Pi to ride out any short outage and to shut itself down cleanly if power stays off too long.

Brands worth looking at in Nairobi:

BrandTypical 500VA priceNotes
APC Back-UPSKES 7,500–9,000Premium, reliable, easy USB management
MercuryKES 5,500–7,000Solid mid-tier, common locally
LyonnKES 5,000–6,500Budget option, acceptable for a Pi

Brands to avoid: Anything under KES 4,500 with no published runtime spec is usually false economy. The battery dies within months and the unit is often rebadged from low-quality stock.

One non-obvious feature to look for: USB management. The UPS should have a USB cable that connects to the Pi, letting software see the UPS state. When power is lost, the Pi can shut itself down automatically before the battery dies — preventing SD card corruption. APC units come with this built in; budget units often do not.

Connecting the UPS to the Pi — graceful shutdown

Once your UPS has a USB management cable plugged into the Pi, install apcupsd (for APC) or nut (for most other brands). Configure it to shut the Pi down when:

  • Mains power has been off for 5 minutes, OR
  • Battery level drops below 15% This costs you nothing and prevents the most common cause of Pi failure in Kenya.

Powering field nodes — solar + 18650 cells

Field nodes never touch mains. Each one carries its own power, which means each one is electrically isolated from your wall sockets.

The standard field-node power stack:

  • 5–10W solar panel mounted on top of the weatherproof enclosure
  • TP4056 charge controller — a tiny circuit board that safely charges the 18650 cell from the panel
  • One or two 18650 cells in a holder — stores energy for nights and cloudy days
  • 3.3V regulator — drops cell voltage to the 3.3V the ESP32 needs This complete power module costs about KES 1,500–2,000 in parts and runs a sensor node for years. We will go into specifics in the dedicated batteries-and-solar post in this series.

Powering irrigation valves — 12V DC, not mains

Solenoid valves come in two flavours: 24V AC or 12V DC. For farm IoT, use the 12V DC variety. Here is why:

  • 12V DC valves can be triggered directly by a small relay from a microcontroller

  • 12V DC cable can run 20–50 metres with minimal loss

  • 12V DC is safe — you can handle the cable with bare hands

  • 24V AC requires mains-to-AC conversion and is harder to control safely A typical 6-zone irrigation controller has:

  • One 12V DC mains adapter (rated 100–240V input, so safe for KPLC)

  • A 6-channel relay board controlled by the Pi or an ESP32

  • Twisted-pair cables running out to each valve

  • Each valve wired with simple two-conductor cable, no special connectors needed The whole thing sits in a sealed enclosure at the controller location. The only mains voltage in the entire irrigation system is inside this one box.

Brownouts — Kenya's specific problem

Rural KPLC delivers voltage that swings. A "240V" supply in practice can be 180V–270V depending on time of day and load. This swing causes three classes of failure:

Voltage conditionWhat happens
Below 200V (brownout)PSUs deliver less than rated current; Pi may freeze; fridges undervoltage-cycle
Above 260V (surge)Cheap PSUs burn out; weak components fail prematurely
Brief cuts (under 1 second)Pi reboots, SD card may corrupt

Protection layers:

  • AVR-equipped UPS. An "Automatic Voltage Regulator" UPS handles brownouts/surges within 160V–280V range and gives clean 240V output. Worth the extra KES 1,500–2,500 in upgrade cost.
  • Surge protector between the wall socket and the UPS. KES 800. Stops the catastrophic spikes.
  • Pi running on UPS USB-management. Lets the Pi notice power conditions and react. If you live somewhere with chronic KPLC issues — and many rural Kenyan farms do — invest in an AVR UPS, not just a standard one.

Common power mistakes and how to avoid them

MistakeConsequenceFix
Buying a "Raspberry Pi PSU" from AliExpress for USD 4Pi brownouts under load, freezes, SD corruptionBuy the official PSU from Amazon UK or Nerokas
Skipping the UPS to save moneyFirst brownout = corrupted SD card = lost dataBuy at minimum a 500VA UPS — your single most important purchase
Using a 100-120V US plug travel adapterBurned out adapter, possible fireBuy adapters labelled 100-240V ~ 50/60Hz
Daisy-chaining UPS to UPSConfused load reporting, both die earlyUse one UPS, properly sized
Putting mains wiring inside a sensor field nodeLethal if wires get exposedField nodes use only 3.3V or 5V DC battery power, never mains
12V valve cable run too long, undersizedValve does not fully open, signals timeoutsUse 0.5mm² minimum, ≤50m runs

Toolkit and budget

If you are putting together a complete power package for a Phase 1 setup:

What you need:

  • 1× Raspberry Pi 4 official PSU (UK Type G) — KES 1,800–2,500
  • 1× 500VA AVR UPS — KES 6,000–8,500
  • 1× Surge protector (multi-outlet) — KES 800
  • 1× 12V 3A switching PSU for irrigation controller — KES 1,200 (if doing irrigation)
  • Cabling, wire, terminal blocks — KES 1,500

Where to buy:

  • PSU: Amazon UK or Nerokas (genuine units only)
  • UPS: Nairobi Industrial Area (touch and test before buying)
  • Surge protector + switching PSU: Local hardware/electrical shops
  • Cabling: Nairobi Industrial Area or AliExpress

Steps:

  1. Buy the UPS first. Test it on a desk lamp before committing.
  2. Plug the Pi PSU into the UPS only — confirm the Pi boots cleanly.
  3. Add the surge protector between wall and UPS.
  4. Install apcupsd or nut on the Pi and confirm graceful shutdown works.
  5. Only after this is solid, expand to irrigation power.

Time: 1 day to assemble and test the homestead power stack.

Total cost: KES 11,000–14,000 for the power layer alone.

What to do next

Power is dull until it fails. Get this part right once and forget about it. Cut corners here and you will be debugging mysterious Pi reboots and corrupted data for the next six months.

If you are also recording milk yield, feed cost, mortality, or sales while you build out the hardware, do that at shira.farm — the dashboard is free and runs without any sensors.

See it in action

Tap this exact setup on our interactive visual guide — photorealistic farm scenes with clickable explainers showing what every device does, what it costs, and which Shira tier unlocks it.

Open the IoT Showcase