Our LtouchGS product is ideally suited for the industrial environment, where analog signals are to be acquired.
LtouchGS comes standard with two analog inputs, voltage or current, with a resolution of 17 bits.
In this article, we explain the main steps to create an application that detects a tank level and then triggers an alarm and sends it via email.
We must respect the polarity and so we connect the ground of power supply wire to the GND terminal of the Ltouch.
The output wire of sensor must be connected to the current mA terminal of the Ltouch.
Finally, the code for this setup is very simple. The following diagram measures the 0-20mA signals on channel 1, with a resolution of 17 bits, and maps the current over a level range. This mapping will depend on the transmitter, the example below maps from 0 mA to 0 cm and from 20 mA to 100 cm.
You can use the library BMTouch to configure and read the values in to android studio.
To configure the sampling frequency directly write the value of the frequency and scale through the library subito dopo protected void onCreate :
BMTouch.ADC_set_scale((byte) 0, (byte) 0, 1); BMTouch.ADC_set_frequency((byte) 0, 15);
Now we can call the library function to read the analog value through a single call or by creating a TimerTask that executes this cyclically, you can see on this video how to do it.
ch1_val = BMTouch.ADC_read_channel((byte) 0, (byte)0);
ich1_val returns the value read from 0 to 32768, it is up to us to know that 32768 is hight 100 cm, so we can make a portion and find the quantity of the tank.
To send an email at a minimum or maximum threshold, we can watch this video that explains in detail how to send an email through gmail.
that’s all, if you have any doubts or requests, contact us by email.