Problem with keypad and sensor

Hy guys i kind of new on the world of arduino, so I have a problem with my project. I try to create smart power meter using power meter module PZEM-004T. While im workin on it, i found a problem to combine the sensor and keypad. The keypad cant show the character on LCD. And also I want to make that to show the parameter we need to input some codes from keypad. For example if i want to show the parameter 'V' on the lcd, I need to pressed 41 on keypad. But i dont how to program that kind of order. I Hope somebody can help me...... Here's my code so far

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <PZEM004T.h>
#include "Keypad.h"

const byte Rows= 4; //number of rows on the keypad i.e. 4
const byte Cols= 4; //number of columns on the keypad i,e, 3
char keys[Rows][Cols]=
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}

byte rowPins[Rows] = {5, 4, 3, 2};
byte colPins[Cols] = {9, 8, 7, 6};

Keypad keypad= Keypad(makeKeymap(keys), rowPins, colPins, Rows, Cols);

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
PZEM004T* pzem;
IPAddress ip(192,168,1,1);

void setup() {
  // put your setup code here, to run once:
 while(!Serial) { }
  while(!Serial3) { }
  pzem = new PZEM004T(&Serial3);
  lcd.init();                      // initialize the lcd 

void loop() {
  // put your main code here, to run repeatedly:
  char key = keypad.getKey();
     if (key)
  float v = pzem->voltage(ip);
  if (v < 0.0) v = 0.0;
  lcd.print("V= ");
  float i = pzem->current(ip);
  if (i < 0.0) i = 0.0;
  lcd.print("A= ");

  float p = pzem->power(ip);
  if (p < 0.0) p = 0.0;
  lcd.print("W= ");

  float e = pzem->energy(ip);
  lcd.print("Wh= ");


The keypad cant show the character on LCD.

Of course it can't. That's the Arduino's job, not the keypad's job.

Can you display ANYTHING on the LCD? If not, how do you know that the LCD is connected correctly?

Print the value obtained from the keypad, too, to make sure that you have it connected correctly.

For example if i want to show the parameter 'V' on the lcd, I need to pressed 41 on keypad.

Why? Do you really plan to have 41 or more values to show?


1. Connect only the Arduino (UNO) and the LCD. Write program to check that any character (0 to F) that you enter from the Keypad appears on the first line of LCD.

2. After that write another program so that when enter the number 1234 from Keypad and only then the L (built-in LED) of UNO becomes ON.

3. In the meantime, you have gathered some experience on Keypad Programming. Now connect your Power Module and do the measurement activities.

4. Post your codes for Step-1 and Step-2.