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'
/*
* LilyGo TTGO T7 v1.5 pins
* ___________
* GND RST | | TXD GND
* N-C VP | ESP32 | RXD 27 ____________
* VN 26 | WROVER | 22 25 22 <- RX 1 | SENDER | 8 LI
* 35 18 | TTGO | 21 32 LO 2 | L9637 | 7 Vs(12v)
* 33 19 | T7 | 27 TDI (5v)Vcc 3 | transceiver| 6 K ->->
* 34 23 | v1.5 | 25 4 25 -> TX 4 |_____#1_____| 5 Gnd
* TMS 5 | | GND 0 510ohm between K and Vs
* N-C 3v3 | WiFi+BLE | 5v 2 caps to Gnd on each V
* SD2 TCK | | TDO SD1
* CMD SD3 |______usb__| SD0 CLK
* (back) (+) (-) LiPo Batt Conn
*
* Because the L9637 is puts out 5v, and the ESP need 3.3v,
* to the RX, I added a 47k to Gnd, and a 470k to the ESP32.
* It worked.
*/
// define Rx and TX on the L9637 chip, with K probed:
// TX is Input for K as output. RX is Output for K as input.
#define Sender_Txd_pin 25 // to Tx on Sender
#define Sender_Rxd_pin 22 // from Rx on Sender L9637
void setup() {
Serial.begin(115200);
// init L9637 RX with a short HIGH-LOW
Serial.println( "init with Rx HIGH" );
pinMode( Sender_Rxd_pin, OUTPUT );
digitalWrite( Sender_Rxd_pin, HIGH );
delay(300);
Serial.println( "sending Rx LOW" );
digitalWrite( Sender_Rxd_pin, LOW );
delay(25);
Sender.begin(10400, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin); // iso9141 baud rate
}
void loop() {
Sender.println( 3 ); // just an integer
delay(2000);
}
Note: I've tested the code and the ESP32 serial ports extensively. That works well. I've check the wiring on the L9637 chip, properly powered, 510 Ω resistors, proper capacitors, with their K-lines connected to each other. When I Digital.Write
to the sender L9637 TX, should I be able to see the K respond? Sometimes it seems like it does, and sometimes it doesn't. How do I make this robust?