I have been working along with Nicola Greene (in conjunction with Water for People and Engineers Without Border UK) and James Fowkes (a fellow Nottingham Hackspace member) to look at the issue of data monitoring for pit latrines.

A group of us had a hackday at Nottingham Hackspace to discuss the problem, look at solutions and hack together prototypes.

The problem is described here in a presentation by Nicola. Basically Water for People have been installing pit latrines in various different areas in Uganda. These are filling up at very different rates, but the reason for this is unknown. They need to record the usage of the latrines in a simple, low-cost, robust and non-intrusive.

As I had been using the DataDuino for wind speed data monitoring, I suggested it as a platform for recording the sensor data. I donated a couple of DataDuinos to the project and we have nearly completed the first prototype to be installed (within the UK to start with).

There is loads of information on this wiki post about the hackday and the prototype development. There is also an overview from Nicola here.

Actually recording the data was a relatively simple matter, using the Wind Logger Arduino code with a few adjustments. This worked quite well and is low-power so should last for 6-12 months of data recording without having to change the batteries.

Flush Sensor

The main problem was to get accurate recording of a flush. We only needed to record when a ‘flush’ (usually a cupful of water) occurred. This would have to be attached to the waste pipe, so in pretty horrible conditions. It should not affect the operation of the latrine at all.

We tried many sensors and almost settled upon using an IR beam break system. But this proved hard to implement and unreliable (it turns out that water absorbs IR, so it needed a high power IR beam to get a signal back.

James had a spark of inspiration and tested a capacitance based sensor. This straps around the tube and, along with a 555 timer, creates an output frequency dependant upon the capacitance. This can be monitored with a microcontroller. It worked very well for detecting water down the waste pipe and is robust, easy to fit and does not block the pipe at all. The only issue is that it cannot be used on metal pipes, which hopefully will not be an issue.

This project was featured on Hackaday while in the early stages.

All the hard design work has mainly been done by James, he has produced a code library which will be implemented on the DataDuino. This is being tested on a pit latrine in the UK, before Nicola takes some prototypes out to Uganda for a pilot project.

Prototype Photos

Here are some photos of the prototype:

The prototype is based up the DataDuino datalogger board, but with a number of changes. The main parts are an Arduino Uno ‘brain’, an SD card holder and 3.3V regulator and a Real Time Clock. In addition to this we also need an astable 555 timer (in the prototype this is built into the sensor).
There are quite a few wiring changes. To list them:
  • There is a 470k/100k potential divider from the input voltage to A0 (measures battery voltage).
  • The output LED has been moved from pin D4 to D5.
  • The 555 timer output feeds the Timer1 input on D5.
  • A ‘Calibrate’ switch is used on pin D7.
  • The Vref pin (pin 22 of the ATmega328) has been isolated, so that the internal reference can be used.
A waterproof case is used with some hefty D cell batteries.
The current consumption is around 9mA (it is put into sleep mode, but only to IDLE, as we need to check Timer1 on pin D5 so need the main processor clock running). The energy stored in a D cell is around 17000mAh, so we can power this device for around 17000mAh / 9mA / 24 = 70 days (approx).
This is OK for the prototype, but we will need to look into reducing this in the future.
It can be reprogrammed via an FTDI lead and the Arduino IDE. This is also how you adjust the reference, clock and timer.
Data is stored onto an SD card.
This is the clever capacitance sensor. It is a 555 timer set up in astable mode, with the large pad as a capacitor which affects the output frequency of the astable.
The capacitor is wrapped around the pipe (this only works with plastic pipes). When switched on the device calibrates itself and the frequency measured is set as ‘normal’.
If any water flows down the pipe then this changes the capacitance and hence the output frequency. This is measured by the logger unit and, if it is deemed to be enough of a change, a timer is started to count the seconds of the flush.
The velcro strap means the unit is adjustable and removable.
Here is the surface mount 555 timer that James built. It is hot-melt glued to the sensor body for protection against water and ingress. This is for a prototype and will be encapsulated differently if we need to make any more of these units.
The data (shown on the serial monitor) is human readable and stored to the SD card as a line in a .csv file.
The data reads: AA,19-06-2014,09:44:38,8,4.40
This is: Reference number, Date, Time, Flush duration in seconds, Battery voltage (V)
When opened in your favourite spreadsheet program each flush event is recorded in the file with date and timestamp.

Code Information

I have put the actual logging sketch and James’s libraries into a GITHUB repository here:


This includes the instructions.

James has been working away at the new capacitance sensor and had created a github library with examples of the code he had created. They are available here: https://github.com/jamesfowkes/Code-Library/tree/master/Arduino/LatrineSensor.


These have been written for the prototype and they are put here for reference.

Download the PDF file .

Prototype Testing

Centre for Alternative Technology

The initial prototype has been taken to the Centre for Alternative Technology (CAT) in Wales to be fitted onto some pit latrines in use there.

There were some problems with the program for these tests and the results were not useful, but people did see a value in such a unit.


There was an opportunity to test the unit in Malawi with a Water For People installation. The program was sorted out (a relatively easy to fix bug in the code). The unit has been taken to Malawi for testing.

Hopefully this time we will get more useful data.


2 responses to “Latrine Logger Prototype

    1. Hi,
      The sensor was made from copper sticky backed tape stuck down to polypropylene (thin plastic) sheet. This was then covered with a layer of tape. There were two pieces of copper tape with a wire soldered to each side. This formed the capacitor.
      The whole thing was then held in place with a velcro strap around the plastic pipe.
      Hope that’s useful.

Leave a Reply

Your email address will not be published. Required fields are marked *