Anda di halaman 1dari 7

Arduino Level trend Recorder

If you have the KS0108 64 * 128 graphics LCD display, an Arduino and a couple of cheap
ultrasonic sonar transducer (HC-SR04) then making a level trend recorder is just a Sunday
afternoon away.
The signal either collected on it's analog pin or digital pin can be plotted beautifully all across the
GLCD (Graphical LCD) screen. With little modification more data can be accommodated on the
Trend Recorder how it works :
Trend recorder is something which plots the historical data on the left and the current data on the
right. However, while the recorder starts then the data line moves from left to right so is time which
moves from left to right. As the trend touches the right extreme point then there is no space remains
on the right so the entire trend line moves little bit to the left and a new point is accommodated on
the right. Once we can master this point, making a trend recorder is just easy.
However, there is one prolific problem with the GLCDs. It has 20 pins to connect. Out of which two
pins are 5 volt and ground connections. Of the remaining 18 pins, minimum 14 pins to be connected
with the digital pins. Thus leaving very few pins of Arduino free for other important works. To
tackle this problem here's one easy way out. Connect the GLCD pins to an Arduino mega or
MCP23017 and then operate the GLCD on I2C bus of Arduino. There is one special library
available for the same. Thanks to the rich library collections of Arduino. So I prefer the MCP23017
MCP23017 (DIL 28 pins) cost of which is barely Rs:100 from has 16 digital GPIO
pins , 14 of which are connected with the GLCD pins (see schematic) while the MCP23017 is
connected to Arduino Uno on I2C bus at analog pin 4 & 5.
Therefore, most of the Arduino pins are set free
now. Our data for trend recorder is taken from one HC-SR04 ultrasonic transducer for which 2
digital pins are used. At the end of this article we will show how with little modification you can put
two or more ultrasonic transducers to get more profile readings and then make average to get one
final reading to plot.
For bulk storage level reading , taking multiple readings and then averaging gives better results.
However, here for all reading we are taking an average of 5 readings taken at a gap of 105 ms.
Upto 4000 millimeter depth HC-SR04 is very accurate to +- 2 mm. Beyond 4500 mm depth the
reading may be inaccurate. The system runs on 5 Volt DC supply.
Control: It's really need less to mention that once the level data is available then throwing some
switches 'on' or 'off' is not really a problem. Just program a few digital switches to be 'on' or 'off'
depending upon the level data at that instance and then connect them to the switching relays or the
Figure-1 shows how for water level reading, it is better to place the probe opposite direction of the
filling line. For the bulk material like coal bunkers, food grain storage it's better to put the probe at
the central circular portion as the filling mostly takes from the periphery side. For bulk material
where the fugitive dusts are created the ultrasonic probe is to have self cleaning air purge line to
clean it by air continuously.

Figure-2: Shows the schematic diagram of the project. The digital temperature sensor DS18B20 is
optional . The ultrasonic probe HC-SR04 is connected on the right. It has 5 volt supply and two
digital pins to connect echo & trigger . For this we have used D3 & D4 respectively.
As the program starts it will ask for interval delay value - at which duration the data will be plotted.
For entering interval value we have used one pot on analog pin A0. From 0 to 1800 seconds interval
can be chosen adjusting the pot. After selecting the value we have used one press-to-on switch on
another analog pin A1 which ,when pressed the interval data will be transferred to the program and
the trend recorder will be start plotting.
At the beginning the trend line will move from left to right and once the trend line touches the
extreme right the entire trend line will be shifted one bit and then redraw from left to right thus
creating just one room for the next incoming point to plot. This puts little memory burden on the
Arduino but it works. On the top line the the hour ,minute and second lapsed will be displayed
along with the level data. After plotting nearly two full screen data (242 points) the screen will reset
and would start from left again. For highest interval of 30 minute this will plot a trend for 121 hours
after which it will reset the data and start over again. However, the time will keep ticking from
inception of the first cycle.
Connection Details:
KS0108 Pins Connected to MCP-23017 Pins



Contrast wiper of 10K Pot



















MCP Pins

Arduino UNO pins





Creating Port Address:

MCP-23017 has three address pins A0, A1, A2, they will be either connected to +5 ve or ground.
For each different combination of connections (all three to be connected) , it will create a port
address of the chip. The most default address is 0x20 where all A0,A1,A2 are connected to ground.
Similarly A0 to +5ve whereas A1 & A2 to ground will create address 0x21 (for more detail see the
data book of MCP-23017). After setting the address the same to be entered in the header file
I2C_graphical_LCD_display.h (see where I've marked as change here for port ). However, I've set
it for the default address as 0x20 for which you need not to do any changes in it.
The code is here:

Level transducers

Schematic drawing:

My Prototype:

GLCD View:

S. Bera