Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System

Components and supplies

Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Arduino UNO
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Adafruit Standard LCD - 16x2 White on Blue
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Resistor 4.75k ohm
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
SparkFun Pushbutton switch 12mm
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Single Turn Potentiometer- 10k ohms
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Buzzer
1 LED and 1 Buzzer on same output, take care of mAmp!! The buzzer I use is 8mAmp.
×1
LEDs
1 Green, 1 Yellow and 1 Red LED.
×3
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Resistor 221 ohm
×3
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Breadboard (generic)
×1
Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Jumper wires (generic)
×1

Apps and online services

Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
Arduino IDE

About this project

Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System

This project gives me the info I need about the waterlevel in a watertank. When the level is low, the green LED is ON. When the level is medium, the yellow LED is ON. When the level is HIGH the red LED blinks at same time with buzzer sound. The distance from sensor to waterlevel is measured by the ultrasonic sensor and is printed to the LCD together with the temperature in that tank. This project is a part of a bigger project. The second part will be 6 chasing LEDS mounted in a circle to indicate the pump is pumping. See: https://create.arduino.cc/projecthub/MichDragstar/arduino-uno-or-trinket-pro-5v-6-chasing-leds-with-pot-and-pb-23a1d7 The 3th part will start the pump when level is high and stop the pump when level is low.(under construction) For the real project I use a waterproof ultrasonic sensor, this wil not change the wiring or code. I don't know what happens about the readings when the sensor is wet (humidity), so this project is only to give me information, the 3th project is used for the pump activities and will be done by magnetic contacts.

 #include <LiquidCrystal.h>//Load Liquid Crystal Library
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 6 // Data wire is plugged into pin 6 on the Arduino 
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire);   // Pass our oneWire reference to Dallas Temperature.
LiquidCrystal LCD(12, 11, 5, 4, 3, 2);  //Create Liquid Crystal Object called LCD
int trigPin = 9; //Sensor Trip pin connected to Arduino pin 9
int echoPin = 7; //Sensor Echo pin connected to Arduino pin 7
int myCounter = 0; //declare your variable myCounter and set to 0
float pingTime;  //time for ping to travel from the sensor to the target and return
float targetDistance; //Distance to Target in Centimeters
float speedOfSound = 776.5; //Speed of sound in miles per hour
void setup() {
 Serial.begin(9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 LCD.begin(16, 2); //Tell Arduino to start your 16x2 LCD
 LCD.setCursor(0, 0); //Set LCD cursor to upper left corner, column 0, row 0
 LCD.print("Distance:");  //Print Message on First Row
 sensors.begin();   // Start up the library
 pinMode(8, OUTPUT);  //pin  8, 10, 13 output pins
 pinMode(10, OUTPUT);
 pinMode(13, OUTPUT);
}
void loop() {
 digitalWrite(trigPin, LOW); //Set trigger pin low
 delayMicroseconds(2000); //Let signal settle
 digitalWrite(trigPin, HIGH); //Set trigPin high
 delayMicroseconds(15); //Delay in high state
 digitalWrite(trigPin, LOW); //ping has now been sent
 delayMicroseconds(10); //Delay in high state
 pingTime = pulseIn(echoPin, HIGH);  //pingTime in microceconds
 pingTime = pingTime / 1000000; //convert pingTime to seconds by dividing by 1000000 (microseconds in a second)
 pingTime = pingTime / 3600; //convert pingtime to hours by dividing by 3600 (seconds in an hour)
 targetDistance = speedOfSound * pingTime; //This will be in miles, since we declared the speed of sound as kilometers per hour; although we're going to convert it back to centimeters
 targetDistance = targetDistance / 2; //Remember ping travels to the target and back from the target, so you must divide by 2 for actual target distance.
 targetDistance = targetDistance * 160934.4; //Convert miles to centimeters by multipling by 160934,4
 sensors.requestTemperatures(); // Send the command to get temperature readings
 LCD.setCursor(10, 0); //Set the cursor to the tenth column of the first row
 LCD.print("                "); //Print blanks to clear the row
 LCD.setCursor(10, 0);  //Set Cursor again to the tenth column of the first row
 LCD.print((int) (targetDistance + 0.5)); //Print measured distance
 LCD.print("cm ");  //Print your units
 LCD.setCursor(0, 1); //Set the cursor to the first column of the second row
 LCD.print("                "); //Print blanks to clear the row
 LCD.setCursor(0, 1);  //Set Cursor again to the first column of the second row
 if (targetDistance > 40) {
   LCD.print("LEV LOW  ");
   LCD.print(sensors.getTempCByIndex(0));
   LCD.print((char)223);
   LCD.print ("C");
 }
 else if (targetDistance < 40 && targetDistance > 20) {
   LCD.print("LEV MED  ");
   LCD.print(sensors.getTempCByIndex(0));
   LCD.print((char)223);
   LCD.print ("C");
 }
 else (targetDistance < 20); {
   LCD.print ("LEV HIGH ");
   LCD.print(sensors.getTempCByIndex(0));
   LCD.print((char)223);
   LCD.print ("C");
 }
 delay(2000);
 if (targetDistance > 40) {
   digitalWrite (13, HIGH);  //Green LED ON
 }
 else {
   digitalWrite(13, LOW);   //Green LED OFF
 }
 if (targetDistance < 40 && targetDistance > 20) {
   digitalWrite (8, HIGH);   //Yellow LED ON
 }
 else {
   digitalWrite(8, LOW);    //Yellow LED OFF
 }
 if (targetDistance < 20) {
   digitalWrite(10, HIGH);   //Red LED ON
   delay(2000);
   digitalWrite(10, LOW);   //Red LED OFF
 }
 else {
   digitalWrite(10, LOW);   //Red LED OFF
 }
}

Code

  • Untitled file
Untitled fileC/C++
#include <LiquidCrystal.h>//Load Liquid Crystal Library
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 6 // Data wire is plugged into pin 6 on the Arduino 

OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire);   // Pass our oneWire reference to Dallas Temperature.

LiquidCrystal LCD(12, 11, 5, 4, 3, 2);  //Create Liquid Crystal Object called LCD

int trigPin = 9; //Sensor Trip pin connected to Arduino pin 9
int echoPin = 7; //Sensor Echo pin connected to Arduino pin 7
int myCounter = 0; //declare your variable myCounter and set to 0

float pingTime;  //time for ping to travel from the sensor to the target and return
float targetDistance; //Distance to Target in Centimeters
float speedOfSound = 776.5; //Speed of sound in miles per hour



void setup() {

  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  LCD.begin(16, 2); //Tell Arduino to start your 16x2 LCD
  LCD.setCursor(0, 0); //Set LCD cursor to upper left corner, column 0, row 0
  LCD.print("Distance:");  //Print Message on First Row

  sensors.begin();   // Start up the library

  pinMode(8, OUTPUT);  //pin  8, 10, 13 output pins
  pinMode(10, OUTPUT);
  pinMode(13, OUTPUT);
}
void loop() {


  digitalWrite(trigPin, LOW); //Set trigger pin low
  delayMicroseconds(2000); //Let signal settle
  digitalWrite(trigPin, HIGH); //Set trigPin high
  delayMicroseconds(15); //Delay in high state
  digitalWrite(trigPin, LOW); //ping has now been sent
  delayMicroseconds(10); //Delay in high state

  pingTime = pulseIn(echoPin, HIGH);  //pingTime in microceconds
  pingTime = pingTime / 1000000; //convert pingTime to seconds by dividing by 1000000 (microseconds in a second)
  pingTime = pingTime / 3600; //convert pingtime to hours by dividing by 3600 (seconds in an hour)
  targetDistance = speedOfSound * pingTime; //This will be in miles, since we declared the speed of sound as kilometers per hour; although we're going to convert it back to centimeters
  targetDistance = targetDistance / 2; //Remember ping travels to the target and back from the target, so you must divide by 2 for actual target distance.
  targetDistance = targetDistance * 160934.4; //Convert miles to centimeters by multipling by 160934,4
  sensors.requestTemperatures(); // Send the command to get temperature readings


  LCD.setCursor(10, 0); //Set the cursor to the tenth column of the first row
  LCD.print("                "); //Print blanks to clear the row
  LCD.setCursor(10, 0);  //Set Cursor again to the tenth column of the first row
  LCD.print((int) (targetDistance + 0.5)); //Print measured distance
  LCD.print("cm ");  //Print your units
  LCD.setCursor(0, 1); //Set the cursor to the first column of the second row
  LCD.print("                "); //Print blanks to clear the row
  LCD.setCursor(0, 1);  //Set Cursor again to the first column of the second row


  if (targetDistance > 40) {
    LCD.print("LEV LOW  ");
    LCD.print(sensors.getTempCByIndex(0));
    LCD.print((char)223);
    LCD.print ("C");
  }
  else if (targetDistance < 40 && targetDistance > 20) {
    LCD.print("LEV MED  ");
    LCD.print(sensors.getTempCByIndex(0));
    LCD.print((char)223);
    LCD.print ("C");
    
  }
  else (targetDistance < 20); {
    LCD.print ("LEV HIGH ");
    LCD.print(sensors.getTempCByIndex(0));
    LCD.print((char)223);
    LCD.print ("C");
  }

  delay(2000);


  if (targetDistance > 40) {
    digitalWrite (13, HIGH);  //Green LED ON
  }
  else {
    digitalWrite(13, LOW);   //Green LED OFF
  }

  if (targetDistance < 40 && targetDistance > 20) {
    digitalWrite (8, HIGH);   //Yellow LED ON
  }
  else {
    digitalWrite(8, LOW);    //Yellow LED OFF
  }

  if (targetDistance < 20) {
    digitalWrite(10, HIGH);   //Red LED ON
    delay(2000);
    digitalWrite(10, LOW);   //Red LED OFF
  }

  else {
    digitalWrite(10, LOW);   //Red LED OFF
  }


 }

Schematics

lcd_pot_led_buzz_pb_distsens_temp_EHVdF6S1L7.fzz

Manufacturing process

  1. Integrated QR, RFID, and Temperature Verification Access Control System
  2. Connect Multiple DS18B20 1‑Wire Sensors to a Raspberry Pi for Accurate Temperature Monitoring
  3. Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide
  4. Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
  5. Integrating a Thermocouple Sensor with the Arduino Portenta H7 Using the MAX6675 IC
  6. Multi‑Position Temperature Sensor System for Smart Home Integration
  7. Compact Arduino Radar System with HC‑SR04 Ultrasonic Sensor & 1.8" Display
  8. Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
  9. Arduino Temperature Sensor Project: Read, Convert, and Display Fahrenheit
  10. Portable Arduino-Based Temperature & Humidity Monitor with 16x2 LCD Display