Here is an example on how I build my dongle prototype. Note that this is not fitted in a real dongle case. It’s slightly too big for it and at the moment this my only ESP32 board and I want it removable. Also, I do like the RJ45 connectors (see this post) I use to hook up to the ZOE’s different CAN buses. In a follow up post I’ll show a more neatly “dongle-ized” evolution, with added LEDs, and maybe even able to access that second CANbus without any replugging.
The development board is plugged into two pin headers. When removed it reveals the DC-DC converter set to about 5.5 volt and the CANbus transceiver.
First, there is the CANbus library. While the ESP32 is around for a while now and there is good CAN support in Espressif’s IDF, the support in the Arduino environment is mediocre at best. For instance, the receiving is implemented using proper FreeRtos queues, but sending a frame is totally unbuffered and without any success/failure feedback. Still, it works.
Then there is a simple I/O system that handles communication on basically a character by character basis to and from the Serial-over-USB, Bluetooth and Wifi (basically a socket connection over TCP/IP, and a local access point). While it takes some tinkering to get the WiFi sockets play nicely, all this stuff is very well supported in the ESP32 tool chain for Arduino. A simple command interpreter handles the commands. The language used is called BobDue for historical reasons.
Free frames on the bus are simply received, stored in an array with one element for each ID. When a frame is requested, the latest value is simply pulled from the array. Note that all this traffic is very volatile and it serves no purpose whatsoever to do complex queuing for any other reason than keeping up with the data speed.
ISO-TP frames are decoded and buffered, but only if they match up with the requested ID. Flow control is handled as is message assembly. We don’t support multi-package frame sending yet. Edit: we now fully support long message sending!
The main loop checks if there is a new frame on the queue and if so, having it processed. Then it checks for new characters from the I/O subsystem. Finally it calls a few ticker functions to send out queued ISO-TP frames and other housekeeping tasks, such as aging the free frame array.
The entire source is reasonably commented C code, and can be found on https://gitlab.com/jeroenmeijer/cansee. Just load the source into PlatformIO, select the board, and upload. This is all a work in progress and at this moment your best bet is the development branch. As soon things settle a bit, we will start doing decent releases with pre-compiled binaries attached.
While developing, tons of new ideas are popping up. Will talk about those later.
You might want to have a peek at this “Frankenstein contraption” testing rig. Things have moved on since (more on that in a later post), but this is how projects like this start. Note that I laid it out neatly on my desk. Real life testing is often a lot messier, often smacking all of this, plus a power bank, plus my laptop, plus my phone in my car!
I do all CANbus connections using RJ45 connectors with a specific pin layout. On the breadboard is the ESP32 development board, powered, flashed and debugged through it’s USB cable. I use PlatformIO on top of Atom on Ubuntu, after having recently switched from the Arduino IDE. The dev board is slightly development unfriendly in that it leaves no pin row on one side. Luckily, that side only needs Vcc, so a small green wire pops out under the board.
On the left side is the 3.3 volt CANbus transceiver. powered from the dev board. From here, a short grey cable carries the CANbus. The T in the middle connects the bus components. On the right a short wire to the SAE J1962 plug going to the car, and on the left is my good old GVRET device based on an Arduino Due and the accompanying SavvyCAN desktop software to spy on the bus and see what is going on. This proved invaluable again. At first the wrong bus resistors made the controller refuse sending packets. Later on it confirmed the car computers did fine answering, but there was a bug in the firmware interpreting that.
The silver block is just a connector, but when this is not connected to the car, I can replace it with an identical block with a 60 ohm resistor over the bus terminals to create an independent CANbus-on-my-desk. Note that to test a CANbus device such as the ESP32, you not only need that bus termination resistor, but also at least one other device to set the acknowledge bit of each frame transmitted by your device under test.
We might have ironed out most issues with the DIY dongle. If there are people willing to build an ESP32 based dongle, especially if they own a Q90, R90, or R110 model, we would like to hear about it. Requirements would be:
Preferably drive one of the above models.
Willing and able to build a dongle, which requires ordering stuff through Aliexpress or ebay HK, basic soldering skills, and either some basic knowledge of using PlatformIO with Atom (or VSCode) with git, or the ability to upload binaries to an ESP32 development board from the command line.
Fool around with it, and be willing to cycle quickly though different updates of CanZE or the ESP32 code.
Remember this post? Well today SpeakEV user StinkyPete posted a detailed sequence of events how to trigger it and what firmware version has it fixed. I will repeat here only his short version.
Set the car to pre-condition at a specific time (requiring the car to be plugged in)
Allow the pre-condition cycle to fully complete
Sometime later, use the key fob to initiate a pre-condition
Firmware version of the CLIMA system: 0803 or lower, figured by user Tooney
In this post a general description of the heating system.
The KonnWEI dongles are, though the most stable in terms of what you get when you buy, not the best to run CanZE with, especially when fast performance is required. Think like the Driving, Braking and Consumption screens. For the technically inclined: this is because these type of dongles are designed to query, in their own pace, car computers using the ISO-TP protocol, where we had to misuse them to also intercept the raw, operational data. Most of that data can also be obtained through ISO-TP, but again, it would have been slow and we would have to do a lot of reverse engineering to make that work.
With the availability of cheap ESP32 micro-controllers, that can do CAN, WiFi and Bluetooth, time had come to finally build our own hardware. In the next posts, I will describe the hardware, the software and the testing. For now suffice to say that we have something working over Bluetooth, with an unmodified CanZE instance on Android, for under 20 euros hardware, and it is blazing fast.
For those who want to follow in our footsteps and want to build their own dongle, let me start with a shopping list. Especially useful if you order on AliExpress!
ESP-32 development board. Maybe something like this.
CANbus transceiver board. Needs to be 3.3 volt, so for instance this.
Some sort of housing / SAE J1962 (“OBD2”) connector. My advice would be to buy the cheapest dongle you can get and gut it. You should be able to do that for under 3 euros.
A small 12 to 5 volt converter. While the ESP development board can take 12 volt, that is a maximum and I wouldn’t advice to run it on the car’s 13.5 volt. Example.
Some veroboard, wire, and other generic craft and soldering stuff.
This is a re-post of what I wrote on SpeakEV a few days back.
The battery in my key card had failed. Note that in the “non-keyless” version, the car does not warn you about that. I removed the mechanical key from the key card and put it in the lock. Turning it, the ring arch, acting as a lever snapped off. You can still see the original crack in the picture below. The arch is made from a hard rubbery material and it had obviously weakened over time. Glue was no option. The material is not very suited for it and anyway the levered forces on that tiny surface area would be way too high.
What I decided to do is first glue it with super glue to ensure it’s original shape. Then I used pieces of small black nylon tie rib to reinforce the arch. Using a hairdryer I bent one piece to follow the inside curve (where the key ring pulls), then glued it in with two component resin. I repeated that for the (flat) bottom part, filling up as much cavity space where I could. For extra strength I also put a third strip over the slightly curved top of the arch, diverting even more force from the original crack. I let it harden and then used a power file to grind away excess resin and sharp ends of the strips. Finally, I touched it up with some black permanent marker. I expect the nylon to last forever, the metal key ring will not shave that off soon.
Bottom line is: when using the mechanical key, tread very lightly. Also, do check the integrity of the arch part of your card. If in doubt, you might want to do something about it. I did with SWMBO’s key.
Before we start two things: I made a significant error about ripple current in the previous post, corrected now. Also, we have a lot less data for three phase operation, so this post is more speculative. If you think I made significant errors, please comment. Before going on, I assume you’ve read at least the post Charger Design.
Theory: Consider the following set of graphs, the first one representing the voltage between each of the phase lines (La, Lb, Lc) and Neutral (N).
The output voltage Vdc of a three-phase full-wave rectifier as shown in that post looks like the second graph. Side note: The 0 potential in the upper graph (the N line) is very much not on the same potential as the 0 in the middle graph, which represents the minus output of the rectifier. For a 400 volt line to line system, the average Vdc will be almost 540 volt, peaking 562 and bottoming 487.
Assuming for the moment a simple resistive load on that Vdc, the input current on the wire of phase A Ila will look like the third graph. So there we have it. It looks “somewhat sinusoidal”, but there will be quite a few harmonics in that current. But we can imagine this waveform a bit smoothed out by the filter contraption of the charger.
I have exactly one voltage-current graph of a ZOE charging in 3 phase operation. It is for a Q model on an 11 kW (3 x 16 A) charger, but the battery was already quite full, so it is running on a lower current.
Looks familiar? Some phase shift and smoothing by the filter and that’s it. Just like with the single phase charging, the phase shift is noticeable because of the relatively low charge current. The dips in the middle of the tops are quite noticeable. The current can’t be shaped like the the line voltage simply because in a three-phase full-bridge rectifier, 1/3rd of the time a wire simply can’t provide current. For the remaining 2/3rd, the charger seems to simply follow the voltage curve of the raw DC output, just like it does when running in single phase mode.
A good article about rectifying 3 phases can be found here.
Only slightly related: I received power intake graphs from both a Q210 and an R240 when throttling down. It seems the Q model steps down in roughly 600 Watt steps, while the R model uses smaller 300 Watt steps.
After the startup sequence described in the previous posts it is now time to move on to the actual charging. Again, all the measurements come from SpeakEV user ElectricBeagle and tons of valuable info has come from user arg. If you want to check out the discussion that lead to all of this, here it is.
Let’s set the stage first. We assume single phase charging, the earth check has been performed, the mains has already been connected and, since it’s single phase charging, the relay between N and L3 has already closed. More about that later. Charging has started and as shown in the previous post, the current has ramped up to the desired level. The ramping is gradual, taking about one second.
The rather massive 100 uF capacitor is now creating that 6 A reactive current. It’s sole purpose seems to be to dampen the huge current spikes created by the switch mode power supply. Note that the capacitors are rated for 63 A. The worsening power factor is simply a side effect of that. However, at 16 A, the PF is already above 0.9, so no worries. Bottom line is: at decent currents, say at or above 16 A, the power factor is great and they do clever things with the switching to follow the voltage, see next picture, taken at a current setting of 30 A, with a very small resistor in the N line to measure current without phase shift.
At significantly lower power levels things worsen very quickly. For instance an off grid PV inverter would need to be very potent in coping with that reactive power. But I digress. Because what you really want to know is the effect of the switching. So let’s zoom in on the raggedness of the current curve.
What I wrote here before was way off, as arg argued in private…….An earlier picture suggests that the current coil produces roughly 1 volt peak-to-peak per 4 A wire current (RMS). That suggests a 10 kHz ripple current of just over 200 mA RMS. On a 10 A charge current that is give or take 2%. But this measurement was done with a current coil on the L wire at 16 A, while the previous picture was done with a resistor in N, at 30 A. I suspect the current coil is quite frequency dependent. Going back one picture, one-and-a half-dot ripple on a 26 dot amplitude is roughly 6%. At least ball park same.
Another interesting thing to look at is earth leakage, given the relatively high capacitance between the stator coils and the motor housing. One “blob” is a half-cycle, lasting 10 ms. The pattern is pretty symetrical, with a small (about 6 dots) peak to peak 50 Hz component, and a decent (about 15 dots) 10 Khz signal. The scale is 30mA/div. My rough estimate is that the 50 Hz component is 13 mA RMS and the 10 kHz part a bit above 30 mA RMS. Note that a consumer grade RCD will trip at 30 mA but as arg argued, it should not care too much about the higher frequencies (though old ones may!). All in all the stray capacitance to earth seems to be about 2nF. Note that the leakage current should not go significantly up with power, as it’s a capacitive coupling.
And this is the reason why ZOE sings. Ramping up the frequency further would progressively increase leak current up to the point where dedicated, uncompromised coils would be needed, adding quite a bit of weight if one would want to do 22 or 43 kW rectifying.
All in all I would say: not too bad really! The only thing I am not really sure about is what is meant with HF and EHF frequency in the leak currents the car can report. I always assumed 150 Hz (3rd harmonics) and 10 kHz (the switching frequency), but I am not 100% sure. If anyone knows or suspects more, I’d love to know.
EDIT: by now after more thinking and a few discussions, I am quite convinced HF means the 10 kHz domain and EHF means 10 kHz harmonics.
Oh and about the single phase relay. It can’t close before the chargepoint contactor is closed, because as long as it is open, the car doesn’t know if the chargepoint is single or three phase. However, assuming no contactor in the filter module (and I haven’t found any in the pictures of the filter and charging module), once power is switched on and it is single phase, the capacitor between L3 and N is idle, so it’s no problem to bridge it with a relay at that moment in time.
This is a companion to the previous post. All measurements are done by SpeakEV user ElectricBeagle. They are all done using either a granny cable set to 10 amps or a decent chargepoint set to 30 amps.
Here is the current when plugging in, measured using a current coil on the L wire. It doesn’t show the phase angle but all current is reactive as it’s created by the filter capacitors.The stable, reactive current is about 6A RMS, close to 10A peak. Note that the spike occurs when the reactive current would be about zero, so the actual plug voltage would be at it’s maximum, creating the maximum spike current. It’s roughly 40 amps and lasts about 1 ms. Note charging has not started yet.
Ignore the lower curve. The upper trace is measured using a resistor in the PE wire. You can clearly see the two measurement pulses. They are roughly 20 mA and last 1ms. These are to measure earth resistance; the car injects the measurement current between N and PE. This happens after plugging in but before charging starts.
This is a slow trace of the L current, measured again using the current coil. It shows the spike and reactive current. After about 3 seconds the charger kicks in and does gradual current ramp up to about 13A lead current. That is about 12A real current.