You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm trying to get data from mode 22 but with no luck (esp32 with SN65HVD230); mode 01 is working fine.
I tried with standard and no standard address with the same result;
I suppose my can packet initializing is wrong.
If i use another setup (bluetooth terminal with elm327) everything goes fine on mode 22.
Any idea? Thanks
#include <CAN.h>
const bool useStandardAddressing = true;
void setup() {
Serial.begin(9600);
Serial.println("CAN OBD-II engine RPM");
// start the CAN bus at 500 kbps
if (!CAN.begin(500E3)) {
Serial.println("Starting CAN failed!");
while (1);
}
// add filter to only receive the CAN bus ID's we care about
if (useStandardAddressing) {
CAN.filter(0x7e8);
} else {
CAN.filterExtended(0x18daf110);
}
}
void loop() {
if (useStandardAddressing) {
CAN.beginPacket(0x7df, 8);
} else {
CAN.beginExtendedPacket(0x18db33f1, 8);
}
CAN.write(0x02); // number of additional bytes
CAN.write(0x22); // show current data
CAN.write(0x17); // show current data
CAN.write(0x8c);
CAN.endPacket();
// wait for response
while (CAN.parsePacket() == 0);// ||
//CAN.read() < 3 || // correct length
//CAN.read() != 0x41) || // correct mode
//CAN.read() != 0x0c); // correct PID
Serial.println(CAN.read(),HEX);
Serial.println(CAN.read(),HEX);
Serial.println(CAN.read(),HEX);
Serial.println(CAN.read(),HEX);
Serial.println(CAN.read(),HEX);
Serial.println(CAN.read(),HEX);
Serial.println("-----");
delay(2000);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. I'm trying to get data from mode 22 but with no luck (esp32 with SN65HVD230); mode 01 is working fine.
I tried with standard and no standard address with the same result;
I suppose my can packet initializing is wrong.
If i use another setup (bluetooth terminal with elm327) everything goes fine on mode 22.
Any idea? Thanks
Beta Was this translation helpful? Give feedback.
All reactions