This tiny library is for reading the current level from the Grove Water Level Sensor. Please note that the code behind this library is from Seeed Studio - Grove Water Level Sensor. I've only put the code into a library to reduce code in my Arduino project, and now I would like to share this with you.
Note from me (the forker): I forked the original project because:
A: The example cannot be found under the Arduino IDE since there is none, except on the readme.
B: I added 'readCM' because why not.
C: The most important reason is that you cannot directly download the library under releases. The result is that you have to download (git clone) the project, then unzip it, go inside the folder, and zip it anew without the readme
Here're some of the project's best features:
- Getting the Data out of the Sensor without unnecessary complexity
- Get Percentage
- Get Centimetre
1. Go under Releases and download the waterlevelsensor.zip. Then include it in the Arduino IDE by hovering over Sketch -> Include Library -> Add .ZIP Library
2. Go under File -> Examples -> Grove_Water_Level_Sensor and upload the code or simply copy paste this code:
#include <waterlevelsensor.h>
WaterLevelSensor sensor = WaterLevelSensor();
void setup() {
Serial.begin(9600);
}
void loop() {
//lesen des Grove Wasser Level Sensors
int waterLevel = sensor.readPercentage();
int waterLevelinCM = sensor.readCM();
//Ausgeben des ermittelten Wertes
Serial.print(waterLevel);
Serial.println("%");
Serial.print(waterLevelinCM);
Serial.println(" cm");
Serial.println("--------------------------");
delay(500);
}