Monitor Liquid Level

details

This project is about a simple and easy way to monitor and measure any liquid level at your house. This is tested and fully working at the tank that author has at his basement full of petroleum. There are many times especially at the winder that he needs to be aware of the level. Furthermore, It is quite useful to record how much petroleum have you consumed per year and gather all these information to economic analysis.

For this project I will be using the following:

  • Arduino Uno
  • Ethernet shield
  • HC-SR04 UltraSonic Sensor
  • Wires for connecting the sensor to arduino
  • CAT5 cable
  • Router
  • Laptop

Picture of Connecting the hardware

CODE

/*****************************************************************************
An idea for Future Smart Homes

Oil Monitoring is a project that lets you monitor the ammount of oil
at yourhome. Alerts you with a message on facebook, gmail or even SMS
at your personal phone and more important gives you statistics about
the past. 

* Arduino Uno
* Ethernet shield and ethernet cable | Wireless shield
* UltraSonic Distance Sensor
* Wires for arduino pins

Developed by Tzivaras Vasilis
Last Update: [10-06-2015]
*****************************************************************************/

#define echoPin 7
#define trigPin 8

#include <SPI.h>
#include <Ethernet.h>

// UltraSonic sensor min and max value to be accepted.
int maximumRange = 200;
int minimumRange = 0;

long duration, distance;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
   
   // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void getSensorValue() {
	digitalWrite(trigPin, LOW); 
	delayMicroseconds(2); 

	digitalWrite(trigPin, HIGH);
	delayMicroseconds(10); 

	digitalWrite(trigPin, LOW);
	duration = pulseIn(echoPin, HIGH);

	//Calculate the distance (in cm) based on the speed of sound.
	distance = duration/58.2;
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          
		  getSensorValue();
		  client.print("{\"id\":");
		  client.print("1770,");
		  client.print("\"measurement\":");
		  client.print(distance);
		  client.print("}");
		  
          client.println("<br />");
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

If you refer to this URL, You can make this project easily.

http://www.instructables.com/id/Monitor-Liquid-Level/?ALLSTEPS

Source : http://www.instructables.com/id/Monitor-Liquid-Level/?ALLSTEPS

This project is about a simple and easy way to monitor and measure any liquid level at your house. This is tested and fully working at the tank that author has at his basement full of petroleum. There are many times especially at the winder that he needs to be aware of the level. Furthermore, It is quite useful to record how much petroleum have you consumed per year and gather all these information to economic analysis.

For this project I will be using the following:

  • Arduino Uno
  • Ethernet shield
  • HC-SR04 UltraSonic Sensor
  • Wires for connecting the sensor to arduino
  • CAT5 cable
  • Router
  • Laptop

Picture of Connecting the hardware

CODE

/*****************************************************************************
An idea for Future Smart Homes

Oil Monitoring is a project that lets you monitor the ammount of oil
at yourhome. Alerts you with a message on facebook, gmail or even SMS
at your personal phone and more important gives you statistics about
the past. 

* Arduino Uno
* Ethernet shield and ethernet cable | Wireless shield
* UltraSonic Distance Sensor
* Wires for arduino pins

Developed by Tzivaras Vasilis
Last Update: [10-06-2015]
*****************************************************************************/

#define echoPin 7
#define trigPin 8

#include <SPI.h>
#include <Ethernet.h>

// UltraSonic sensor min and max value to be accepted.
int maximumRange = 200;
int minimumRange = 0;

long duration, distance;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
   
   // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void getSensorValue() {
	digitalWrite(trigPin, LOW); 
	delayMicroseconds(2); 

	digitalWrite(trigPin, HIGH);
	delayMicroseconds(10); 

	digitalWrite(trigPin, LOW);
	duration = pulseIn(echoPin, HIGH);

	//Calculate the distance (in cm) based on the speed of sound.
	distance = duration/58.2;
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          
		  getSensorValue();
		  client.print("{\"id\":");
		  client.print("1770,");
		  client.print("\"measurement\":");
		  client.print(distance);
		  client.print("}");
		  
          client.println("<br />");
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

If you refer to this URL, You can make this project easily.

http://www.instructables.com/id/Monitor-Liquid-Level/?ALLSTEPS

Source : http://www.instructables.com/id/Monitor-Liquid-Level/?ALLSTEPS

COMMENTS

Please Login to comment
  Subscribe  
Notify of