THE PROJECT LIBRARY PROJECT 01Ideas worth building. Problems worth solving.
KSEF PROJECTS / 001PROJECT PROPOSAL
INTERNET OF THINGS · WATER ACCESS

A SMARTER WAY TO ACCESS WATER

MajiPay.

An M-Pesa-enabled, IoT water vending machine built with the ESP8266.

A practical project that combines mobile payment, automated dispensing and real-time monitoring to make small-volume water sales more accurate and convenient.

ESP8266M-PesaWater dispensingIoT
MAJIPAY
WATER READY1.0 LPay • Fill • Go
◆
◔
✦
PROJECT CATEGORYApplied technology / Engineering
DOCUMENT TYPEBuild-and-test proposal
PREPARED FORKenya Science & Engineering Fair
MAJIPAY / THE IDEA02 / 05
01 — CONTEXT & DESIGN

The problem.
The possibility.

Small quantities of drinking water are often sold through manually operated taps. Attendants must verify payment, measure water and supervise dispensing. That can cause queues, inconsistent quantities and limited visibility of water remaining.

Project aim

Design and evaluate a prototype that dispenses a selected volume of water only after a confirmed M-Pesa payment, while recording the quantity dispensed and the tank level.

Research question

Can an ESP8266-controlled dispenser, connected to a verified payment service, deliver a selected water volume accurately and reliably?

Specific objectives

  1. Build a working low-voltage dispensing prototype.
  2. Connect the ESP8266 to a payment-verification backend.
  3. Measure dispensed water with a flow sensor.
  4. Display status and monitor stock or tank level.
  5. Test accuracy, payment gating and failure handling.

Working hypothesis

If the system counts pulses from a calibrated flow sensor and opens the valve only after a verified payment, it can dispense water close to the selected volume without an attendant measuring each sale.

Important distinctionPayment confirmation comes from a trusted server, not from a customer pressing a “paid” button or showing a text message.
MAJIPAY / HOW IT WORKS03 / 05
02 — SYSTEM ARCHITECTURE

From payment
to a precise pour.

A backend handles M-Pesa credentials and payment callbacks. The ESP8266 receives a one-time dispense authorisation and controls the water hardware.

01Select
volume
→
02Pay via
M-Pesa
→
03Verify on
server
→
04Dispense &
measure

Prototype components

ComponentPurpose
NodeMCU ESP8266Wi-Fi and control
Flow sensorCounts dispensed volume
Food-safe valve or pumpControls water flow
Relay / MOSFET driverSwitches valve or pump
Buttons and displaySelection and feedback
Tank + level sensorStorage and low-water alert
Separate rated power supplySafe power for actuator

Control logic

  1. Customer selects a volume and enters an M-Pesa phone number.
  2. Server starts an STK Push for the correct price.
  3. Server checks the M-Pesa result and records a unique order ID.
  4. ESP8266 retrieves an approved, unused order over HTTPS.
  5. Valve opens; flow pulses are counted until the calibrated target is reached.
  6. Valve closes; the order is marked dispensed and the result is logged.
Build safelyUse low-voltage circuitry, keep electronics away from water, add a fuse and a normally closed valve, and use food-contact-safe tubing if demonstrating drinking water. Check the flow sensor’s output voltage before connecting it to the ESP8266’s 3.3 V pins.
MAJIPAY / BUILD & EVALUATE04 / 05
03 — METHODOLOGY

Build it.
Then prove it.

Start with a tabletop prototype and clean test water. Use the M-Pesa Daraja sandbox for the payment demonstration; real transactions require approved production credentials and a reachable HTTPS callback.

Construction plan

  1. Mount tank, outlet, flow sensor and normally closed valve; check for leaks.
  2. Wire the ESP8266, display and buttons; drive the actuator through a suitable driver and separate supply.
  3. Program Wi-Fi connection, selection menu, pulse counter and automatic shut-off.
  4. Create a backend for STK Push, callback verification, order state and a simple admin dashboard.
  5. Calibrate pulses per litre using a measuring jug; repeat for at least three volumes.

Variables to measure

  • Independent: selected volume (e.g. 250, 500 and 1,000 mL).
  • Dependent: actual measured volume and dispense time.
  • Controlled: same sensor, tubing, tank height and supply voltage for each trial.
VOLUME ERROR|actual − target| ÷ target × 100%Lower error indicates more accurate dispensing.

Test plan & results sheet (complete after building)

TrialTarget (mL)Actual (mL)Error (%)Time (s)Payment verified?
1250________________________________
2500________________________________
31,000________________________________

Repeat each target at least three times, calculate the average error, and separately test declined payment, duplicate callback, lost Wi-Fi, empty tank and power interruption. The valve should remain closed when authorisation is absent or interrupted.

MAJIPAY / CONCLUSION05 / 05
04 — OUTCOMES & NEXT STEPS

Small machine.
Real-world impact.

MajiPay is designed to demonstrate a pay-before-dispense service that measures each sale and makes water availability visible to an operator.

Expected outcomes

  • Water flows only after a verified order.
  • Dispensed quantities can be compared with selected quantities.
  • The display shows progress and errors clearly.
  • The operator can see transaction and tank information.

Limitations & improvements

  • Wi-Fi or payment-service outages can delay a sale; never dispense on an unconfirmed payment.
  • Sensor calibration may change with pressure and flow rate; recalibrate when hardware changes.
  • For public use, add filtration, water-quality checks, secure housing and maintenance procedures.
  • Later versions could support solar power and SMS receipts.
THE FAIR DEMONSTRATION

Select a volume → trigger a sandbox payment → show server verification → watch the dispenser stop at its target → measure the output in a graduated jug. Show a failed-payment case to prove the valve stays shut.

Conclusion

The project proposes a practical combination of mobile payments and automated measurement. Its success should be judged using recorded trials—not claims made before construction—particularly volume error, response time and safe behaviour during failures.

References & further reading

  • Safaricom Developer Portal — Daraja API and STK Push documentation: developer.safaricom.co.ke
  • Espressif Systems — ESP8266 technical documentation: docs.espressif.com
  • Flow sensor datasheet for the exact model used; record its calibration during testing.
Student name: __________________________School: __________________________Date: ______________