display serial input on LCD Keypad Shield

Hello

I have a DF Robot keypad shield on which I want to display a serial input coming from the TX, RX pins of an Arduino Nano.

The keypad shield is connected to an Arduino Uno. I have tried to connect the incoming TX RX to the A0 and A1 pins of the keypad Shield, but the shield does not displays the values. (I think the shield uses A0 to handle the buttons)

How to display the incoming Serial values on th LCD?
How to connect the Serial Pins?

Thanks for your answers

Here is my code: (based on the serialEvent tutorial)

void loop()
{
  
   lcd.setCursor(0,1);            
   
  if (stringComplete) {
  lcd.print(inputString);

    // clear the string:
    inputString = "";
    stringComplete = false;
}


void serialEvent() {
  while (Serial.available()) {
    
     lcd.setCursor(0,1);     
     
    // get the new byte:
    char inChar = (char)Serial.read(); 
    
    lcd.print("input: ");
    lcd.print(inChar);
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}

Please show us all your code.

GGabor:
The keypad shield is connected to an Arduino Uno. I have tried to connect the incoming TX RX to the A0 and A1 pins of the keypad Shield, but the shield does not displays the values. (I think the shield uses A0 to handle the buttons)

How to display the incoming Serial values on th LCD?
How to connect the Serial Pins?

Why do you connect serial wires to A0 and A1 if you know A0 is already in use ?
(and yes, it is indeed at A0 for that shield)
If you're not going to use the USB/serial then you can use pins 0 and 1 for serial communication.
Lookup your shield at the dfrobot site and have a look at the pins on it.
Depending on the board revision (i guess) you have a lot of pins available on the shield (look like those that are not in use by the shield itself are available in the actual version).
Don't see it as connecting to the LCD keyboard shield, though.
See it as connecting to the Uno through the LCD keyboard shield, because that is what you're actually doing.
Connect RX of the first board, to TX of the second board and vice versa.
And of course don't forget to connect the GND's together.

How well it all will work, will also depend on how fast you're going to write to your LCD (as in how often do you update it).
But that is not your first concern.

MAS3:
Why do you connect serial wires to A0 and A1 if you know A0 is already in use ?
(and yes, it is indeed at A0 for that shield)

Hi!

Thanks for your reply! Yes, A0 is in use, that is my first concern. The examples I found in the tutorial and on the net for serial communication are all use the default TX/ RX pins (which is A0 and A1 for Arduino Uno in this case)

Can you help me how can I use other pins to receive the serial data? For example I've A4 and A5 free on the shield, I would like to use those instead. The data is coming with 19200 bps, that is a good speed for the sender (and for the pressure sensor I'm reading on the sender side)

Thanks

I guess you mean D0 (RX) and D1 (TX) for the hardware serial port otherwise you need to bind the software serial port to the port you want to use. And then there is the Arduino SerialEvent() handling.

Cheers!

BW: This was an interesting problem so I did a quick hack in Cosa to show how the UART and LCD can be bound together; i.e. no code required. This is possible as the UART takes two IOStream::Device as in/out channels. The default is an IOBuffer but it is possible to connect any other implementation of IOStream::Device such as the LCD.

The example sketch shows two major examples; 1) the traditional approach where the loop goes low power and waits for incoming characters on the UART and feeds them to the LCD, 2) declarative approach where the LCD is bound to the UART and that's all.

See the example sketch Cosa/CosaLCDterm.ino at f1155072cfc2a40e6d707c41a998ace35cea205c · mikaelpatel/Cosa · GitHub

Give us a URL to your "DF Robot keypad shield". Maybe we can see something we are missing. You didn't expect me to google it did you?

Thanks, Jack

jackwp:
Give us a URL to your “DF Robot keypad shield”. Maybe we can see something we are missing. You didn’t expect me to google it did you?

Thanks, Jack

Hi

Here is the link:

http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)

Regards,
Gabor

Ok,
so you are using
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
in your sketch, and your LCD keypad shield is working? both displaying and buttons detected?

Hi Gabor.

Tell us some more about what you've tried yet.
What experience do you have, or is this your first project ?
Did you ever use that LCD keypad shield before, or is this your first project with it ?
If i get a new toy, i'll try some very simple examples first with it.

After you've got a display to work (and understand how to do that), you've got a nice debug tool right there.

Your question isn't as clear as you might think it is.
The problem could be how to use the display,
It could be how to get serial data,
It could be how to handle the serial data you just got,
It could be how to convert that serial data to some format that will fit your LCD,
It could be a mismatch in speed the data comes in and has to be displayed (there will be something visible but you can't make anything of it).

I suspect i can see some of these in the code you've posted before.

So it is very important for you to explain exactly where your problem is.
If you post code, post all of it.
So not just "void loop ()".

jackwp:
Ok,
so you are using
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
in your sketch, and your LCD keypad shield is working? both displaying and buttons detected?

Hello Jack

Yes, the keypad shield is working fine with the sample code from its website. It detects the buttons upon pressing them.

Great, then if the LCD Keypad Shield is working, that's half of the system cleared.

Next suspect, the input.
Did you change your serial pins from A0 and A1 to D0 and D1 yet?

MAS3:
Hi Gabor.

Tell us some more about what you’ve tried yet.
What experience do you have, or is this your first project ?
Did you ever use that LCD keypad shield before, or is this your first project with it ?
If i get a new toy, i’ll try some very simple examples first with it.

After you’ve got a display to work (and understand how to do that), you’ve got a nice debug tool right there.

Your question isn’t as clear as you might think it is.
The problem could be how to use the display,
It could be how to get serial data,
It could be how to handle the serial data you just got,
It could be how to convert that serial data to some format that will fit your LCD,
It could be a mismatch in speed the data comes in and has to be displayed (there will be something visible but you can’t make anything of it).

I suspect i can see some of these in the code you’ve posted before.

So it is very important for you to explain exactly where your problem is.
If you post code, post all of it.
So not just “void loop ()”.

Hi!

Thanks for trying to help me. Let me share some more information about what I’m trying to do. The main story is that I want to build an arduino variometer for my RC glider. This is a very challenging project and … even thou I’m very new to the Arduino programming.

The Sener part (air module) is an Arduino Nano connected to an MS5611 pressure sensor. I have a working code mainly from the Varesano.net site. When I plug the module to the USB, it sends the Celsius, Pressure and Altitude to the Arduino IDE Serial Monitor in a string format like 31.2C;980mbar;240M (closed by a new line)

This is the data which I want to send down on a OrangeRX/TX radio link (that is also based on an Arduino) to the “ground unit” (I have to upload a newer firmware to it which has the transparent link functionality). Let’s put the radio link away for now, that is another story , a later stage on this project.

For now:
I have a serial data (ascii string) coming from the “Air unit” RX TX pins. I would like to display this data on the “Ground unit”. The Ground unit is an Arduino Uno connected to the Keypad Display shield. (Later I want change the display modes with the buttons)

Another later stage is to implement a “vario calculation routine” based on the altitude change, and connect a speaker to the Ground unit to beep the Vario. (I have already written a separate beeping routine based on a vario value parameter). So I have a few parts in drafts, now trying to compile them together.

But for now it would be perfect if I connected the “Air module” with wires to the “Ground module” and get the transmitted ASCII string displayed. (The Radio link, the beeping and some fancy features can come later :))

This is a very challenging project for me, my experience is coming from the “official” tutorials and from various articles I found on the net.

Thanks
Gabor

jackwp:
Great, then if the LCD Keypad Shield is working, that's half of the system cleared.

Next suspect, the input.
Did you change your serial pins from A0 and A1 to D0 and D1 yet?

Not yet, I will have more time on the weekend.

Ok, that makes things clear.
You know Arduino's own master Yoda AKA Nick Gammon ?
He has a nice web page (click!) that explains exactly what you want to do, how it can be done and also offers some variants to that.
The newline and semicolons are your friends here.
I think by reading that, you will have an idea on how to handle the incoming data.

You seem to be getting ASCII data in, and that is great for displaying.
But for calculations, you need to convert the ASCII to values.
This can be done, but you'd need to take some things in consideration.
Like the pressure in your example is a 3 number value, but could also be a 4 number value.

Make yourself a list of goals.
Work on these one after another, and combine them into your project after you solved them.
You can divide the goals into sub-goals if you need to.

MAS3:
Ok, that makes things clear.
You know Arduino's own master Yoda AKA Nick Gammon ?
He has a nice web page (click!) that explains exactly what you want to do, how it can be done and also offers some variants to that.
The newline and semicolons are your friends here.
I think by reading that, you will have an idea on how to handle the incoming data.

You seem to be getting ASCII data in, and that is great for displaying.
But for calculations, you need to convert the ASCII to values.
This can be done, but you'd need to take some things in consideration.
Like the pressure in your example is a 3 number value, but could also be a 4 number value.

Make yourself a list of goals.
Work on these one after another, and combine them into your project after you solved them.
You can divide the goals into sub-goals if you need to.

Hi!

Thanks for your link and for your advices! Yes you are right, I need smaller goals:) The first would be to connect the 2 units by wires :slight_smile:

I disconnected the display shield and connected the sender with wires:
TX to D0 and RX to D1 then were trying to dsplay the received data on the serial monitor.
Unfortunately the output is empty :frowning: However the sender works, because when I connect that directly to the PC the data appear on the serial monitor. There is still something wrong with he wiring

Here is the code:

String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete

void setup()
{
Serial.begin(19200);
inputString.reserve(200);
}

void loop()
{
while (Serial.available()) {

char inChar = (char)Serial.read();

Serial.print(inChar);

inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}

if (stringComplete) {
Serial.print(inputString);
inputString = "";
stringComplete = false;
}

}
}

If you need to test the 2 units to communicate, try this.
http://www.instructables.com/id/Test-arduino-to-arduino-serial-using-softwareSeri/#intro
It tests two arduinos connected together, one sending serial, and the other receiving serial (and verifying connection).

jackwp:
If you need to test the 2 units to communicate, try this.
http://www.instructables.com/id/Test-arduino-to-arduino-serial-using-softwareSeri/#intro
It tests two arduinos connected together, one sending serial, and the other receiving serial (and verifying connection).

Thanks very much for the link. By watching the drawing there I just realized that I forgot to connect the grounds to each other. Now the communication works with the above code between the 2 arduinos. My next step would be parsing the received data to float variables and do some calculation.

But now I'm happy to see the communicaton working at last. :stuck_out_tongue: