I tried making as simple of a sketch as I could out of the rpm example sketch as seen below. I connected the green wire to GPIO3 (rx) and the white wire to GPIO1 (tx). However, the blue light on the esp32 (pin 2) never came on. I've tried another sketch with mySerial(115200) to see where the code was hanging up at. It appeared as if it couldnt get past obd.init(), and attempted to initialize once every 1min 13sec. I do know that the esp32 is getting power from the freematics adapter. But maybe not a Serial connection? I was worried the serial connections between the freematics unit and the Serial monitor overlapped so I've been trying to get feedback with just the blue light, hence the code below. Could anyone help me figure out the problem here? I'm kinda a noob at the serial stuff, maybe I can verify the wires on the freematics unit are still working with a multimeter somehow?
#include <OBD2UART.h>
COBD obd;
void setup()
{
// we'll use the debug LED as output
pinMode(2, OUTPUT);
// start communication with OBD-II UART adapter
obd.begin();
// initiate OBD-II connection until success
while (!obd.init());
}
void loop()
{
int value;
if (obd.readPID(PID_RPM, value)) {
// RPM is successfully read and its value stored in variable 'value'
// light on LED when RPM exceeds 1000
digitalWrite(2, value > 1000 ? HIGH : LOW);
}
}
stanley wrote: ↑Tue Jan 25, 2022 7:58 pm
Connect Rx and Tx to GPIO 16 and 17. You can change the pins in the library code (OBD2UART.cpp).
I am in a similar situation except I am using the UART Adapter V2 and I have had no luck getting my ESP32 to connect. I have tried connecting the adapter to pins 16 and 17 and it still cannot detect it. I tried changing the ports but it kind of sends the system into shock if I change it. I have tested the adapter with an arduino nano and it works perfectly fine. Any thoughts?