River Level monitor

Hi all, total noob here but i need to develop my understanding of creating a river level monitor. I have settled on the idea based around the ultrasonic sensor HC-SR04 and have a section of code to upload which appears to be working. what i am missing is a way of getting the device to work and take readings autonomously and translating that reading into visual graphics. bit of background for you all to start with i live in a village that was flooded heavily on boxingday (we even made the front cover of the tabloids) but we have a relatively speaking small amount of monitors on our river and tributaries. i want to empower the local community with plans and demos on how to build their own river level monitor and we can then look at an opensource project where everyone's monitor uploads via their wifi. As we implement flood alleviation schemes the community can see in rel time how this helps them avoid being flooded.

Any help would be appreciated .



Do you have a solid mounting, like a bridge??

Many good river depth monitors have a pressure sensor embedded in the stream bed.


Thanks i have a few points to mount these to mainly bridges but as i want the network to expand via the community i assume i will need some plans for a bracket or even zip tying onto overhanging branches.

dave-in-nj: http://makerzone.mathworks.com/producthardware-detail/real-timetide-gauge-to-tweet-tidal-alerts/

Wow consider my mind blown! that was a very helpful link and its amazing how far this could be taken. thanks

i have a piece of code ive found but i keep getting a reading of 112 no matter what is in front of the sensor and at what distance. I’m assuming I’ve done something wrong to cause this but i’m not sure what?.

code is below:

#define trigPin 10
#define echoPin 13

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

void loop() {
float duration, distance;
digitalWrite(trigPin, LOW);

digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) * 0.0344;

if (distance >= 400 || distance <= 2){
Serial.print("Distance = ");
Serial.println(“Out of range”);
else {
Serial.print(“Distance = “);
Serial.println(” cm”);

Use new ping library for Ultrasonic sensors:


Good luck

I would offer that it cannot easly see distance closer than 1/2 meter or easilhy see more than 2 meters. but, between things should work fine. once you get it working, then see what distances can be done reliably.

I use car back-up sensors with the supplied circuit board. they are not good close, and have a limit of how far they can 'see'