Many moons ago I fitted a set of Dallas DS18B20 temperature sensors in the engine bay as I didn't trust the radiator. I put one in the water hose from the engine to the radiator, another in the hose from the radiator back to the engine. For air temps I put one in the air flow either side of the raditor.
To measure this all, I buried a Raspberry Pi behind the dash and came up with a funky set of three relays so the Pi could shut itself down safely when I killed the power. It never worked very well.
Moving forward I discovered the ESP32. Much more robust, lots of IO, lots of libraries, what's not to love? I puzzled for a while how best to get the data off it and settled on MQTT. This then lead onto a number of different things:-
- I needed to write the firmware for the ESP32
- I needed to write an MQTT broker for Android
- I needed to extend MSDroid to listen to MQTT topics as if it was receiving data from the ECU.
I did all that, but the firmware was always a little ropey in dealing with connections dropping in the frankly electronic abusive environment behnd the dashboard and I kind of forgot about it.
A few weeks ago I thought it would be fun to put the ESPHome.io firmware on it and posted about it on Mastodon. The weak link was always "Where is the MQTT broker?" The orginal f/w assumed it was running on whatever was providing the WiFi DHCP, i.e. the Android phone if it was a hotspot. However, this was awkward if I was working on the car in the garage.
Then, @Slash909uk@mastodon.me.uk suggested a VPN. My initial reaction was "VPN on a microcontroller? Are you mad?" But then they linked to https://esphome.io/components/wireguard.html and I already use WireGuard quite a lot.
It was shockingly simple. The ESP32 attempts to connect to the home Wifi, and then my phone. If either of that works, it then sets up a WG connection to my WG hub that gives it access to my home network regardless of connection. It then connects to my internal MQTT server that Home Assistant listens to.
I went to an Under 17 Car Club event at MoD Lyneham last Sunday, and it was hot. It's about 100 miles from home, and the journey there went smoothly.
The PreRad air temperature sensor dropped out for some reason part way there, but not a major loss.
The Sun beat down all day. We were on a huge airfield with no shade and the temperature was easily over 30C, and the journey home was a bit tougher.
The good news is that the top hose (i.e. engine temperature) was generally a sensible temperature, but there are two dropouts. Those are where the car just died. Both times I was on a dual carrige-way doing circa 70mph, but I managed to safely stop. I let the car sit for a short while, and then it would restart and I could carry on.
After the first time it happened, I plugged in my laptop in so I could log what was going on at the ECU. I caught it dying.
There is a bunch of stuff going on here. The white line is the engine speed, at this point about 2.1k RPM. The yellow line is the air/fuel ratio as measured in the exhaust. Ideally this should be about 14.7. The red line is how long the fuel injectors are open for (in milliseconds). The cyan line is the throttle pedal position.
The engine is slowing down, so I start pressing the accelerator, and in response the ECU lengthens the injector pulse to put more petrol in. However, the AFR measured in the exhaust goes to maximum lean. There is no fuel being injected, and the car is effectively coasting to a stop. The engine is no longer producing power and it's only the momentum of the car that is causing it to turn over.
I suspected the fuel was vapourising in the heat and asked possibly the best engine resource on the internet which suggested it could be the high pressure fuel pump conking out, or vapour pressure in the swirl tank defeating the low pressure fuel pump.
My plan now is to add three more temperature sensors, one on the HP pump, one on the swirl pot and one on the fuel rail. I've also bought a 80psi pressure sensor but I need to figure out how to plumb that in without spraying high pressure petrol in a fine mist around the engine bay.
Oh, I've also tweaked MSDroid so it can authenticate against my MQTT server so I can now see (and log) all this lovely data concurrently with all the data coming out of the ECU.
The beauty of using MQTT is that I can now thow as many sensors as I like into the car, and still blend them in with logs of data from the ECU.