Create a gauge on dashboard for rainwater tank?

Hello everyone :smiley:

I’ll start with the most important: I am a real beginner and a pure self-taught computer enthusiast, but with perseverance I am making progress. :trophy:

I managed to create a code using an Arduino Nano + HRC-04 ultrasonic sensor and a 433Mhz transmitter :satellite: to retrieve the distance from the top of my tank to the bottom.

Then, via the receiver code :mailbox_with_mail: on the Arduino Uno, I modified the value in JSON format and finally I used node-red to create a gauge (like the rpi-info module by @piznel).

Could someone help me create a module on Gladys to integrate it into the dashboard?

Thanks in advance to everyone who will help me

Hello @jerome!

I assume you’re on Gladys 3? I don’t know if you’re following the project’s progress, but we’re currently working on Gladys 4 and the first alpha version has already been released.

In Gladys 3, it’s not possible to create a dashboard box linked to a module. In Gladys 4, the module functionality is a bit different, but it’s possible!

Hello @pierre-gilles.

Indeed, I am currently on Gladys 3. I am following the project, I check the forum every day.

Before starting with the alpha, I try to make sure everything works on Gladys 3 first.

Actually, my idea would be to have something similar to rpi-info.

Here’s what I managed to do with Node-RED

I’m not answering your question, but could you share your setup? I bought a house with a tank and I’m really interested :grin:

No problem, Do you want photos or a diagram?

I like the idea of the « Rainwater tank » :smirking_face:
I’m also interested in a future project.

Both, my captain :grin:

Hi,

you will make two people happy, I’m also interested in your setup/photos :smile:. I also have a project to monitor the remaining water in my rainwater tank, so as not to start the automatic watering when it’s empty ^^

Hello
one more :grin:, I plan to do the same but not right away…
I need to find the time :wink:
So I’m interested, Thanks!!

I can’t integrate the 433MHz transmitter and receiver into fritzing.

Does anyone know how?

/*
 * Example code for an HC-SR04 ultrasonic sensor.
 * Value communication at 433MHz
 */

#include <VirtualWire.h>

/* Constants for the pins */
const byte TRIGGER_PIN = 2; // TRIGGER pin
const byte ECHO_PIN = 3;    // ECHO pin
const byte VW_SET_TX_PIN = 12;

 /* Constants for the timeout */
const unsigned long MEASURE_TIMEOUT = 25000UL; // 25ms = ~8m at 340m/s

/* Speed of sound in air in mm/us */
const float SOUND_SPEED = 340.0 / 1000;

/** Setup() function */
void setup() {

/** Initialize the VirtualWire library */
vw_setup(2000);

/* Initialize the serial port */
  Serial.begin(115200);

  /* Initialize the pins */
  pinMode(TRIGGER_PIN, OUTPUT);
  digitalWrite(TRIGGER_PIN, LOW); // The TRIGGER pin must be LOW at rest
  pinMode(ECHO_PIN, INPUT);
}

/** Loop() function */
void loop() {

  /* 1. Start a distance measurement by sending a HIGH pulse of 10µs on the TRIGGER pin */
  digitalWrite(TRIGGER_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGER_PIN, LOW);

  /* 2. Measure the time between the sending of the ultrasonic pulse and its echo (if it exists) */
  long measure = pulseIn(ECHO_PIN, HIGH, MEASURE_TIMEOUT);

  /* 3. Calculate the distance from the measured time */
  int distance_mm = measure / 2.0 * SOUND_SPEED;

  /* Display the results in mm */

  Serial.print(distance_mm);
  Serial.println();

  /* Send the message */
  vw_send((byte *) & distance_mm, sizeof(distance_mm));

  /* Wait for the end of the transmission */
  vw_wait_tx();

  /* Wait delay to avoid displaying too many results per second */
  delay(1000);
}

To use it with the serial monitor:

//load libraries
#include <VirtualWire.h>

const byte VW_SET_RX_PIN = 11;

void setup() {
  Serial.begin(115200);

  // Initialize the VirtualWire library
  // You can change the RX/TX/PTT pins before vw_setup() if necessary
  vw_setup(2000);
  vw_rx_start(); // Now we can receive messages

}

void loop() {
  float distance_mm;
  byte message_size = sizeof(float);

  /*
   The "message_size" variable must be reset to
   the size of the variable before being able to receive a message.
   The easiest way is to use a local variable to avoid
   having to reassign the value at the beginning of loop().
   */

  // Wait to receive a message
  vw_wait_rx();

  if (vw_get_message((byte *) &distance_mm, &message_size)) {
    // Copy the message, whether it is corrupted or not

   if (distance_mm >= 0 && distance_mm <= 400)
   { Serial.print("Tank filled to: 100%"); }
   else if (distance_mm >= 401 && distance_mm <= 540)
   { Serial.print("Tank filled to: 90%"); }
   else if (distance_mm >= 541 && distance_mm <= 680)
   { Serial.print ("Tank filled to: 80%"); }
   else if (distance_mm >= 681 && distance_mm <= 820)
   { Serial.print ("Tank filled to: 70%"); }
   else if(distance_mm >= 821 && distance_mm <= 960)
   { Serial.print ("Tank filled to: 60%"); }
   else if (distance_mm >= 961 && distance_mm <= 1100)
   { Serial.print ("Tank filled to: 50%"); }
   else if (distance_mm >= 1101 && distance_mm <= 1290)
   { Serial.print ("Tank filled to: 40%"); }
   else if (distance_mm >= 1291 && distance_mm <= 1400)
   { Serial.print ("Tank filled to: 30%"); }
   else if (distance_mm >= 1401 && distance_mm <= 1550)
   { Serial.print ("Tank filled to: 20%"); }
   else if (distance_mm >= 1551 && distance_mm <= 1700)
   { Serial.print ("Tank almost empty: 10%"); }
   else if (distance_mm >= 1701 && distance_mm <= 2000)
   { Serial.print ("Tank almost empty: 5%"); }
   Serial.println();
  }
}

To use it with Node-red (Json format):

//load libraries
#include <VirtualWire.h>

const byte VW_SET_RX_PIN = 11;

void setup() {
  Serial.begin(115200);

  // Initialize the VirtualWire library
  // You can change the RX/TX/PTT pins before vw_setup() if necessary
  vw_setup(2000);
  vw_rx_start(); // Now we can receive messages

}

void loop() {
  int distance_mm;
  byte message_size = sizeof(int);

  /*
   The "message_size" variable must be reset to
   the size of the variable before being able to receive a message.
   The easiest way is to use a local variable to avoid
   having to reassign the value at the beginning of loop().
   */

  // Wait to receive a message
  vw_wait_rx();

  if (vw_get_message((byte *) &distance_mm, &message_size))
    // Copy the message, whether it is corrupted or not

  Serial.print("{\"HRC_04\":");
  Serial.print(distance_mm);
  Serial.println("}");

  delay(5000);

}

For those who then want to use node-red with the gauge above:

I was inspired by this tutorial for those who want a small video

https://projetsdiy.fr/debuter-arduino-node-red-enregistrer-afficher-mesures-json-port-serie/

I’m looking back into this topic for v4 @link39 did you try something back then?

I really feel like doing this with an esp12 and mqtt

Last summer I installed a Fibaro double switch behind a double switch.

  • Switch 1: turns on the pump that sends water to the garden
  • Switch 2: turns on the solenoid valve that allows water to pass for automatic watering

Now I need to add a system that prevents the pump from turning on if there is no more water. This is where I am, I think I’ll get back to it in the spring so I can test it, it’s too cold now :cold_face:

Rather than an Arduino, an ESP seems perfectly sufficient to me, but I haven’t progressed any further than that.

Well, the first tests are conclusive, it’s precise.

I need to find my node mcu for the WiFi and Mqtt (Gladys) part.

Really cool @VonOx

I’m skiing this week but it makes me want to get back to this project. Keep me informed when you’ve made progress.

A+