AdamVStephen / gem-water-level-gauge

Building a water level gauge using MPX5010DP sensor and arduino.
GNU General Public License v2.0
0 stars 1 forks source link

gem-water-level-gauge

Building a water level gauge using MPX5010DP sensor, driven by an Arduino nano, using a 16x2 LCD panel as a display, and with a serial interface to change settings (persisted on the Arduion EEprom).

Inspired by http://brelovich.se/2011/09/water-level-sensor-arduino-ethernet/ and a suggestion from Nick Balshaw.

gemfinalconstruction

Operation

  1. For basic operation as per the default firmware parameters, simply power up using a USB-A male (power)to USB Mini-B male cable.

  2. All user modifiable parameters can be changed over the serial link and are persisted in the EEprom. Alternatively, the defaults can be changed in the source and the Arduino reflashed using the Arduino IDE.

  3. The device will take a sample measurement from the sensor every cycle. The cycle time is a modifiable parameter, with a default of 1 second (this is also the minimum, otherwise the display flashes in an ugly way.)

  4. The raw ADC value of 0-1023 is converted to a level in centimetres. The conversion calculation is simple. The sensor produces a voltage of 0.2V for 0kPa and varies linearly up to 4.7V for 10 kPA. The pressure is generated by water in the tube, so P (Pa) = rho g h where rho is the density of water, g gravitational acceleration and h the height of the water column. The level is then converted to centimetres as the most convenient unit.

  5. The display is updated to indicate the current reading, min-max range, and average. The average is computed as the mean of the 10 previous values. To the right of the current/average level readings, a bar graph shows the level graphically. As the LCD panel has 8x8 pixels per character, each row indicates 12.5% of the full range.

  6. The current level is compared to very low (lolo), low (lo), high (hi) and very high (hihi) thresholds. The thresholds have default values 5,10,40,45 but can be reset over the serial interface. If an alarm is detected, it is signalled to the user via the LCD panel.

  7. To verify that the software is running (in the case that levels are stable, which is normal) - the right hand bars cycle around to indicate that each delay loop has completed.

  8. In honor of 37signals.com every 37 cycles the information display shows the number of iterations, hours and minutes since powerup.

  9. Internally, the code makes provision for other interfaces (serial, LED...) but these are not documented here.

  10. To modify the parameters using the serial cable, connect the USB-A to a laptop with a suitable terminal program. This could be a gtkterm or minicom on Linux, or Putty on Windows. The terminal setup is 115200 Baud, 1-8-N.

  11. The serial interface design is a set of single letter commands, with optional arguments. The commands are as follows 1.1 To get alarm levels : "g" 1.1 Set alarm very low level : "s L N" 1.1 Set alarm low level : "s l N" 1.1 Set alarm high level : "s h N" 1.1 Set alarm very high level : "s H N" 1.1 Configure alarm very low level : "e L N" 1.1 Configure alarm low level : "e l N" 1.1 Configure alarm high level : "e h N" 1.1 Configure alarm very high level : "e H N" 1.1 Set cycle time (ms) : "s d N"

Serial Interface Example

gemserialinterface

Bill of Materials

Item Specific Component Source Cost
Pressure sensor MPX5010DP CPC £13.49
Arduino MC Nano Ebay £1.87
16x2 LCD N/A Ebay £3.25

A few cables and bits of circuit board completed the electronics part of the project. Nick (see below) provided a fine case to hold it all together.

Notes

Nick Balshaw is a scholar and a gentleman. He captains the 70 foot narrowboat "Gem" around the South of England. For further biographic details, see his excellent Tokamak blog https://alltheworldstokamaks.wordpress.com/

nickb

Easter Eggs

Each iteration from boot is counted, and on certain special numbers, the information display is briefly subverted with an alternative message. Given modulo arithmetic combinations, some iterations will be particularly lucky.