Eventually, I want to tap into the K-line of my Kawasaki Ninja with an (ISO 9141) OBD reader, using an ESP32 WROVER and a L9637 single-wire transceiver. To get there, I'm at the stage of confirming my L9637 chip is wired properly to my ESP32.
Here's where I am:
HardwareSerial Sender(1); // Serial port1 is the 'Sender'
HardwareSerial Receiver(2); // Serial port2 is the 'Receiver'
/*
* LilyGo TTGO T7 v1.5 pins
* ___________
* GND RST | | TXD GND
* N-C VP | ESP32 | RXD 27
* VN 26 | WROVER | 22 25 (22 <- SEND-Rx)
* 35 18 | TTGO | 21 32 (21 -> RCVR-Tx)
* 33 19 | T7 | 27 TDI (27 -> SEND-Tx)
* 34 23 | v1.5 | 25 4 (25 <- RCVR-Rx)
* TMS 5 | | GND 0
* N-C 3v3 | WiFi+BLE | 5v 2
* SD2 TCK | | TDO SD1
* CMD SD3 |______usb__| SD0 CLK
* (back) (+) (-) LiPo Batt Conn
*
* ____________
* 22 <- RX 1 | SENDER | 8 LI
* LO 2 | L9637 | 7 Vs(12v)
* (5v)Vcc 3 | tranceiver | 6 K ->-> K on #2
* 27 -> TX 4 |_____#1_____| 5 Gnd |
* |
* ____________ V
* 25 <- RX 1 | RECEIVER | 8 LI |
* LO 2 | L9637 | 7 Vs(12v) |
* (5v)Vcc 3 | tranceiver | 6 K <-<- K on #1
* 21 -> TX 4 |_____#2_____| 5 Gnd
*
* (need a 510ohm between K and Vs, and a cap to Gnd on each V)
*/
// define Rx and TX on the 2 L9637 chips with K's connected:
// TX is Input for K as output. RX is Output for K as input.
#define Sender_Txd_pin 27 // to Tx on Sender
#define Sender_Rxd_pin 22 // from Rx on Sender L9637
#define Receiver_Txd_pin 21 // to Tx on Receiver L9637
#define Receiver_Rxd_pin 25 // from Rx on Receiver
void setup() {
Serial.begin(115200);
// init both L9637 RX's with a short HIGH-LOW
Serial.println( "init both with Rx HIGH" );
pinMode( Sender_Rxd_pin, OUTPUT );
pinMode( Receiver_Rxd_pin, OUTPUT );
digitalWrite( Sender_Rxd_pin, HIGH );
digitalWrite( Receiver_Rxd_pin, HIGH );
delay(300);
Serial.println( "sending both Rx LOW" );
digitalWrite( Sender_Rxd_pin, LOW );
digitalWrite( Receiver_Rxd_pin, LOW );
delay(25);
Sender.begin(10400, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin); // iso9141 baud rate
Receiver.begin(10400, SERIAL_8N1, Receiver_Txd_pin, Receiver_Rxd_pin);
}
void loop() {
Sender.println( 3 ); // just an integer
delay( 200 );
while (Receiver.available()) {
char RxdChar = Receiver.read();
Serial.print(RxdChar);
}
delay(2000);
}
Note: I've tested the code and the ESP32 serial ports extensively. It works well. I've check the wiring on the (2) L9637 chips, properly powered, 510 ohm resistors, proper capacitors, with their K-lines connected to each other. When I Digital.Write to the Sender L9637 TX, I can see the K respond as well as the Receiver L9637 RX. But when I do the serial write, the Responder.available() never goes true. What gives?
I appreciate any assistance.