Any Update ?
Why it's not a good idea to use two processors ??
With two processors you could be facing power problems (must power-up both at the same time), communication problems and level shifting problems. And two sets of code. A port expander is usually much easier to implement.
You haven't told us why you need to use the one-wire way.
Most ESP32 boards have enough pins to connect a 4x4 keyboard directly.
Leo..
Same Issue => "LESS NUMBER OF PINS"
Suppose I need to connect some 10 or 15 inputs with button press and a key pad with an LCD 16x4 i2c and a seven segment 4 digit display
Then how to go with everything on a single board with less number of pins??
Please give a brief on port expander as I am not familiar with that till now . . .
I assume your LCD has a "backpack", which is an I2C port expander. It connects to the ESP with two data lines, and "expands" it to the multiple inputs of the LCD.
Same can be done with the buttons of a keypad. Eight wires of the keypad go to another port expander, I2C pins connect to the same I2C pins of the LCD backpack.
The LCD and the 16-button keypad now only use two pins of the ESP32.
Lots of examples on how to connect/code a keyboard with I2C port expander on the net.
Leo..
is it something like this
or
Yes, the PCF8574 is one of the many port expanders available.
This seems the goto library.
Leo..
If you want to use D4, just replace A0 with 4
Ya but I didn't find an I2C 4x4 matrix keypad in ready made mode ??
Would you please help !!
OK I am on it right now . . . Le me go through with that !!!
Is it like this ???
OnewireKeypad <Print, 16 > Keypad(Serial, KEYS, 4, 4, 4, 4700, 1000);
No result , nothing there
Would you please allot the code you are working with currently ?
#include <OnewireKeypad.h>
char KEYS[] = {
'1', '2', '3', 'A',
'4', '5', '6', 'B',
'7', '8', '9', 'C',
'*', '0', '#', 'D'
};
OnewireKeypad <Print, 16 > myKeypad(Serial, KEYS, 4, 4, 4, 4700, 1000 );
void setup () {
Serial.begin(115200);
pinMode(13, OUTPUT);
myKeypad.setDebounceTime(50);
myKeypad.showRange();
}
void loop() {
if ( char key = myKeypad.getkey() ) {
Serial.println(key);
digitalWrite(13, key == 'C');
switch (myKeypad.keyState()) {
case PRESSED:
Serial.println("PRESSED");
Serial.println(analogRead(4));
break;
case RELEASED:
Serial.println("RELEASED");
break;
case HELD:
Serial.println("HOLDING");
break;
}
}
}
Ya on pin 4 every key is working but as usual with different results.
I need to buy hardware firstly
Well, by the time would you please help me in solving this one below ??
from this link
I derived this for UNO
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello Boss");
delay(1500);
}
and
for ESPs
#define RXp2 16
#define TXp2 17
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
Serial.println("Message Received: ");
Serial.println(Serial2.readString());
}
Note: :- The second is not getting under the option in message here , don't know why, so please manage !!!
Please guide !!!!!!!!!
Do you get the correct keys when using an UNO or MEGA?
There is no ``` after the first code (before 'and').
Worked OK for me.
It may depend on how your browser copies the text.
I selected the text from the webpage, clicked on <CODE> and did a paste
Arduino Code for URT communication:
// this sample code provided by www.programmingboss.com
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello Boss");
delay(1500);
}
ESP32 Code for URT communication:
// this sample code provided by www.programmingboss.com
#define RXp2 16
#define TXp2 17
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
Serial.println("Message Received: ");
Serial.println(Serial2.readString());
}
Ya done . . Thanks!!
Yes yes I marked that thing ![]()
Now OK for me . . . .
Please guide me in solving the issue in that post !!!
DO NOT connect RX TX as they show on that webpage. You may damage the ESP.