Grove Capacitive Water Sensor fails to work after power cycle

I am sorry that we did not consider the case of power failure when we were designing.

i just bought one of these and have discovered the same problem. how is that NOT one of the first things you think of when creating a sensor that is going to be connected to a microcontroller? especially when you’re touting easy of use w/ “plug and play” components.

has any progress been made on a software solution to fixing this issue that doesn’t require flashing the firmware? i’d really like be able to use it as part of an automated solution.

Hi
I have just bought 2 of these for a project to fill a couple of containers.
But as everyone above has noticed after a POR the results come back to 0.
This post is now 3 years old so why isn’t the firmware fixed already?
Mike

Hello.
Is there any progress regarding the release of firmware with corrections regarding calibration?

I built the required .hex files for both MCUs and uploaded them in a fork of jenskeiner’s GitHub repository. They’re located in the firmware directory at the root of the project. I used a USB to UART adapter and pymcuprog to flash the two ATTINY1616s.

Similar to pyudpi, the documentation for pymcuprog contains the wiring needed to initiate communication. The process was straightforward, and the water level sensor functions as intended after updating my code to account for the extra byte per pad.

If you want to build the firmware yourself, I’d recommend using Microchip Studio.

A huge thanks goes out to jenskeiner. I appreciate what you did.

Bought a Grove Water Level Sensor. Connected it to an Arduino Nano. Used your proposed software. Placed the sensor in a glass of tap water. I get correct results with a fill level of 65 %. Works OK for 12 hours in continuous operation. Then I remove the sensor and I get 0%. Fine. But then I put the sensor back in the water, I still get 0%. I have to clean the board and again put the sensor back in the water to obtain the 65%. Not very practical for measuring the water level in my swimming pool that I want to use gor at least 3 months.

Hi there,

SO

I can’t help but notice , you didn’t post the code? :face_with_peeking_eye:
You think maybe that might be it ? “Arduino Nano.”
USE the code tags above “</>” paste it in there, Lots of smart folks here willing to help
I doubt the sensor is bad…:crossed_fingers:

HTH
GL :slight_smile: PJ :v:

//A4=SDA
//A5=SCL
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

unsigned char low_data[8] = {0};
unsigned char high_data[12] = {0};
#define NO_TOUCH       0xFE
#define THRESHOLD      100
#define ATTINY1_HIGH_ADDR   0x78
#define ATTINY2_LOW_ADDR   0x77

void getHigh12SectionValue(void)
{
  memset(high_data, 0, sizeof(high_data));
  Wire.requestFrom(ATTINY1_HIGH_ADDR, 12);
  while (12 != Wire.available());
  for (int i = 0; i < 12; i++) {
    high_data[i] = Wire.read();
  }
  delay(10);
}

void getLow8SectionValue(void)
{
  memset(low_data, 0, sizeof(low_data));
  Wire.requestFrom(ATTINY2_LOW_ADDR, 8);
  while (8 != Wire.available());
  for (int i = 0; i < 8 ; i++) {
    low_data[i] = Wire.read(); // receive a byte as character
  }
  delay(10);
}

void check()
{
  int sensorvalue_min = 250;
  int sensorvalue_max = 255;
  int low_count = 0;
  int high_count = 0;
  while (1)
  {
    uint32_t touch_val = 0;
    uint8_t trig_section = 0;
    display.clearDisplay();
    display.setCursor(0, 0);
    low_count = 0;
    high_count = 0;
    getLow8SectionValue();
    getHigh12SectionValue();
    Serial.println("low 8 sections value = ");
    for (int i = 0; i < 8; i++)
    {
      Serial.print(low_data[i]);
      Serial.print(".");
      if (low_data[i] >= sensorvalue_min && low_data[i] <= sensorvalue_max)
      {
        low_count++;
      }
      if (low_count == 8)
      {
        Serial.print("      ");
        Serial.print("PASS");
      }
    }
    Serial.println("  ");
    Serial.println("  ");
    Serial.println("high 12 sections value = ");
    for (int i = 0; i < 12; i++)
    {
      Serial.print(high_data[i]);
      Serial.print(".");
      if (high_data[i] >= sensorvalue_min && high_data[i] <= sensorvalue_max)
      {
        high_count++;
      }
      if (high_count == 12)
      {
        Serial.print("      ");
        Serial.print("PASS");
      }
    }
    Serial.println("  ");
    Serial.println("  ");
    for (int i = 0 ; i < 8; i++) {
      if (low_data[i] > THRESHOLD) {
        touch_val |= 1 << i;
      }
    }
    for (int i = 0 ; i < 12; i++) {
      if (high_data[i] > THRESHOLD) {
        touch_val |= (uint32_t)1 << (8 + i);
      }
    }
    while (touch_val & 0x01)
    {
      trig_section++;
      touch_val >>= 1;
    }
    Serial.print("water level = ");
    Serial.print(trig_section * 5);
    Serial.println("% ");
    Serial.println(" ");
    Serial.println("*********************************************************");
    display.print("water level=");
    display.print(trig_section * 5);
    display.print("%");
    display.display();
    delay(1000);
  }//while (1)
}

void setup() {
  Serial.begin(115200);
  Wire.begin();
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) 
  {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  //display.setRotation(0);//reference (default)
  //display.setRotation(1);//clockwise 90degrees
  //display.setRotation(2);//clockwise 180degrees
  //display.setRotation(3);//clockwise 270degrees
  display.clearDisplay();
  display.setCursor(0, 0);
  display.print("Display OK & waiting");
  display.display();
}

void loop()
{
  check();
}

I would send you a photo but I don’t know how

I’ve just read all the previous posts before realizing that I will also have the power ON/OFF problem. I use batteries so I take measurements once an hour before again turning power off. This product in its actual state is useless for me. I am currently using an ultrasonic sensor to measure the distance from the sensor to the pool water level. I am getting ±1cm precision and was hoping to do better using another method. I’ll keep searching.

Hi there,

SO, Sounds like apples and oranges, Read a while you will see others have the same scenarios and how they handled it, as you found this method and this hardware do NOT harmonize.
YES, definitely jumped the gun and misjudged both the hardware and standard debugging before actually reading the thread. A few clear giveaways from your posts:

In Summary

  • Wrong sensor for the job: You bought a PCB-based capacitive strip (intended for shallow reservoirs or plant monitoring) and expected it to sit submerged in an outdoor, chemically treated swimming pool for 3 months continuously without fouling, corrosion, or drift. :face_with_peeking_eye:

  • Basic forum fumble: A raw sketch without code formatting tags, and admitted you don’t know how to post a photo, Oh’ and BTW you trapped your program execution inside an infinite while(1) within a function instead of using Arduino’s native loop().

  • Skipped the documentation and context: You only read the thread after troubleshooting, only to realize the sensor has a known issue when powered off/on—which completely invalidates your battery-saving sleep plan.

  • The “cleaning” misconception: Capacitive water level sensors rely on baseline calibration and surface tension. When pulled out :face_with_hand_over_mouth: :backhand_index_pointing_right:and re-dipped wet, lingering water films or altered surface charge throw off the baseline readings until dried or recalibrated, which you interpreted as needing a manual wipe-down each time. :grimacing:

Your ultrasonic sensor, which was the appropriate non-contact method for a pool in the first place you will find is what most use, or a site tube with a float and optical coupler/detector.

My favorite method, seen used in tanks in the Fabs.

60 GHz / 80 GHz FMCW Radar

If sticking with overhead, non-contact measurement, millimeter-wave radar completely outclasses ultrasonic for outdoor pools.

  • Why it wins: Microwave radar is unaffected by air temperature, humidity, wind, or steam. It provides direct millimeter-level accuracy (typically 1mm resolution) without needing temperature compensation.

  • Hardware: Modules like the Seeed MR60BHA1 / 60 GHz mmWave sensor or commercial equivalents mounted under the pool coping or skimmer lid.

  • Power: Pulls burst current during chirp, but sleeps cleanly between hourly wakeups on a microcontroller.

I have a demo on here with code of course , and using their APP as well, mm detection measurements can easily be made. beats +/-1cm :wink:

In most of the post on this I have seen it’s been the surface levels and variation caused by wind or splash turbulence in pools especially, Quieting the surface is easy using this “stilling well” tech the moonshiners used back in the day (I disavow any knowledge) :blush: Educational use only.
In this case any disturbance caused by surface ripples, wind, and ambient air temperature gradients affecting the speed of sound.

  • Hardware: A vertical piece of 2" or 3" schedule 40 PVC pipe placed in the skimmer or fixed to the pool edge, submerged below the lowest water level with a small 1/4" bleed hole at the bottom.

  • Implementation: Mount a weather-sealed ultrasonic sensor (like a JSN-SR04T) pointing straight down inside the tube.

  • Improvement: The pipe dampens waves completely into a glass-flat meniscus. Add a DS18B20 temperature sensor to software-compensate the speed of sound formula (v = 331.3 + 0.606 T). This reliably brings ultrasonic precision down to 2–3 mm.

I have seen other methods also, often the external tube seems to be the most reliable and accurate. YMMV :crossed_fingers:

HTH
GL :slight_smile: PJ :v:

Where can I see your demo?
BTW

  1. I was not planning to submerge the water level sensor but only place it at 5cm below the water line.
  2. JSN-SR04 has a blind zone at < 20 cm (too much)
  3. My code is copied from the proposed Grove document with the while(1)
  4. Politeness and respect is mutual.

Any news about that demo???

Hi there,

So, I didn’t have the spoon with me at the time of the first post, SO here we like to “teach a man to Fish” :fishing_pole:


Try the search option , upper right corner is a little magnifier, Use that and go advanced and put the info in , there’s 30 results. (it’s a hot topic) :grin:
"reading distance …(something).. " I think it was.

Plenty to read and understand to get the most from it, plus the PC app is there also.

HTH
GL :slight_smile: PJ :v:

hello Mr. Spoonfeeder and non-fumbling forum expert

Thanks for the ideas using the “MR60BHA1” but all above-water sensors require the protective pipe to reduce water surface turbulences as you clearly mentioned. My current Aoyyuw ultrasonic senor is mounted inside the caisson for the pump, skimmer, filter, I/O water tubing. “Desjoyaux piscine”. No room to evacuate leaves from the gross plastic filter box if I add the protective pipe. I am currently looking into the possibility of a submerged hydrostatic pressure sensor at the bottom of the pool. Any extra savvy comments about that?

Just out of interest, what range (depth?) and accuracy, are you trying to measure?

I have been trying similar techniques for my pool, especially now, coming into summer where evaporation is significant. Next, close the loop with automatic filling from our bore/spear.

Hello I’m currently getting ±1cm variation with my ultrasonic sensor. Not too bad considering the pool is 1.5m deep. I know repeatability will vary due to the turbulance from the pump and slightly modified by temperature. But same reults at night with pump off. I am a curious retired engineer that likes to understand how to explain curious behaviors. I saw that an electrostatic pressure should have a ±0.2% precision. For 1.5m should give ± .3 cm. I’ll let you know if I do some experiments. Best Regards.

another option

in the wiki it says hot swapping is not supported… I am assuming when the power is removed the internal IC’s will not reboot

Just out of interest, what range (depth?) and accuracy, are you trying to measure?

Hi

I have evaluated 2 methods for measuring my pool water level.

  1. A02yyuw ultrasonic distance sensor placed 10 cm above the water surface
  2. Hydrostatic pressure sensor placed at about 86cm deep (current loop 4-20mA,0-200cm).

My goal was to evaluate the repeatability of the water level measured values. I found the ultrasonic method the better choice after . Here are the results:

1 day measuring water level of swimming pool using ultrasonic sensor vs water pressure sensor
water temperature min.=18.38dgC; max.=19.0dgC
air temperature min.=7.69dgC; max.=14.98dgC

ultrasonMeasurements(cm):
9.29,
9.20,
9.27,
9.53,
9.43,
9.03,
8.90,
8.90,
9.17,
9.09,
9.30,
9.05,
9.00,
9.00,
9.00,
9.00,
9.04,
8.70,
8.70,
9.05,
9.10,
9.50,
9.10,
8.73,
8.62,
25 hours=> avg: 9.07 sd: 0.23
last measurementTime(gmt): 2026-10-27T13:37:43

PressureSensorMeasurements(cm):
85.68,
85.56,
85.41,
85.29,
85.19,
85.60,
85.98,
85.68,
85.43,
85.43,
85.63,
86.05,
86.00,
85.86,
86.01,
85.98,
86.27,
86.29,
86.61,
86.77,
85.99,
85.79,
86.91,
87.43,
24 hours=> avg: 85.95 sd: 0.53
last measurementTime(gmt): 2026-10-27T13:48:50


sensors used:


https://fr.aliexpress.com/item/4000312560051.html?spm=a2g0o.productlist.main.1.777e300c4Spo2P&algo_pvid=abdc3501-9ecf-4f71-81c7-002c6381ee3b&algo_exp_id=abdc3501-9ecf-4f71-81c7-002c6381ee3b-0&pdp_ext_f=%7B%22order%22%3A%22407%22%2C%22spu_best_type%22%3A%22price%22%2C%22eval%22%3A%221%22%2C%22fromPage%22%3A%22search%22%7D&pdp_npi=6%40dis%21EUR%2126.19%2126.19%21%21%2128.57%2128.57%21%40210382de17931105948255535e1069%2110000001293426388%21sea%21FR%214287180718%21X%211%210%21n_tag%3A-29919%3Bd%3A3313e7b3%3Bm03_new_user%3A-29895&curPageLogUid=T7KoiEya7r22&utparam-url=scene%3Asearch%7Cquery_from%3A%7Cx_object_id%3A4000312560051%7C_p_origin_prod%3A


https://fr.aliexpress.com/item/1005006415176688.html?spm=a2g0o.order_list.order_list_main.9.4cd15e5bNgcRCK&gatewayAdapt=glo2fra

I will probably repeat this evaluation next summer as I was seeing much more variation using the ultrasonic sensor during the heat waves a few months ago.