i wrote this guide over at bimmerpost:
https://g80.bimmerpost.com/forums/showthread.php?p=29397382gist here is that ESP32 is much much faster than nRF52 chips for CAN + BLE.
i have managed to get quite a list of decoded can bus values:
RPM 100hz
throttle 100hz
gear 50hz
longitudinal acceleration 50 hz
lateral acceleration 50 hz
yaw rate 50 hz
speed 50 hz
wheel speed (for each wheel) 50 hz
battery voltage 10 hz
air temperature 1 hz
steering angle 5 hz
coolant temperature ~5 hz
engine oil temperature ~5 hz
gearbox shift speed (S1,S2,S3) 10 hz
very close to having:
brake pressure front 50 hz
brake pressure rear 50 hz
i have identified the messages, still figuring out the actual units / data range.
missing:
intake temperature
fuel level
note that because of some bluetooth le performance issues, i have temporarily throttled some can frames:
100 hz -> 33 hz (every 3rd message)
50 hz -> 25 hz (every other message)
any messages at 25 hz or less, i deliver them as-is. no throttling.
i wrote my own CAN-bus driver for ESP32 (interrupt based) and i can handle 2500+ messages / second with many many CPU cycles to spare. The bluetooth stack is trash and i am hoping to write my own limited BLE stack with basic advertising and notify/read/write support for RaceChrono, as i am not limited by BLE bandwidth or ESP32 CPU, but the ESP32 BLE drivers (i have tried quite a few)
still have to release my source code on github, but waiting until i get out to the track later this month to give it a proper run before releasing the code.
here is a video of all this working in RaceChrono:
Comments
PS. I'm planning to create a curated list of "RaceChrono DIY" GitHub projects, and your's will fit perfectly once you release the source code and parts list etc. This way people will find inspiration from other people's projects little bit easier.
Have you seen my project on GitHub? Would you be interested in contributing?
https://github.com/timurrrr/RaceChronoDiyBleDevice
I've already started to add ESP32 support, but haven't gone down the rabbit hole of driver stack optimization
Looking forward to see your changes and pull requests!
the reason i wrote my own CAN-bus driver is that, one, most of the stuff out there is some real dumb programming in C/C++. sorry to say something like that, but man some of the most inefficient code i've ever seen, but for most applications that are not latency bound, probably works 99% of the time. two, i didn't care about implementing the entire can-bus protocol. so i optimized the read-only path, short circuiting asap, either at the hardware filter level, or in the interrupt service handler, not copying/reading data unless its a pid i care about.
i would like to do similar for the BLE side, since that suffers from similar problems. and again, i would only implement the very basic stuff needed for racechrono, not try and fix the entire arduino/esp32 BLE stack.
https://github.com/joeroback/racechrono-canbus
so its definitely still a work in progress, but since i am at the point now where i can go to the track with what i got, i figured its good enough to get out there at this point.
@timurrrr Maybe post one of the extra boards to @dirtyfreebooter ? What do you think?
this is my current setup. i don’t have easy access to 12v and ground, so for me, i will be using a 3.7v lipo battery solution, as a ~800 mAh lipo battery lasts all day.
i am going try and make videos for each part (downloading code from github, uploading to ESP32), hoping that it is enough to help someone that isn’t a computer person, but motivated enough to be able to do this themselves.
the can-bus wires where easy to identify for my car, bmw g80, given the twisted pair, and internet forums. identifying a 12v power and ground in that complex wiring harness is much harder and i don’t have access to any wiring diagrams, so its just easier for me to use a solution that is battery powered, then risk messing up that harness or shorting the car in a damaging way.
Nice work @dirtyfreebooter! I decoded many of the same codes for my F82 M4, but alas have not delivered on my intent to document and share.
I do, however have a transformation formulae for front and rear BP that seem to work well enough. I think that was one of the tougher transformations to figure out if I recall.
Front BP: bitsTointLE(raw,40,16)*(-3.2808399)+104986.88
Rear BP: bitsTointLE(raw,16,16)*(-3.2808399)+104986.88
Here’s a short example of them in use: https://youtu.be/phNXwQsBpwc (and yes I have a lot of work to do on car control). Note, while presented on a video overlay is novel and somewhat interesting, I like plotting them against each other to see common places on a track that the rear brake kicks (presumably to correct understeer)—which I see A LOT, BTW, on exit of turn 10b at Road Atlanta
Happy to further collaborate as the G8x and F8x platforms look to be very similar
https://github.com/MagnusThome/RejsaCAN-ESP32