As a newbie, I thought I would share my first few experiences (I am not an expert by any means).
I bought a particle photon and the carloop ODB-II adapter. I wanted to read from serial, so I also picked up a USB cable. Note that the photon gets power from the ODB port even when the car is off.
I had difficulty using the OSX dev, because of compilation issues. Other folks indicated that an “ignore” file is needed, but I went with the online build platform and that worked best.
On the build site, I created a new project and created two new files: carloop.cpp and TinyGPS.cpp, along with the corresponding headers. Note that the online build would not allow me to use “+” characters after GPS. I then copied the contents of the carloop.cpp/.h and TinyGPS++.cpp/.h from the carloop GitHub.
The main program goes into the “.ino” file (auto-generated with a new project). I used:
// This #include statement was automatically added by the Particle IDE.
#include "TinyGPS.h"
// This #include statement was automatically added by the Particle IDE.
#include "carloop.h"
Carloop<CarloopRevision2> carloop;
void setup() {
carloop.begin();
Serial.begin(9600);
}
void loop() {
//Serial.println("Beginning loop before message read");
carloop.update();
CANMessage message;
while(carloop.can().receive(message))
{
Serial.printf("ID %03x len %d", message.id, message.len);
for(int i = 0; i < message.len; i++) {
Serial.printf("%02x ", message.data[i]);
}
Serial.print("\n");
}
}
Note that “message.length” in the initial carloop example is now “message.len”, according to the particle CANMessage documentation.
After flashing the program onto the photon and plugging into my car, I opened terminal and listened to the USB port at 9600 baud using this command:
$ screen /dev/tty.usbmodem1421 9600
Note that the usb modem number does not stay always consistent across flashes/disconnects.
Every couple of seconds, I received messages like:
ID 17f00010 len 820 10 00 00 00 00 00 00
It does not look like the data payload is printed, which is what I am investigating now!