Go Down

### Topic: Get the LCD signal (Read 1 time)previous topic - next topic

#### WarrenHC ##### Dec 15, 2018, 06:53 amLast Edit: Dec 15, 2018, 10:39 am by WarrenHC
Hello everyone,

I have a pH meter like this one:

and I was trying to do the same thing like this, trying to catch signal from LCD pins:

But the problem is, when I connect the wire to the arduino, my pH meter will going crazy, the value is pretty unstable, seems like some noise effect it.

I was wondering, is anyone could give me some advise? Thanks a lot.

P.S. Sorry for my English.

#### 6v6gt #1
##### Dec 16, 2018, 03:28 pm
From the picture, it appears that the 4 digit LCD has 12 pins which is to be expected for a multiplexed 4 digit display with seven segments for the digits and the decimal point being segment 8. That is, non of the pins are directly connected to a power rail.

1. work out if it is a common cathode or common anode type.
2. which 4 pins switch the digits
3. which 8 pins control the digit segments and the decimal point.

I have not done it myself but, without an oscilloscope, I would probably start with a 10k resistor with one end connected to a power rail and probe each of the 12 pins to see if the effect is on an individual digit or a specific segment on all four digits simultaneously. Then move the resistor to the other power rail and do the same. If you see nothing, maybe try with a smaller value resistor but you increase the risk of damage if its value  is too small.

Once you have understood the pin mappings of the lcd, you can then start working out how to connect it to an Arduino. You may need special value pullup/pulldown resistors on any lcd pins which may float when not active. It looks like it is a 3 volt device so it would be best to use a 3 volt arduino or some sort of level shifting.

This is not a trivial exercise and, depending on the multiplexing frequency, you may need to need to use direct port reads to get the status of the pins quickly enough.

#### WarrenHC #2
##### Dec 18, 2018, 02:19 pmLast Edit: Dec 18, 2018, 02:21 pm by WarrenHC
Hi 6v6gt,

Thanks for your reply, very appreciate, but I think I might let you misunderstand.

I'm already can capture the signal from those pins, and already find out the function of each pin.
Normally, the pH meter will gave me an exactly number, at most 0.2~0.5 floating.
But when I connect the wire between LCD pins to arduino, the pH meter will going crazy, the value will floating between 1~2.

I'm already try to put diode in it, but the voltage drop makes my arduino can't capture any signal. #### 6v6gt #3
##### Dec 18, 2018, 05:18 pm
OK. You have got further than I thought.
You must also connect the Arduino ground to the negative rail of the PH meter. You haven't shown such a connection on your diagram.
Are you using pullup resistors on the 5volt Arduino Uno ? This may present a problem for the 3 volt device you are connecting to if the pins are not 5volt tolerant.

#### WarrenHC #4
##### Dec 20, 2018, 03:03 pmLast Edit: Dec 20, 2018, 03:33 pm by WarrenHC
Hi 6v6gt,

Thanks for your reply again, and sorry for my non rigorous diagram.

I'm not sure about this, "connect the Arduino ground to the negative rail of the PH meter."
Do you mean like this? I tried to connect a diode(1N4007) between the negative rail of the PH meter and Arduino GND, but seems not working.

And I draw a diagram about your second advise, "using pullup resistors on the 5volt Arduino Uno."
Is like this? #### 6v6gt #5
##### Dec 20, 2018, 05:10 pm
OK.
1. The grounds should be directly connected together. That means don't use a diode. The GND pin of the Arduino should be effectively connected to the black wire of your 3 volt power supply.

2. The pullup resistors: No this is not correct. Ideally you would manage with out using pullup resistors. There is a risk that if you do use pull up resistors, that there is an overvoltage on your PH meter pins because the Arduino is 5 volt and the PH meter is 3 volt. (220 Ohms as you have drawn is anyway far too low for a pullup. 10K to 20K is more usual.)

So try with just connecting the grounds together directly and see if you get a stable reading on the PH meter.

#### WarrenHC #6
##### Dec 23, 2018, 02:51 pm
Hi 6v6gt,

I tried the circuit like this diagram below: But unfortunately, it didn't work. I'm really appreciate about your help, thanks a lot.

#### 6v6gt #7
##### Dec 24, 2018, 10:04 am
So it appears that that the Arduino introduces some persistent instability into the PH meter.
Have you got anything else connected to the Arduino which you have not shown and why are you using an external 9v battery or are you not using the USB connection to your PC ?

Anyway:

1. Post the code that you are using.
2. Load a blank sketch into the Arduino and see if this has the same effect on the PH meter. Say just
void setup{}
void loop{}
3  I guess you have colour coded the connections to the LCD display such that the 4 dark blue wires together are the digit drivers and the 8 mixed colour wires are the common segments. Try first with just the digit wires disconnected. Later then just the common segment wires disconnected to see if that makes a difference.
4. You can try operating the Arduino from the 3volt battery pack by connecting its red wire to the 5v pin of the Arduino and black to ground as you already have, but do NOT then connect either the USB cable or the 9 volt battery. The idea is just to see if then the PH meter is stable  but of course you can't then see any reading on the Arduino (no serial monitor) and the battery won't last very long

#### WarrenHC #8
##### Dec 25, 2018, 03:44 pmLast Edit: Dec 25, 2018, 03:56 pm by WarrenHC
Hi 6v6gt,

I have to apologize again, my Arduino is actually powered by USB and like what you said, connect to PC. And there's nothing else connect to the Arduino.

1. Here is my code down below, there's few lines about the 16x2 LCD, but I disconnect already when I first post this article:
2. I tried this suggestion, but still unstable.
3. This suggestion worked, I disconnect the digital wires(Pin 2 to Pin 9), the pH meter became stable; either when I connect it back and disconnect the analog wires(Pin A0 to Pin A3), also got the stable value. But they both have a same problem, I got the faded LCD.
4. This one is amazing, I was so excited about the result from this advice, it works very well. But just like you said, I can't get any data from the pH meter through the Arduino. Is there any suggestion to get over it?

At last, really appreciate and Merry Christmas.

Code: [Select]
`#include <Wire.h>#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);#include <SoftwareSerial.h>#include <Streaming.h>#define DEBUG 1int lcdA = 0, lcdB = 0, lcdC = 0, lcdD = 0;bool lcd1, lcd2, lcd3, lcd4, lcd5, lcd6, lcd7, lcd8;unsigned int  sAn, sBn, sCn, sDn;unsigned int  sA, sB, sC, sD;bool A, B, C, D;float temp = 0.0;//convert the signal to numberint getDigit(int i, int j) {  if ( A[i] &&  A[j] && !B[i] &&  B[j] &&  C[i] &&  C[j] &&  D[i]) return 0;  if (!A[i] && !A[j] && !B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 1;  if (!A[i] &&  A[j] &&  B[i] &&  B[j] &&  C[i] && !C[j] &&  D[i]) return 2;  if (!A[i] &&  A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] &&  D[i]) return 3;  if ( A[i] && !A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 4;  if ( A[i] &&  A[j] &&  B[i] && !B[j] && !C[i] &&  C[j] &&  D[i]) return 5;  if ( A[i] &&  A[j] &&  B[i] && !B[j] &&  C[i] &&  C[j] &&  D[i]) return 6;  if (!A[i] &&  A[j] && !B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 7;  if ( A[i] &&  A[j] &&  B[i] &&  B[j] &&  C[i] &&  C[j] &&  D[i]) return 8;  if ( A[i] &&  A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] &&  D[i]) return 9;  return 0;}void setup() {  Serial.begin(57600);    lcd.begin(16, 2);  lcd.print("pH Value: ");  pinMode(A3, INPUT);  pinMode(A2, INPUT);  pinMode(A1, INPUT);  pinMode(A0, INPUT); }void loop() {  lcdA = analogRead(A3);  lcdB = analogRead(A2);  lcdC = analogRead(A1);  lcdD = analogRead(A0);   sAn = sBn = sCn = sDn = 0;  for (int i = 0; i < 8; i++)  sA[i] = sB[i] = sC[i] = sD[i] = 0;  int i = 0;  //run while Com ports are active  while ( lcdA != 0 || lcdB != 0 || lcdC != 0 || lcdD != 0) {     lcdA = analogRead(A3);    lcdB = analogRead(A2);    lcdC = analogRead(A1);    lcdD = analogRead(A0);        lcd1 = digitalRead(9);    lcd2 = digitalRead(8);    lcd3 = digitalRead(7);    lcd4 = digitalRead(6);    lcd5 = digitalRead(5);    lcd6 = digitalRead(4);    lcd7 = digitalRead(3);    lcd8 = digitalRead(2);    if (lcdA == 0) {      sA += lcd1;      sA += lcd2;      sA += lcd3;      sA += lcd4;      sA += lcd5;      sA += lcd6;      sA += lcd7;      sA += lcd8;      sAn++;    }    if (lcdB == 0) {      sB += lcd1;      sB += lcd2;      sB += lcd3;      sB += lcd4;      sB += lcd5;      sB += lcd6;      sB += lcd7;      sB += lcd8;      sBn++;    }    if (lcdC == 0) {      sC += lcd1;      sC += lcd2;      sC += lcd3;      sC += lcd4;      sC += lcd5;      sC += lcd6;      sC += lcd7;      sC += lcd8;      sCn++;    }    if (lcdD == 0) {      sD += lcd1;      sD += lcd2;      sD += lcd3;      sD += lcd4;      sD += lcd5;      sD += lcd6;      sD += lcd7;      sD += lcd8;      sDn++;    }    i++;         //if (lcdA == 0 && lcdB == 0 && lcdC == 0 && lcdD == 0) {    //if (lcdA == 0 && lcdB == 0 && lcdC == 0 && lcdD == 0 &&     //(sA + sA + sA + sA + sA + sA + sA + sA > 0)) {      for (int i = 0; i < 8; i++) {        A[i] = (1.0 * sA[i] / sAn > 0.5);        B[i] = (1.0 * sB[i] / sBn > 0.5);        C[i] = (1.0 * sC[i] / sCn > 0.5);        D[i] = (1.0 * sD[i] / sDn > 0.5);      }      //Calculate      float value = getDigit(0, 1) * 10       + getDigit(2, 3) * 1      + getDigit(4, 5) * 0.1      + getDigit(6, 7) * 0.01;            lcd.setCursor(10, 0);      lcd.print(value);            if((value != 0) && (value != temp)) {        #if DEBUG        Serial << "A: ";        for (int i = 0; i < 8; i++) Serial << (A[i] ? "1" : "0");        Serial << " - ";        Serial << "B: ";        for (int i = 0; i < 8; i++) Serial << (B[i] ? "1" : "0");        Serial << " - ";        Serial << "C: ";        for (int i = 0; i < 8; i++) Serial << (C[i] ? "1" : "0");        Serial << " - ";        Serial << "D: ";        for (int i = 0; i < 8; i++) Serial << (D[i] ? "1" : "0");        Serial << endl;        #endif        Serial << "Value: " << value <<endl;      }      temp = value;  }  //}}`

#### 6v6gt #9
##### Dec 26, 2018, 12:32 pm
OK. So the symptoms are a (a) a greyed out display and (b) wildly changing values.
The "blank sketch" test (#2) was to eliminate the possibility that any pins were set as output or had their pullup resistors enabled. It still failed so the problem is probably not with your sketch.

That the common 3volt supply test appears to have succeeded indicates that there could be problem related to the impedance of the arduino pins, leakage, noise something etc. That this test #4 succeeded may indicate that one solution is to get a 3.3volt arduino (say Mini 8Mhz 3.3 volt) however, your 16x2 LCD may then not be compatible.

The next test I suggest is this:

5. Disconnect the 3 volt battery pack from the PH meter and power it instead from the 3.3 volt pin (and ground)  from the Uno. Check the behaviour and if it is still unstable, repeat test #3 disconnecting groups of wires. Finally, disconnect all wires to the LCD pins leaving only the power supply wires attached to the PH meter and again check the behaviour.

This should help identify whether the problem is power supply noise, or some other cause.

#### WarrenHC #10
##### Dec 27, 2018, 01:03 pm
Hi 6v6gt,

I was looking for the Arduino Pro Mini(3 volt version) in these days, and it's okay if I have to give up the 16x2 LCD, because I still have other ways to get the value like RS485, right?

And about the suggestion you gave me, let the pH meter working with the 3.3 volt from Arduino Uno.
1. When the Arduino UNO using the power from USB, no matter what I do(disconnect the digital wires or analog wires, or just disconnect every wires), all I got is unstable value.
2. But when I use the 3 volt battery to powered the Arduino(the advise from your last post), everything is fine.

#### WarrenHC #11
##### Jan 08, 2019, 02:58 pm
Hi 6v6gt,

I got my Arduino Pro Mini(3.3 volt with 8MHz) couple of days ago, and as what we expected, it goes well, the pH meter is very stable now.

I'm very appreciate your advises and guides, really thanks a lot.

#### 6v6gt #12
##### Jan 08, 2019, 03:31 pmLast Edit: Jan 08, 2019, 07:47 pm by 6v6gt
I am glad that all went well in the end. Maybe the experience you have documented here will help someone else who is doing the same thing so I'll add a few search tags to the thread:

Digital pH Meter Integration with Arduino
Capture data from device using Arduino to Interface to its LCD display

Go Up