Ultrasonic Sensor senses unlawful entry into premise of water management cyber physical system if installed on boundary of WMCPS.
It also senses the level of water if installed on top of water tank. we shall substract distance of water from height of water tank and find the level of water in tank.
This sensor consists of one or more ultrasonic transmitters (basically speakers), a receiver, and a control circuit.
The transmitters emit a high frequency ultrasonic sound, which bounce off any thing that has higher density than air.
That ultrasonic noise is reflected and detected by the receiver on the sensor.
That return signal is then processed by the control circuit to calculate the time difference between the signal being transmitted and received.
This half of time difference can subsequently be multiplied with speed of sound i.e. 340 m/s, to calculate the distance in m between the sensor and the reflecting object.
def checkdist():
GPIO.output(16,GPIO.HIGH)
time.sleep(0.000015)
GPIO.output(16,GPIO.LOW)
while not GPIO.input(18):
pass
t1 = time.time()
while GPIO.input(18):
pass
t2 = time.time()
return (t2-t1)*340/2
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16,GPIO.OUT,initial=GPIO.LOW)
GPIO.setup(18,GPIO.IN)
time.sleep(2)
The HC-SR04 Ultrasonic sensor for the Raspberry Pi has four pins: ground (GND), Echo Pulse Output (ECHO), Trigger Pulse Input (TRIG), and 5V Supply (Vcc). The sensor output signal (ECHO) on the HC-SR04 is rated at 5V.
A basic ultrasonic sensor consists of one or more ultrasonic transmitters (basically speakers), a receiver, and a control circuit.
The transmitters emit a high frequency ultrasonic sound, which bounce off any nearby solid objects.
Some of that ultrasonic noise is reflected and detected by the receiver on the sensor.
That return signal is then processed by the control circuit to calculate the time difference between the signal being transmitted and received.
This half of time difference can subsequently be multiplied with speed of sound i.e. 340 m/s, to calculate the distance in m between the sensor
and the reflecting object. Sound consists of oscillating waves through a medium (such as air) with the pitch being determined by the closeness of
those waves to each other, defined as the frequency. Only some of the sound spectrum (the range of sound wave frequencies) is audible to the human ear,
defined as the "Acoustic" range. Very low frequency sound below Acoustic is defined as "Infrasound", with high frequency sounds above,
called "Ultrasound". Ultrasonic sensors are designed to sense object proximity or range using ultrasound reflection, similar to radar,
to calculate the time it takes to reflect ultrasound waves between the sensor and a solid object.
Ultrasound is mainly used because it's inaudible to the human ear and is relatively accurate within short distances.
|