sebin
Published

Realtime Reservoir Monitoring

An IoT based system which can monitor water levels and several other parameters of dams and canal systems.

BeginnerShowcase (no instructions)68
Realtime Reservoir Monitoring

Things used in this project

Story

Read more

Code

Ultrasonic code for wio terminal

C/C++
#include "Ultrasonic.h" //include ultrasonic distance sensor library 
#include "TFT_eSPI.h" //include TFT LCD library 

TFT_eSPI tft; //initialize TFT LCD 

TFT_eSprite spr = TFT_eSprite(&tft); //initialize buffer
 
Ultrasonic ultrasonic(D0); //set ultrasonic distance sensor pin as D0

void setup()
{
  tft.begin(); //start TFT LCD
  tft.setRotation(3); //set screen rotation
  spr.createSprite(TFT_HEIGHT,TFT_WIDTH); //create buffer
  
}
void loop()
{
    spr.fillSprite(TFT_BLACK); //fill background 
    spr.setTextSize(2); //set text size 
    spr.setTextColor(TFT_YELLOW); //set text color 
    
    spr.drawString("Current Water Level", 55, 10); //draw text string 
    spr.drawFastHLine(40, 35, 240, TFT_DARKGREY); //draw horizontal line 
    
    spr.setTextColor(TFT_WHITE); 
    spr.drawString("- Centimeters: ", 20, 50);
    spr.drawString("- Inches: ", 20, 80);
    int water_level=0;
    water_level=350-ultrasonic.MeasureInCentimeters();
    spr.drawNumber(water_level, 200,50); //display distance in centimeters
    delay(50);
    spr.drawNumber(ultrasonic.MeasureInInches(), 130,80); //display distance in inches 
    
    spr.pushSprite(0,0); //push to LCD 
    delay(500);
}

Credits

sebin

sebin

3 projects • 1 follower
Innovation & Entrepreneurship Development Cell Nodal Officer

Comments