Ultrasound based Fluid Level Indicator using Arduino

89
Contactless Fluid Level Indicator Abstract \ We are all familiar with sonars, reliable and time-tested technology. They have been used in monitoring sea bottoms, as well as fish and underwater objects for quite a few decades now. The Ultrasonic Level Sensors are the same type of technology, optimized for best operation in air, used as liquid level indicators. The ultrasonic level sensors consists of two essential parts, a transducer (also called sensor) and an electronic control box. Transducer cannot work alone without the control box.The control box can be conveniently placed in a control room or some other location and connected to the transducers via coaxial cables. The transducers are mounted at the top of the tanks, pointing downward to the liquid’s surface. A strong ultrasonic signal burst is then generated by the transducer and propagates through the air down to the liquid’s surface. The ultrasonic signal will not penetrate below the surface of the liquid, it will be reflected back to the transducer. The echo round trip time is then converted to level, which is defined as actual depth of the liquid in the tank. It is important to mention that the measurement is not affected by specific gravity, viscosity or any other characteristic of the liquid being monitored. [Type text] Page 1

description

The project describes Arduino based fluid level indicator and pump control. Students can simply download the report and make the hardware by seeing the section.

Transcript of Ultrasound based Fluid Level Indicator using Arduino

Contactless Fluid Level Indicator

Contactless Fluid Level Indicator

Abstract

\We are all familiar with sonars, reliable and time-tested technology. They have been used in monitoring sea bottoms, as well as fish and underwater objects for quite a few decades now. The Ultrasonic Level Sensors are the same type of technology, optimized for best operation in air, used as liquid level indicators.The ultrasonic level sensors consists of two essential parts, a transducer (also called sensor) and an electronic control box. Transducer cannot work alone without the control box.The control box can be conveniently placed in a control room or some other location and connected to the transducers via coaxial cables. The transducers are mounted at the top of the tanks, pointing downward to the liquids surface.A strong ultrasonic signal burst is then generated by the transducer and propagates through the air down to the liquids surface. The ultrasonic signal will not penetrate below the surface of the liquid, it will be reflected back to the transducer. The echo round trip time is then converted to level, which is defined as actual depth of the liquid in the tank.It is important to mention that the measurement is not affected by specific gravity, viscosity or any other characteristic of the liquid being monitored.

Chapter 1 Introduction

Contactless fluid level measurement is an important aspect. It dependes upon an ultrasound sensor which UV signal. The signal when falls on any surface ( including fluid) it bounces back. Receiver receives the signal and measure the time duration for the traversal. This gives us the distance from time.Fluid level indicator can be used where contact sensors are difficult to implement for instance in drinking water tank, engine fuel tank etc.Contribution of the ProjectTill now Ultrasound sensors were used for collision sensing, obstacle sensing. Even though such signals are reflected from fluid surface, not significant work is carried out in this direction. Therefore In this project we are using the Ultrasound concept for liquid level measurement.

0. History of ultrasonic waves Prior to World War II, sonar, the technique of sending sonic waves through water and observing the returning echoes to characterize submerged objects, inspired early ultrasonic investigators to explore ways to apply the concept to medical diagnosis. In 1929 and 1935, Sokolov studied the use of ultrasonic waves in detecting metal objects. Mulhauser, in 1931, obtained a patent for using ultrasonic waves, using two transducers to detect flaws in solids. Firestone (1940) and Simons (1945) developed pulsed ultrasonic testing using a pulse-echo technique. Shortly after the close of World War II, researchers in Japan began to explore the medical diagnostic capabilities of ultrasonic. The first ultrasonic instruments used an A-mode presentation with blips on an oscilloscope screen. That was followed by a B-mode presentation with a two dimensional, gray scale image. Japan's work in ultrasonic was relatively unknown in the United States and Europe until the 1950s. Researchers then presented their findings on the use of ultrasonic to detect gallstones, breast masses, and tumors to the international medical community. Japan was also the first country to apply Doppler ultrasonic, an application of ultrasonic that detects internal moving objects such as blood coursing through the heart for cardiovascular investigation. Ultrasonic pioneers working in the United States contributed many innovations and important discoveries to the field during the following decades. Researchers learned to use ultrasonic to detect potential cancer and to visualize tumors in living subjects and in excised tissue. Real-time imaging, another significant diagnostic tool for physicians, presented ultrasonic images directly on the system's CRT screen at the time of scanning. The introduction of spectral Doppler and later color Doppler depicted blood flow in various colors to indicate the speed and direction of the flow. The United States also produced the earliest hand held "contact" scanner for clinical use, the second generation of B-mode equipment, and the prototype for the first articulated-arm hand held scanner, with 2-D images. The Non-Destructive Testing NDT has been practiced for many decades, with initial rapid developments in instrumentation spurred by the technological advances that occurred during World War II and the subsequent defense effort. During the earlier days, the primary purpose was the detection of defects. As a part of "safe life" design, it was intended that a structure should not develop macroscopic defects during its life, with the detection of such defects being a cause for removal of the component from service. In response to this need, increasingly sophisticated techniques using ultrasonic, eddy currents, x-rays, dye penetrants, magnetic particles, and other forms of interrogating energy emerged. In the early 1970's, two events occurred which caused a major change in the NDT field. First, improvements in the technology led to the ability to detect small flaws, which caused more parts to be rejected even though the probability of component failure had not changed. However, the discipline of fracture mechanics emerged, which enabled one to predict whether a crack of a given size will fail under a particular load when a material's fracture toughness properties are known. Other laws were developed to predict the growth rate of cracks under cyclic loading (fatigue). With the advent of these tools, it became possible to accept structures containing defects if the sizes of those defects were known. This formed the basis for the new philosophy of damage tolerant design. Components having known defects could continue in service as long as it could be established that those defects would not grow to a critical, failure producing size. A new challenge was thus presented to the nondestructive testing community. Detection was not enough. One needed to also obtain quantitative information about flaw size to serve as an input to fracture mechanics based predictions of remaining life. The need for quantitative information was particularly strongly in the defense and nuclear power industries and led to the emergence of quantitative nondestructive evaluation (QNDE) as a new engineering/research discipline. A number of research programs around the world were started, such as the Center for Nondestructive Evaluation at Iowa State University (growing out of a major research effort at the Rockwell International Science Center); the Electric Power Research Institute in Charlotte, North Carolina; the Fraunhofer Institute for Nondestructive Testing in Saarbrucken, Germany; and the Nondestructive Testing Centre in Harwell, England.[2]0. History of ultrasonic applicationsUltrasonic sensing techniques have earned a pre-eminent position in a variety of fields including medicine, nondestructive testing and process monitoring, geophysics, and sonar surveillance. Ultrasonic flow sensors have been employed for a number of years for performing intraoperative or extracorporeal blood flow measurements. Intraoperative flow measurements are typically conducted to monitor blood flow in various vessels during vascular, cardiac, transplant, plastic and reconstructive surgery. Transit-time ultrasonic flow sensors detect the acoustic propagation time difference between the upstream and downstream ultrasonic transmissions in a moving fluid and process this information to derive a fluid flow rate. Ultrasonic array transducers rely on wave interference for their beam forming effects, and typically include a plurality of individual transducer elements organized as either a one-dimensional (linear) array or a two-dimensional array. Ultrasonic is used as a non-invasive technique for obtaining image information about the structure of an object which is hidden from view, and is widely known as a medical diagnostic tool as well as a tool for non-destructive testing and analysis in the technical arts. Ultrasonic diagnostic imaging systems are in widespread use for performing ultrasonic imaging and measurements. Ultrasonic imaging sensors act as both transmitters and receivers of ultrasonic energy. The sensor first acts as a transmitter; emitting ultrasonic energy in a train of high frequency pulses, typically in the range of 2 to 10 Mhz. Then the transmitter is turned off and the sensor acts as a receiver, which listens for returned echoes at the transmitted frequency. Ultrasonic sensors are used to make remote distance measurements. One particular use of ultrasonic sensors is within a vehicle occupant protection system within a vehicle. Ultrasonic range finders typically use ultrasonic frequencies which are inaudible to the human ear. These high frequencies have inherently shorter wavelengths, which lead to greater positional accuracy than audible frequencies. Parking aid systems of today usually consist of an electronic control unit and several ultrasonic sensors. Each ultrasonic sensor possesses a separate data line, since, in order to improve evaluation, echo information from several ultrasonic sensors is required at a certain instant. Thus, the evaluation of several ULS on the basis of one transmitted sonic wave permits more precise conclusions to be made about the position of and the range of the obstacle. Ultrasonic sensors are equipped in robots and used for detecting objects positioned along a robot travel path. Such ultrasonic sensors are adapted to convert a pulse signal into an ultrasonic wave energy which is, in turn, radiated at a search area.Ultrasonic testing UT has been practiced for many decades. Initial rapid developments in instrumentation spurred by the technological advances from the 1950's continue today. Through the 1980's and continuing through the present, computers have provided technicians with smaller and more rugged instruments with greater capabilities. Thickness gauging is an example application where instruments have been refined make data collection easier and better. Built-in data logging capabilities allow thousands of measurements to be recorded and eliminate the need for a "scribe." Some instruments have the capability to capture waveforms as well as thickness readings. The waveform option allows an operator to view or review the A-scan signal of thickness measurement long after the completion of an inspection. Also, some instruments are capable of modifying the measurement based on the surface conditions of the material. For example, the signal from a pitted or eroded inner surface of a pipe would be treated differently than a smooth surface. This has led to more accurate and repeatable field measurements.Many ultrasonic flaw detectors have a trigonometric function that allows for fast and accurate location determination of flaws when performing shear wave inspections. Cathode ray tubes, for the most part, have been replaced with LED or LCD screens. These screens, in most cases, are extremely easy to view in a wide range of ambient lighting. Bright or low light working conditions encountered by technicians have little effect on the technician's ability to view the screen. Screens can be adjusted for brightness, contrast, and on some instruments even the color of the screen and signal can be selected. Transducers can be programmed with predetermined instrument settings. The operator only has to connect the transducer and the instrument will set variables such as frequency and probe drive. Along with computers, motion control and robotics have contributed to the advancement of ultrasonic inspections. Early on, the advantage of a stationary platform was recognized and used in industry. Computers can be programmed to inspect large, complex shaped components, with one or multiple transducers collecting information. Automated systems typically consisted of an immersion tank, scanning system, and recording system for a printout of the scan. The immersion tank can be replaced with squirter systems, which allows the sonic to be transmitted through a water column. The resultant C-scan provides a plan or top view of the component. Scanning of components is considerably faster than contact hand scanning; the coupling is much more consistent. The scan information is collected by a computer for evaluation, transmission to a customer, and archiving.Today, quantitative theories have been developed to describe the interaction of the interrogating fields with flaws. Models incorporating the results have been integrated with solid model descriptions of real-part geometries to simulate practical inspections. Related tools allow the Nondestructive Evaluation NDE to be considered during the design process on an equal footing with other failure-related engineering disciplines. Quantitative descriptions of NDE performance, such as the probability of detection (POD), have become an integral part of statistical risk assessment. Measurement procedures initially developed for metals have been extended to engineered materials such as composites, where anisotropy and inhomogeneity have become important issues. The rapid advances in digitization and computing capabilities have totally changed the faces of many instruments and the type of algorithms that are used in processing the resulting data. High-resolution imaging systems and multiple measurement modalities for characterizing a flaw have emerged. Interest is increasing not only in detecting, characterizing, and sizing defects, but also in characterizing the materials. Goals range from the determination of fundamental microstructural characteristics such as grain size, porosity, and texture (preferred grain orientation), to material properties related to such failure mechanisms as fatigue, creep, and fracture toughness. As technology continues to advance, applications of ultrasonic also advance. The high-resolution imaging systems in the laboratory today will be tools of the technician tomorrow.0. Future development of this technologyLooking to the future, those in the field of NDE see an exciting new set of opportunities. The defense and nuclear power industries have played a major role in the emergence of NDE. Increasing global competition has led to dramatic changes in product development and business cycles. At the same time, aging infrastructure, from roads to buildings and aircraft, present a new set of measurement and monitoring challenges for engineers as well as technicians. Among the new applications of NDE spawned by these changes is the increased emphasis on the use of NDE to improve the productivity of manufacturing processes. Quantitative nondestructive evaluation (QNDE) both increases the amount of information about failure modes and the speed with which information can be obtained and facilitates the development of in-line measurements for process control. The phrase, "you cannot inspect in quality, you must build it in," exemplifies the industry's focus on avoiding the formation of flaws. Nevertheless, manufacturing flaws will never be completely eliminated and material damage will continue to occurring in-service so continual development of flaw detection and characterization techniques are necessary.Advanced simulation tools that are designed for inspectability and their integration into quantitative strategies for life management will contribute to increase the number and types of engineering applications of NDE. With growth in engineering applications for NDE, there will be a need to expand the knowledge base of technicians performing the evaluations. Advanced simulation tools used in the design for inspectability may be used to provide technical students with a greater understanding of sonic behavior in materials. As globalization continues, companies will seek to develop, with ever increasing frequency, uniform international practices. In the area of NDE, this trend will drive the emphasis on standards, enhanced educational offerings, and simulations that can be communicated electronically. The coming years will be exciting as NDE will continue to emerge as a full-fledged engineering discipline.TriangulationTriangulation is the most commonly used method for distances of 10 meters or less. A laser or LED is used to produce a collimated beam which then impinges on the surface of the target. The target reflects light in many directions, some of the reflected light reaching the detector. The position of the reflected light focused onto the detector depends on the distance between the sensor and target. Detectors such as position sensitive detectors (PSD), diode arrays or CCD arrays enable the reflected light to be detected with high spatial resolution and at high sampling frequencies. The sensor-object distance is calculated trigonometrically and accuracies of better than 0.5% are the norm.Measurement times of less than 10 ms are common, allowing real-time study of moving or vibrating objects. The light source should be compact and should produce an intense, small spot of light with minimal divergence. Amplitude modulation is used in order to eliminate the effects of stray (background) light. Figure: Hand-held laser range meter device. This device works on the same concept of the laser gun device but the difference is that it uses a large beam width of ultrasonic waves as shown in Figure 4.2. The time of flight and triangulation techniques might be used to measure the distance using ultrasonic waves.

Figure Hand-held ultrasonic range meter device.

Chapter 2Working Principle of Ultrasound Sensor

In this chapter we discuss the internal architecture and working principle of the ultrasound sensor.The overall systemThe calculations are done by the following way. First of all, the device calculates the time that the ultrasonic wave took to reach the targeted object and come back to the receiver. Thus, if we need to calculate the time needed for the ultrasonic wave to reach the object from the device, we divide the previous time we had by two. Second, the device multiplies the time by the speed of sound (340 m/s) to get the distance between the device and the object. The time from transmission of the pulse to reception of the echo is the time taken for the sound energy to travel through the air to the object and back again. Since the speed of sound is constant through air, measuring the echo reflection time lets you calculate the distance to the object using this equation:

Distance = (s * t)/2 (in meters) (2.1)

Where: s [m/s] is the speed of sound in air and t [s] is the round trip echo time.

Table 2.1: The delay times of boundary rangeRound trip echo timeDistance

t = 588 us10 cm

t = 17.6 ms3 m

.

Figure 2.1: General block diagram.2.2.1 Calculation of the distance to an object

The hand-held Ultrasonic Range meter device offers precise ranging information from roughly 10cm to 3 meters. The ranger works by transmitting a pulse of sound outside the range of human hearing. This pulse travels at the speed of sound away from the ranger in a cone shape and the sound reflects back to the ranger from any object/target in the path of this sonic wave. The ranger pauses for a brief interval after the sound is transmitted and then awaits the reflected sound in the form of an echo. The controller driving the ranger then requests a ping; the ranger creates the sound pulse, and waits for the return echo. If received, the ranger reports this echo to the controller and the controller can then compute the distance to the object based on the elapsed time.The Pulse Trigger Input line should be held low and then brought high for a minimum of 100sec to initiate the sonic pulse. The pulse is generated on the falling edge of this input trigger. The rangers receiver circuitry is held in a short blanking interval of 600 sec to avoid noise from the initial ping and then it is enabled to listen for the echo. The echo line is low until the receive circuitry is enabled. Once the receive circuitry is enabled, the falling edge of the echo line signals an echo detection or nothing if there is no reflection.

The long-range measurement is difficult a little. To measure the correct distance, the following conditions are necessary.The object must be perpendicular to the range meter.The surface of the object must be flat.There is not object which reflects the ultrasonic around.

Figure 2.2: Theoretical graph of the pulses and its echo-reflection pulse.

2.3 Ultrasonic systemIt consists of a transmitter and receiver pair on the device and a microcontroller with a digital display. There are two different transducers for transmitter and receiver. The transmitter transmits and the receiver waits for the reflected signals. The Figure 2.3 illustrates this system.

Figure 2.3: The overall design of the ultrasonic system.2.3.1 Ultrasonic TransmitterThe transmitter consists of an electronics circuitry and an electromechanical transducer.The electronic circuitry generates the required frequency electrical signal and the electromechanical transducer converts that electrical signal into the physical form and activates the open medium surface. This oscillating physical surface creates the ultrasonic Waves. The oscillating surface creates a pressure variation and ultimately a pressure wave with a frequency equal to that of the surface oscillation. The Figure 2.4 shows the generation of ultrasonic waves.

Figure 2.4: The transmitter circuit design.

The transmitter was designed to oscillate at a resonant frequency of about 40 KHz. The 555 timer generates a 40 KHz sinusoidal ultrasonic wave. The frequency is calculated by using the following formula:

F = 1.44 / 2 * R1 * C = 1.44 / 2 * 12.6 K * 1nF = 46 kHz. (2.1)

This design of the transmitter was done in way to get the closest value to 40 KHz by adjusting the resistor and the capacitor to the values shown in the Figure 2.4.

2.3.1.1 The 555 timer datasheetThe 555 monolithic timing circuits is highly stable controller capable of producing accurate time delays, or oscillation .In the delay time of operation, the time is precisely controlled by one external resistor and capacitor .For a stable operation as an oscillator, the free running frequency and the duty cycle are both accurately controlled with two external resistors and one capacitor. As shown in Figure 2.5:

Figure: The 555 block diagram.The Table 2.2 shows the datasheet of the 555 timer, the parameter rating and the units characterized by each component.

Table 2.2: The datasheet of the 555 timerSymbol Parameter Rating Unit

VCC Supply Voltage+16V

Pd Maximum allowable power dissipation 600mW

TAOperating ambient temperature range0 to 70 C

VTH (Vcc = 5v)Threshold voltage3.33V

VTRIG(Vcc = 5v)Trigger Voltage1.67V

VRESETReset Voltage0.3 to 1.0V

Ultrasonic ReceiverThe receiver also has the same configuration except that it has a receiver electronic circuitry and a transducer, which converts the ultrasonic sound waves into an electrical signal. The sound waves travel into the medium and are reflected by an object in the path of the waves. This reflected wave is then sensed by the receiver, which actually calculates the time of flight of the signal to find the distance. The Figure 2.6 illustrates the receiver circuit.

Figure 2.6: The receiver circuit design.

2.3.2.1 Basis of the operational amplifierThe operational amplifier is the amplifier with the very big voltage gain.In case of TL082 to be using this time, at the specification, the voltage gain becomes 150V/mV. It is the 15 V output in 0.1 mV of the input. To say becomes 150,000 times of gain. In case of the operational amplifier, the value of the voltage gain doesn't have the relation too much. Anyway, the fact that the voltage gain is big is important.

The Difference Gain amplificationThere are positive input and negative input in the operational amplifier.The voltage gain can be calculated by the following formula.

G = Vo/Vi = -(Rf/Ri) (2.2)

Figure: The difference gain amplification.

Using the voltage divider formula:

Vb = V1 * R2/(R1 + R2) (2.3)

The current passing through Ri is the same current passing through Rf because the current entering the negative input is negligible in A (in the ideal operational amplifier, it is considered zero) and this gives the following equation:

(Vi Va) / Ri = (Va Vo) / Rf (2.4) Vo = (V1 * R2 * (Rf + Ri) / (R1 + R2) * Ri) Vi * Rf / Ri (2.5)

Signal amplification circuitThe signal amplification circuit is illustrated below in the Figure 2.8.

Figure The circuit of the signal amplification.

The ultrasonic signal which was received with the reception sensor is amplified by 2500 times (68dB) of voltage with the operational amplifier with two stages. The voltage gain G is 100 times at the first stage (40dB) and 25 times (28dB) at the next stage. Generally, the positive and the negative power supply are used for the operational amplifier. The circuit this time works with the single power supply of +5 V. Therefore, for the positive input of the operational amplifiers, the half of the power supply voltage is applied as the bias voltage and it is made 2.5 V in the central voltage of the amplified alternating current signal. When using the operational amplifier with the negative feedback, the voltage of the positive input terminal and the voltage of the negative input terminal become equal approximately. So, by this bias voltage, the side of the positive and the side of the negative of the alternating current signal can be equally amplified. When not using this bias voltage, the distortion causes the alternating current signal. When the alternating current signal is amplified, this way is used when working the operational amplifier for the two power supply with the single power supply.Using the formula in 2.1:Vi is the input voltage at the ultrasonic transducer.Vo1 is the output voltage of the first amplification stage.Vo2 is the output voltage of the second amplification stage.At minimum distance, d = 10 cm,Vi max = 2.50004 V.Vo1 = (5 * 47K * (100k + 1k) / (47k + 47k) * 1K) - 2.50004 * 100k / 1k = 2.496 V.Vo2 = (5 * 47K * (100k + 3.9k) / (47k + 47k) * 3.9K) - 2.496 * 100k / 3.9k = 2.6 V.

At maximum distance, d = 3 m,Vi max = 2.4999 V.Vo1 = (5 * 47K * (100k + 1k) / (47k + 47k) * 1K) - 2.4999 * 100k / 1k = 2.46 V.Vo2 = (5 * 47K * (100k + 3.9k) / (47k + 47k) * 3.9K) - 2.46 * 100k / 3.9k = 2.50156 V.

Vi = 2.50004 2.4999 = 0.04 mV.A slight change in Vi formed a bigger change in Vo2. Vo2 = Vi * Gain = 0.04 * 2500 = 100 mV.

Data of the TL082 operational amplifierAs for TL082, the two operational amplifiers are enclosed with the one package.

Figure 2.9: Pin connections top view.

Table 2.3: The datasheet of the TL082 operational amplifier.Symbol SymbolValueUnit

Supply VoltageVCCVEE+18-18V

Differential Input VoltageVID30V

Input Voltage RangeVIDR15V

Output Short Circuit DurationtSCContinuous

Power Dissipation(Plastic Package)PD1/8JA68010mWmW/C

Operating Ambient Temperature RageTA0 - +70C

Storage Temperature RangeTstg-65 - +150C

Slew rateSR16V/s

Gain bandwidth productGBW4MHz

The magnitude of the input voltage must not exceed the magnitude of the supply voltage or 15V, whichever is less. The output may be shorted to ground or either supply. Temperature and/or supply voltages must be limited to ensure that power dissipation ratings are not exceeded.For the 741 operational amplifier, GBW = 1 MHz, SR = 0.5 V/s.For the TL082 operational amplifier, GBW = 4 MHz, SR = 16 V/s.Vi(t) = 0.04 cos ( 40000 * 2 * * t) mV.Vo(t) = 100 cos ( 40000 * 2 * * t) mV.(Vo(t)) = 2 * * 40000 * 0.1 = 0.025 V/s.0.025 V/s < 0.5 V/s the 741 operational amplifier could be used.0.025 V/s < 16 V/s the TL082 operational amplifier could be used.The TL082 operational amplifier has a better slew rate.For a 10% error in the frequency, F = 40000 * 0.9 = 36000 Hz.The required gain bandwidth product for a gain = 2500 is,GBW = 36000 * 2500 = 90 MHz > 4 MHz.The signal amplification is split into two stages because of this gain bandwidth product.The maximum gain G max = 4 MHz / 36000 Hz = 111.11.The maximum gain is greater than the gain for the first stage 100 and the second stage 22.

Detection circuitThe detection is done to detect the received ultrasonic signal. It is the half-wave rectification circuit which used the 1N4148 diodes.

Figure The detection circuit.

The DC voltage according to the level of the detection signal is gotten by the capacitor behind the diode. The 1N4148 diode is used because it is a fast switching diode.

Chapter 3Overall Concept of the Project

1. First Display keeps displaying Temperature and keeps waiting for the pump to activate2. When user presses the switch, MC senses the data and triggers the relay. Relay starts the pump. 3. Ultrasound sensor keeps monitoring the water level and when level is filled, gives and alarm and switches off the Relay unit.4. It in turns switches off the pump.5. User now needs to switch off the hardware switch to trigger the system back to initial stage.

The above diagram is the schematic of the project.

Chapter 4Arduino Microcontroller Board

We use Arduino Dueminolova with ATMEG328 Microcontroller in our project. For entire model to drive smoothly, the ground of power supply is made common with arduino ground. Note that digital pins of Arduino produces about 4.2 v which is sufficient to drive LEDs. However it does not produce enough current. Hence without external current, the project runs a risk at draining microcontroller. Therefore alternative supply is used with it.

Arduino is a popular open-source single-board microcontroller, descendant of the open-source Wiring platform, designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open hardware design for the Arduino board with an Atmel AVR processor and on-board input/output support. The software consists of a standard programming language compiler and the boot loader that runs on the board.Arduino hardware is programmed using a Wiring-based language (syntax and libraries), similar to C++ with some simplifications and modifications, and a Processing-based integrated development environment.Current versions can be purchased pre-assembled; hardware design information is available for those who would like to assemble an Arduino by hand. Additionally, variations of the Italian-made Arduinowith varying levels of compatibilityhave been released by third parties; some of them are programmed using the Arduino software.The Arduino project received an honorary mention in the Digital Communities category at the 2006 Prix Ars Electronica.[

HardwareAn Arduino board consists of an 8-bit Atmel AVR microcontroller with complementary components to facilitate programming and incorporation into other circuits. An important aspect of the Arduino is the standard way that connectors are exposed, allowing the CPU board to be connected to a variety of interchangeable add-on modules (known as shields). Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. A handful of other processors have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs such as the LilyPad run at 8 MHz and dispense with the onboard voltage regulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an external programmer.At a conceptual level, when using the Arduino software stack, all boards are programmed over an RS-232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino boards contain a simple inverter circuit to convert between RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB, implemented using USB-to-serial adapter chips such as the FTDI FT232. Some variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools instead of the Arduino IDE, standard AVR ISP programming is used.)The Arduino board exposes most of the microcontroller's I/O pins for use by other circuits. The Diecimila, now superseded by the Duemilanove, for example, provides 14 digital I/O pins, six of which can produce pulse-width modulated signals, and six analog inputs. These pins are on the top of the board, via female 0.1 inch headers. Several plug-in application "shields" are also commercially available.The Arduino Nano, and Arduino-compatible Bare Bones Board and Boarduino boards provide male header pins on the underside of the board to be plugged into solderless breadboards.

Arduino Board ModelsArduinoProcessorVoltageFlashkBEEPROMkBSRAMkBDigital I/Opins...withPWMAnalog inputpinsUSB InterfacetypeDimensionsinchesDimensionsmm

DiecimilaATmega1685V160.511466FTDI2.7in 2.1in68.6mm 53.3mm

Due[11]ATMEL SAM3U2560[12]50541616

DuemilanoveATmega168/328P5V16/320.5/11/21466FTDI2.7in 2.1in68.6mm 53.3mm

UnoATmega328P5V32121466ATmega8U22.7in 2.1in68.6mm 53.3mm

LeonardoAtmega32u45V321214612Atmega32u42.7in 2.1in68.6mm 53.3mm

MegaATmega12805V12848541416FTDI4in 2.1in101.6mm 53.3mm

Mega2560ATmega25605V25648541416ATmega8U24in 2.1in101.6mm 53.3mm

FioATmega328P3.3V32121468None1.6in 1.1in40.6mm 27.9mm

NanoATmega168orATmega3285V16/320.5/11/21468FTDI1.70in 0.73in43mm 18mm

LilyPadATmega168V or ATmega328V2.7-5.5V160.511466None2in 50mm

The board with marked color is used for this project.

Arduino Software

The Arduino IDE is a cross-platform application written in Java, and is derived from the IDE for the Processing programming language and the Wiring project. It is designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling and uploading programs to the board with a single click. There is typically no need to edit makefiles or run programs on a command-line interface. Although building on command-line is possible if required with some third-party tools such as Ino.The Arduino IDE comes with a C/C++ library called "Wiring" (from the project of the same name), which makes many common input/output operations much easier. Arduino programs are written in C/C++, although users only need define two functions to make a runnable program:setup() a function run once at the start of a program that can initialize settingsloop() a function called repeatedly until the board powers offA typical first program for a microcontroller simply blinks a LED on and off. In the Arduino environment, the user might write a program like this:[14]#define LED_PIN 13 void setup () { pinMode (LED_PIN, OUTPUT); // enable pin 13 for digital output} void loop () { digitalWrite (LED_PIN, HIGH); // turn on the LED delay (1000); // wait one second (1000 milliseconds) digitalWrite (LED_PIN, LOW); // turn off the LED delay (1000); // wait one second}For the above code to work correctly, the positive side of the LED must be connected to pin 13 and the negative side of the LED must be connected to ground. The above code would not be seen by a standard C++ compiler as a valid program, so when the user clicks the "Upload to I/O board" button in the IDE, a copy of the code is written to a temporary file with an extra include header at the top and a very simple main() function at the bottom, to make it a valid C++ program.The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs, and uses avrdude to upload programs to the board.For educational purposes there is third party graphical development environment called Minibloq available under a different open source license.

Arduino Duemilanove

OverviewThe Arduino Duemilanove ("2009") is a microcontroller board based on theATmega168orATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16MHzcrystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started."Duemilanove" means 2009 in Italian and is named after the year of its release. The Duemilanove is the latest in a series of USB Arduino boards; for a comparison with previous versions. SummaryMicrocontrollerATmega168

Operating Voltage5V

Input Voltage (recommended)7-12V

Input Voltage (limits)6-20V

Digital I/O Pins14 (of which 6 provide PWM output)

Analog Input Pins6

DC Current per I/O Pin40 mA

DC Current for 3.3V Pin50 mA

Flash Memory16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader

SRAM1 KB (ATmega168) or 2 KB (ATmega328)

EEPROM512 bytes (ATmega168) or 1 KB (ATmega328)

Clock Speed16MHz

PowerThe Arduino Duemilanove can be powered via the USB connection or with an external power supply. The power source is selected automatically.External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.The power pins are as follows: VIN.The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. 5V.The regulated power supply used to power the microcontroller and other components on the board. This can come either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V supply. 3V3.A 3.3 volt supply generated by the on-board FTDI chip. Maximum current draw is 50 mA. GND.Ground pins.MemoryTheATmega168has 16 KB of flash memory for storing code (of which 2 KB is used for the bootloader); theATmega328has 32 KB, (also with 2 KB used for the bootloader). TheATmega168has 1 KB of SRAM and 512 bytes of EEPROM (which can be read and written with theEEPROM library); theATmega328has 2 KB of SRAM and 1 KB of EEPROM.Input and OutputEach of the 14 digital pins on the Duemilanove can be used as an input or output, usingpinMode(),digitalWrite(), anddigitalRead()functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions: Serial: 0 (RX) and 1 (TX).Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the FTDI USB-to-TTL Serial chip. External Interrupts: 2 and 3.These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See theattachInterrupt()function for details. PWM: 3, 5, 6, 9, 10, and 11.Provide 8-bit PWM output with theanalogWrite()function. SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).These pins support SPI communication using theSPI library. LED: 13.There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.The Duemilanove has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and theanalogReference() function. Additionally, some pins have specialized functionality: I2C: analog input pins A4 (SDA) and A5 (SCL).Support I2C (TWI) communication using theWire library.There are a couple of other pins on the board: AREF.Reference voltage for the analog inputs. Used withanalogReference(). Reset.Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.See also themapping between Arduino pins and ATmega168 ports.CommunicationThe Arduino Duemilanove has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. TheATmega168andATmega328provide UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An FTDIFT232RLon the board channels this serial communication over USB and theFTDI drivers(included with the Arduino software) provide a virtual com port to software on the computer. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TXLEDson the board will flash when data is being transmitted via the FTDI chip and USB connection to the computer (but not for serial communication on pins 0 and 1).ASoftwareSerial libraryallows for serial communication on any of the Duemilanove's digital pins.TheATmega168andATmega328also supportI2C(TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of theI2Cbus; see thedocumentationfor details. For SPI communication, use theSPI library.ProgrammingThe Arduino Duemilanove can be programmed with the Arduino software (download). Select "Arduino Diecimila or Duemilanove w/ATmega168" or "Arduino Duemilanove w/ATmega328" from theTools > Boardmenu (according to the microcontroller on your board). TheATmega168orATmega328on the Arduino Duemilanove comes preburned with abootloaderthat allows you to upload new code to it without the use of an external hardware programmer. It communicates using the originalSTK500protocol (reference,C header files).You can also bypass the bootloader and program the microcontroller through the ICSP (In-Circuit Serial Programming) header; seethese instructionsfor details.Automatic (Software) ResetRather then requiring a physical press of the reset button before an upload, the Arduino Duemilanove is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of theFT232RLis connected to the reset line of theATmega168orATmega328via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.This setup has other implications. When the Duemilanove is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Duemilanove. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.The Duemilanove contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; seethis forum threadfor details.USB Overcurrent ProtectionThe Arduino Duemilanove has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed.Physical CharacteristicsThe maximum length and width of the Duemilanove PCB are 2.7 and 2.1 inches respectively, with the USB connector and power jack extending beyond the former dimension. Three screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins.

Pin Configuration

Chapter 5Power Supply

Powe Supply Board

+12v -12v Regulated Power Supply

TransformerThis Dual Power Supply design uses a full wave bridgerectifiercoupled with a centre-tapped transformer. A transformer with a power output rated at at least 7VA should be used. The 7VA rating means that the maximum current which can be delivered without overheating will be around 390mA for the 9V+9V tap; 290mA for the 12V+12V and 230mA for the 15V+15V. If the transformer is rated by output RMS-current then the value should be divided by 1.2 to get the current which can be supplied. For example, in this case a 1A RMS can deliver 1/(1.2) or 830mA.RectifierWe use an epoxy-packaged 4 amp bridge rectifier with at least a peak reverse voltage of 200V. (Note the part numbers of bridge rectifiers are not standardised so the number are different from different manufacturers.) For safety thediodevoltage rating should be at least three to four times that of the transformers secondary voltage. The current rating of the diodes should be twice the maximum load current that will be drawn.Filter CapacitorThe purpose of the filter capacitor is to smooth out the ripple in the rectified AC voltage. Theresidual amount of ripple is determined by the value of the filer capacitor: the larger the value the smaller the ripple.The 2,200uF is a suitable value for all the voltages generated using this project. The other consideration inchoosing the correct capacitor is its voltage rating. The working voltage of the capacitor has to be greater than thepeak output voltage of the rectifier. For an 18V supply the peak output voltage is 1.4 x 18V, or 25V. So we havechosen a 35V rated capacitor.

RegulatorsThe unregulated input voltage must always be higher than the regulators output voltage by at least 3V inorder for it to work. If the input/output voltage difference is greater than 3V then the excess potential must bedissipated as heat. Without a heatsink 3 terminal regulators candissipate about 2 watts. A simple calculation of the voltage differential times the current drawn will give the watts tobe dissipated. Over 2 watts a heatsink must be provided. If not then the regulator will automatically turn off if theinternal temperature reaches 150oC. For safety it is always best to use a small heatsink even if you do not think youwill need one.

StabilityC4 & C5 improve the regulators ability to react to sudden changes in load current and to preventuncontrolled oscillations.DecouplingThe monoblok capacitor C2 & C6 across the output provides high frequency decoupling which keepsthe impedence low at high frequencies.LEDTwo LED's are provided to show when the output regulated power is on-line. You do not have to use theLED's if you do not want to. However, the LED on the negative side of the circuit does provide a minimum load tothe 79xx regulator which we found necessary during testing. The negative 3-pin regulators did not like a zeroloadsituation. We have provided a 470R/0.5Wresistorsas the current limiting resistors for the LED's.Diode ProtectionThese protect mainly against any back emf which may come back into the power supply when itsupplies power to inductive loads. They also provide additional short circuit protection in the case that thepositive output is connected by accident to the negative output. If this happened the usual current limiting shutdownin each regulator may not work as intended. The diodes will short circuit in this case and protect the 2 regulators.

Dual Power Supply Parts List

MC7812 Pinouts

MC7912 Pinouts

PARTS IC1 = 7812 (1) IC2 = 7912 (1) C1, C2 = 2200F/25V elect. (1 each) C3, C4 = 0.33F mylar (1 each) C5, C6 = 100F/25V elect. (1 each) D1-D4 = 1N4001 (4) or W04M bridge diode (1) T1 = 110/220V Input 13.5V - 0V - 13.5V 1.5A output Transformer (1) S1 = ON/OFF Toggle Switch (1)

Chapter 6Control Unit Relay BoardPump runs on 9v supply. MC can't control this. Therefore it needs to control the pump through a relay board. Relays operates at 12v. In order to control it with 5v MC output, it is coupled with MC using an Optocoupler.Relay's one input is given from 9v battery and the other input is grounded. When MC triggers relay, pump is activated

Main Relay unit With Optocoupler

1) Microcontroller Selects a stage of OC of DPDT line selection2) It selects HIGH for the pin that is connected with the OC of the Relay driver3) When OC pin is high, relay is on, it carries the voltage which is at the output stage of DPDT. The same is supplied to motor. Accordingly the motor moves in forward or reverse direction for the period that the OC is high through MCU pin.

Chapter 7Arduino with LCD

With LCD Circuit

LCDs Pin 1 (VSS) is grounded with Digital Ground. Pin 12 or vdd is given from pin 12. Pin 3 of LCD which is intensity control of the display is given from 10k pot output which is connected between +vcc and ground. Lesser the voltage, better the display. So pot needs to be set to high value. Pin 15 and 16 of the LCD is connected with +vcc and ground respectively. These pins control the backlight. If pin 15 of the LCD is disconnected, the LCD will produce display but without back green light.

Pin 11,12,13,14 or the data pins of LCD is connected with Pin 7,6,5 and 4 of the Arduino respectively.

Details of LCDLCDConnectionsMostly anLCDhas a 14 pin connection which are D0-D7 (Data Bits), E (Enable), R/W (Read/Write), RS (Register Select), Vee or Vo (Contrast), Vdd or Vcc (+5V supply), Vss (Ground/Earth connection) so there are 8 data, 3 power and 3 control lines for a standard non-backlightLCD. If anLCDhas a backlight it has additional two lines for that which are 15th (VB+) and 16th(VB- or Ground) lines. Below there is a table of the pin matches and pictures of myLCD's backsides:StandardLCDPin Matches (Character number 0Enable signal

7DB00/1Data pin 0

8DB10/1Data pin 1

9DB20/1Data pin 2

10DB30/1Data pin 3

11DB40/1Data pin 4

12DB50/1Data pin 5

13DB60/1Data pin 6

14DB70/1Data pin 7

If yourLCDhas more than 80 characters (like 4x40)15E21, 1->0Enable signal row 2 & 3

16Not used mostly

HY1602B (Hyper 1602B) with KS0065 controller (compatible with HD44780) and backlight. Click for a bigger picture

1602-04 with KS0066U controller (compatible with HD44780) and backlight Click for a bigger picture

These are 2 different 2x16LCDs as in the pictures the 15th and 16th pins are for backlight as I mentioned above.

Pinout DescriptionsPin 1,2,3According to the table, I call Pin 1(Vss),2(Vdd/Vcc),3(Vee/Vo) power pins because they are the gates to power. Pin 1 is for ground so you have to connect to ground/earth and Pin 2 is for the +5V power supply. 6V or 4,5V is mostly acceptable in few amperes and also 3V is acceptable on some of theLCDmodules (You can also power these modules with a battery in a very economical way). In my application I get the voltage from themolex cableof the pc which is inside the case. And pin 3 is for theLCD's contrast adjustment. I did not but you could use a potentiometer(10K pot will be ok) for changing the contrast of yourLCD. See the schematics belowPin 4,5,6I call Pin4(RS),5(R/W),6(E) the control buddies because these pins are the arms of your controller inside yourLCDmodule. Pin 4(RS) is registration select if this pin is low the data perceived by the data pins taken as commands by theLCDand if this pin is high theLCDcan receive/send 8 or 4 bit character data. I call Pin 5(R/W) clerk because when this pin is low you can write character to theLCD, if the pin is high you can read character data or the status information from theLCD. I didn't make any read operations in my app so I solder this pin to the ground (with soldering this to the ground I made this pin low - "0" see the below circuits). Pin 6(E) which I call the guardian, is used to initiate the actual transfer of commands or character data between theLCDmodule and the data pins.Pin 7,8,9,10,11,12,13,14The eight pins which are DB0-DB7 are the data pins which I call them the workers. The data can be transferred or fetched from theLCDby 8 or 4 bits. Which one is better? This is up to you, by the way if you are using a microcontroller and you have few pins you can use your module in 4 bit mode(by using DB4-DB7). I used 8 bit mode in myLCDbecause I used the parallel port which already have 8 bit data lines. Pin 15,16These two pins are for the backlight of theLCDmodule. 15th pin goes to the power supply(VB+) and 16th pin goes to the ground(VB-). Backlight is very useful in dim environments but someLCDmodules don't have backlights. There are multicoloredLCDs around as well.If your soldering goes well you get a typical test screen of a character basedLCDas its shown below:

LCD OperationsInstructionCodeDescriptionExecution time**

RSR/WDB7DB6DB5DB4DB3DB2DB1DB0

Clear display0000000001Clears display and returns cursor to the home position (address 0).1.64mS

Cursor home000000001*Returns cursor to home position (address 0). Also returns display being shifted to the original position. DDRAM contents remains unchanged.1.64mS

Entry mode set00000001I/DSSets cursor move direction (I/D), specifies to shift the display (S). These operations are performed during data read/write. I/D = 0 --> cursor is in decrement position. I/D = 1 --> cursor is in increment position. S = 0 --> Shift is invisible. S = 1 --> Shift is visible40uS

Display On/Off control0000001DCBSets On/Off of all display (D), cursor On/Off (C) and blink of cursor position character (B). D = 0 --> Display off. D = 1 --> Displan on. C = 0 --> Cursor off. C = 1 --> Cursor on. B = 0 --> Cursor blink off. B = 1 --> Cursor blink on.40uS

Cursor/display shift000001S/CR/L**Sets cursor-move or display-shift (S/C), shift direction (R/L). DDRAM contents remains unchanged. S/C = 0 --> Move cursor. S/C = 1 --> Shift display. R/L = 0 --> Shift left. R/L = 1 --> Shift right40uS

Function set00001DLNF**Sets interface data length (DL), number of display line (N) and character font(F). DL = 0 --> 4 bit interface. DL = 1 --> 8 bit interface. N = 0 --> 1/8 or 1/11 Duty (1 line). N = 1 --> 1/16 Duty (2 lines). F = 0 --> 5x7 dots. F = 1 --> 5x10 dots.40uS

Set CGRAM address0001CGRAM addressSets the CGRAM address. CGRAM data is sent and received after this setting.40uS

Set DDRAM address001DDRAM addressSets the DDRAM address. DDRAM data is sent and received after this setting.40uS

Read busy-flag and address counter01BFCGRAM / DDRAM addressReads Busy-flag (BF) indicating internal operation is being performed and reads CGRAM or DDRAM address counter contents (depending on previous instruction). I used some delay functions in my code which are ThreadSleep if you don't want to use these you can check the Busy Flag and make yourLCDspeedy. BF = 0 --> Can accept instruction. BF = 1 --> Internal operation in progress no additional operation can be accepted.0uS

Write to CGRAM or DDRAM10write dataWrites data to CGRAM or DDRAM.40uS

Read from CGRAM or DDRAM11read dataReads data from CGRAM or DDRAM.40uS

* = Not important, Can be "1" or "0"

Chapter 8Arduino with LM 35

Temperature Sensor LM 35 With Arduino

TheLM35is a common TO-92 temperature sensor. It is often used with the equationtemp = (5.0 * analogRead(tempPin) * 100.0) / 1024;However, this does not yield high resolution. This can easily be avoided, however. TheLM35only produces voltages from 0 to +1V. The ADC uses 5V as the highest possible value. This is wasting 80% of the possible range. If you change aRef to 1.1V, you will get almost the highest resolution possible.The original equation came from taking the reading, finding what percentage of the range (1024) it is, multiplying that by the range itself(aRef, or 5000 mV), and dividing by ten (10 mV per degree Celcius, according to the

datasheet: However, if you use 1.1V as aRef, the equation changes entirely. If you divide 1.1V over 1024, each step up in the analog reading is equal to approximately 0.001074V = 1.0742 mV. If 10mV is equal to 1 degree Celcius, 10 / 1.0742 = ~9.31. So, for every change of 9.31 in the analog reading, there is one degree of temperature change.To change aRef to 1.1V, you use the command "analogReference(INTERNAL);"Here's an example sketch using 1.1 as aRef:

float tempC;int reading;int tempPin = 0;

void setup(){analogReference(INTERNAL);}

void loop(){reading = analogRead(tempPin);tempC = reading / 9.31;}With this sketch, approximately a tenth of a degree resolution is possible. Of course, such small numbers are going to be somewhat inaccurate because aRef will not be exactly 1.1V. Also, theLM35is only guaranteed to be within 0.5 degrees of the actual temperature. However, it does yield higher resolution, if only for appearances' sake.A side note: with aRef at 1.1V, the temperature range of theLM35is limited to 0 to 110 degrees Celcius.CODE

void setup(){ pinMode(13,OUTPUT);

Serial.begin(19200);}

void loop(){ int reading = analogRead(5); // converting that reading to voltage, for 3.3v arduino use 3.3 float voltage = (float)reading * 5.0; voltage /= 1024.0; // print out the voltage //Serial.write(voltage); // now print out the temperature float temperatureC = (voltage ) * 100 +5.0; //converting from 10 mv per degree wit 500 mV offset //to degrees ((volatge - 500mV) times 100)

Serial.println((int)temperatureC); delay(1000);

// now convert to Fahrenheight float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

Serial.println(temperatureF); delay(1000); if(temperatureC>45) digitalWrite(13,HIGH); else digitalWrite(13,LOW); int wind=analogRead(4); Serial.println("WIND="); Serial.println(wind);}

Chapter 9Arduino with Ultrasound Sensor

The above diagram depicts how sensor is connected near the pump pipe to effectively measure the water level.The following diagram explains the schematic and code of distance sensing.Ping Ultrasonic Range FinderThePing)))is an ultrasonic range finder from Parallax. It detects the distance of the closest object in front of the sensor (from 2 cm up to 3m). It works by sending out a burst of ultrasound and listening for the echo when it bounces off of an object. The Arduino board sends a short pulse to trigger the detection, then listens for a pulse on the same pin using thepulseIn()function. The duration of this second pulse is equal to the time taken by the ultrasound to travel to the object and back to the sensor. Using the speed of sound, this time can be converted to distance.Hardware Required Arduino Board (1) Ping Ultrasonic Range Finder hook-up wireCircuitThe 5V pin of the PING))) is connected to the 5V pin on the Arduino, the GND pin is connected to the GND pin, and the SIG (signal) pin is connected to digital pin 7 on the Arduino.

image developed usingFritzing. For more circuit examples, see theFritzing project pageSchematic:click the image to enlarge

Code/* Ping))) Sensor This sketch reads a PING))) ultrasonic rangefinder and returns the distance to the closest object in range. To do this, it sends a pulse to the sensor to initiate a reading, then listens for a pulse to return. The length of the returning pulse is proportional to the distance of the object from the sensor. The circuit: * +V connection of the PING))) attached to +5V * GND connection of the PING))) attached to ground * SIG connection of the PING))) attached to digital pin 7

http://www.arduino.cc/en/Tutorial/Ping created 3 Nov 2008 by David A. Mellis modified 30 Aug 2011 by Tom Igoe This example code is in the public domain.

*/

// this constant won't change. It's the pin number// of the sensor's output:constintpingPin=7;

voidsetup(){// initialize serial communication:Serial.begin(9600);}

voidloop(){// establish variables for duration of the ping,// and the distance result in inches and centimeters:longduration,inches,cm;

// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:pinMode(pingPin,OUTPUT);digitalWrite(pingPin,LOW);delayMicroseconds(2);digitalWrite(pingPin,HIGH);delayMicroseconds(5);digitalWrite(pingPin,LOW);

// The same pin is used to read the signal from the PING))): a HIGH// pulse whose duration is the time (in microseconds) from the sending// of the ping to the reception of its echo off of an object.pinMode(pingPin,INPUT); duration=pulseIn(pingPin,HIGH);

// convert the time into a distance inches=microsecondsToInches(duration); cm=microsecondsToCentimeters(duration);Serial.print(inches);Serial.print("in, ");Serial.print(cm);Serial.print("cm");Serial.println();delay(100);}

longmicrosecondsToInches(longmicroseconds){// According to Parallax's datasheet for the PING))), there are// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per// second). This gives the distance travelled by the ping, outbound// and return, so we divide by 2 to get the distance of the obstacle.// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdfreturnmicroseconds/74/2;}

longmicrosecondsToCentimeters(longmicroseconds){// The speed of sound is 340 m/s or 29 microseconds per centimeter.// The ping travels out and back, so to find the distance of the// object we take half of the distance travelled.returnmicroseconds/29/2;}

The Connection wrt to a bread board is shown bellow.

Chapter 10Advantages and Limitations

AdvantagesThere are no moving parts, nothing to wear out.There is no maintenance, nothing to clean or lubricate. No gaskets or seals to replace.There is no calibration, once the ultrasonic level sensor is installed properly, it will keep on working for some 20+ years (depending on quality of installation), requiring no attention.Transducers are not affected by vapor condensation, or fumes inside the tank. In the past there used to be claims that fumes absorb ultrasonic signal. That is a myth. The problem was caused by insufficient product quality or an improper installation.Measurement is not affected by liquid density, specific gravity, viscosity, etc.Transducers are available in variety of housings to suit the corrosive environments in tanks, typically PVC, Teflon, stainless steel and explosion-proof for hazardous, flammable liquids. We have had a case where a barge transportation firm requested that our stainless steel transducers were plated with 24 karat gold, to offer best corrosion resistance for the fluids they transport.Transducers are hermetically sealed, waterproof, splashing of liquids or immersing in liquid will not cause damage.Ultrasonic level sensors allow multiplexing, where several tanks can be monitored by one control box. This results in significant cost reduction. Another significant advantage and cost saving of multiplexing is that all transducer cables can be placed in the same conduit. Automated Sonix Corporation has two models of this kind. Sonix-1000 can monitor up to seven (7) tanks, UC-4000 monitors up to nine (9). Both control boxes can be placed several hundred feet from the monitored tanks. Level and volume of each monitored tank are shown on one control panel in sequence. Both models have a computer connectible output to save the data in computer. The protocol is RS232C, uses only 2 wires and can transmit up to 2000 feet distance.Disadvantages The poor aiming on the targeted object causes a bad reflection of the laser and that would display a false detection of the objects distance that has been targeted.The atmospheric conditions may affect the ranging capabilities of the hand-held laser range meter device. The rain and snow reflect the laser beam and that may display a false detection of the objects distance. In other term the purity of the water will have a bearing on the accuracy of measurement.Chapter 11Results

Chapter 12ConclusionIn order to design and build a portable device, the weight of the device is a primary problem. The technology of using ultrasonic to measure distances is in continuous progress, features have been added to this technology to make it easy to use and more accurate by assigning more challenging constraints. After discussing and choosing the constraints, the solutions for these sets of challenging problems are to be discussed and solved physically and mathematically. Each solution has its advantages and disadvantages depending on the situation where the device is used; the hand-held laser range meter device is a fast growing technology because of its efficiency and its accuracyIn this project we successfully implemented an Ultrasound based contactless fluid level indicator. The project is incorporated in a closed loop control for controlling water pump.

[Type text]Page 68