Water Level sensor

This sketch turns Z-Uno in Water Level sensor to periodically report data values to channel Multilevel Sensor.
  • Z-Uno board
  • Breadboard
  • Water Level sensor (like this)
  • 6 wires
// demo sketch for connecting level water sensor to Z-Uno

// add library
#include "ZUNO_DHT.h"
// pin connection sensor
#define PIN_SENSOR A0

// set up channel
ZUNO_SETUP_CHANNELS(
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, 
                          SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE,  
                          SENSOR_MULTILEVEL_SIZE_ONE_BYTE, 
                          SENSOR_MULTILEVEL_PRECISION_ZERO_DECIMALS,
                          getterLevel)
);

int level;  // here we will store the data sensor
int levelpercent;  // here we will store the value level percent

void setup() {
    Serial.begin();
    Serial.println("start");  
}

void loop() {
    // obtaining readings from the level water sensor
    level=analogRead(PIN_SENSOR);
    Serial.print("level = ");
    Serial.println(level);   
    // in percent
    levelpercent=level/10.24;
    Serial.print("levelpercent = ");
    Serial.println(levelpercent);   
    // send data to channel
    zunoSendReport(1);     
    // send every 30 second
    delay(30000);
}

byte getterLevel() {
    return (byte)levelpercent;
}
Download this sketch