Monitoring water tank levels using ultrasonic help.

Hi all.

I'm trying to follow an Instructables project for measuring and monitoring the levels in my water tank.

The project can be found here -

I have bought all the gear and have set it up. I'm playing in Arduino, but I feel that the instructions I'm following are old and out of date,

I'm getting errors regarding the NewPing library say that it doesn't support my Esp8266 architecture.

Also the step;
"Start Arduino and open File > Preferences window.
Enter ( copy and paste - without the quote marks) into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas."
I believe that address has long gone. This is one of the early steps. Can I go without it or have I fallen at the first hurdle?

Once I press "verify", I get;
"WARNING: library NewPing claims to run on avr, arm architecture(s) and may be incompatible with your current board which runs on esp8266 architecture(s).
Executable segment sizes:
IROM : 246196 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 27944 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1256 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 1924 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 26136 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 277320 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 29316 bytes (35%) of dynamic memory, leaving 52604 bytes for local variables. Maximum is 81920 bytes."

Going to the next step of "Serial Monitor" shows nothing but a blank box, so I assume that I've cocked up somewhere.

So just trying to make this project work but I'm obviously venturing into new territory for me. I hope this is the write place to ask for help. If not, please point me in the right direct.

The code, posted in code tags?

An image of the setup?

A schematic?

A schematic?

In a non-Fritzing flavor.

I use a series of these sensors Taidacent Non Contact Liquid Level Sensor Water Tank Level Sensor. I have placed 4 of the sensors on the tank to indicate F, 3/4, 1/2, and E. They work great at detecting water levels but they are power hogs.

 * Water_Level_1.ino
 * Created: 19/11/2017 10:18:19 AM
 * Author: Graham Payne
 * using  NodeMCU-12E v3 ESP8266 WiFi board and 2 x Waterproof HC-SR04 type ultrasonic sounders to measure the volume of water in 2 water tanks.
 * The sonar pings for the top of the water, gets the distance in cm, 
 * calculates depth of water as cm and then calculates volume of water as liters.
 * All the info is passed by WiFi on the WLAN to the local server (RPi3) running Blynk local server
 * Info is available on a phone using the Blynk App logged into local server.
*  pin mapping is different on these boards - CAUTION. Pin numbers are generally GPIO numbers
*  This version not not impement WiFi, for testing only.

#include <BlynkSimpleEsp8266.h>
#include <NewPing.h>
    #define SONAR_NUM 1                                         // Number of sensors. Change to suit your requirements.
    #define PI 3.1415926535897932384626433832795
    const int MAX_DISTANCE = 300;                            //max distance to measure
    const int Diameter1 = 355;                                      //internal Diameter of tank 1  cm                
    const int Depth1 = 283.5;                                           //total depth of tank 1  cm   , from sensor to base   inside 

    const unsigned int Period = 2000;    //period between pings, in milliseconds. i.e  1 munute = 60,000. max 65535. Want longer? use unsigned long
    //** SENSOR PINS
    const int PingPin1 = 5;                          //     GPIO5,  D1 
    const int EchoPin1 = 4;                        //     GPIO4,  D2
    const int PingPin2 = 14;                         //     GPIO14,  D5
    const int EchoPin2 = 12;                         //     GPIO12,  D6
    const int Area1 = PI * ((Diameter1 / 2) * (Diameter1 / 2));         //area of base of tank 1
    // Global variables
    int Litres1, Litres2, Distance1, Distance2, WaterDepth1, WaterDepth2;
    BlynkTimer timer;                                                                   //config timer

    NewPing sonar[SONAR_NUM] = {                                        // Sensor object array.
        NewPing(PingPin1, EchoPin1, MAX_DISTANCE),          // Each sensor's trigger pin, echo pin, and max distance to ping.

void sendSensorReadings()
//***********Readings Tank 1
    Distance1 = sonar[0].ping_cm();                                         //get distance to the top of the water tank 1
    if (Distance1 >= Depth1 || Distance1 == 0 )  Distance1 = Depth1;                   //check it does not go negative
    WaterDepth1 = Depth1 - Distance1;                                   //calculate the depth of the water
    Litres1 = (Area1 * WaterDepth1) / 1000;                             //calculate the volume of the water as litres
    digitalWrite(13, HIGH);                                                     //flash the LED on D7, just to let us know it's running
    digitalWrite(13, LOW);

//************************* can be commented out, test use only
    Serial.println("Tank 1 water distance: " + String(Distance1));      //print depth
    Serial.println("Tank 1 water depth: " + String(WaterDepth1));     //print depth
    Serial.println("Tank 1 Litres: " + String(Litres1));                         //print litres

void setup() {
    pinMode(13, OUTPUT);                                                //LED GPIO13 D7
    timer.setInterval(Period, sendSensorReadings);      // Setup a function to be called every 'n' seconds
//**    can be commented out, test only
    Serial.begin(115200);                                               // Open serial console. 


void loop() {;;

That's the given code. I have substituted the measurements in for the tanks so it knows a rough volume.

The link to the instructions didn't work it seems - Project details here.

Here is the project so far. The box it will hopefully one day live in. The pink lead is talking to the PC but will provide power to the setup. The LED came away when moving it and I haven't looked up what pins it should go back on, so ignore that!

Any ideas folks?

Did you resolve this? it peaked my curiosity because I have been considering a way to monitor our residential sump pump. Of course, a simple HC-SR04 sensor is not appropriate in such an environment. The problem is the NewPing library does not accommodate ESPs. There is an old (4 years) port of the NewPing library for the ESP8266: NewPing8266. No idea if it really would work in your case. However, you might find a comment in this post relevant and sufficient, but not as user friendly as NewPing or NewPing8266.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.