PNKP237 / EHU32

ESP32-based bluetooth audio integration for Opel/Vauxhall vehicles. Control bluetooth audio source with steering wheel buttons, show coolant temperature and battery voltage on the integrated display and more!
The Unlicense
17 stars 3 forks source link

Additional information without electric climate #3

Open Vortecsz opened 6 months ago

Vortecsz commented 6 months ago

Hello, would be possible to display coolant, speed, rpm and voltage without the Electronic climate? I know how to activate the electronic climate tab in the bottom but I don't have the automatic climate so this is useless for me. Would be possible to show maybe the coolant and battery in the first page of the screen without auto climate? If not why? The data are pulled from the ECC or is something related to the print on the display? If the problem is the ECC I could search for the different address of the data's in the can line? If the problem is the print why I couldn't print in the first page? Thank you so much for the work!

PNKP237 commented 6 months ago

Battery is out of the question for now, I haven't been able to come up with a way to read battery voltage from MS-CAN other than through ECC. As for coolant temp and vehicle speed, it is possible to read it using measurement blocks from the display (but then there's no RPMs nor voltage). I'll try to implement that in the next version (it will try reading reduced data from display if there is no response from ECC) - I guess you can expect the new version in one or two weeks, still optimizing and testing stuff. As for why - it uses the same protocol that OPCOM or Tech2 use for reading measurement data and only ECC offers coolant temp, speed, rpms and voltage combined. If these tools can't access more data from display or radio neither can we.

Haven't had much luck with sniffing the coolant, rpm and speed data like it was defined HERE. In my case (Z16XER) I was reading total garbage, but once I get reading basic data from the display done I'll try again with these.

Vortecsz commented 6 months ago

Love to hear that, it would be possible to display like the coolant in the first page? I would like to have the coolant temperature in the main page without need to swap page everytime

PNKP237 commented 6 months ago

First page as in the mode where song data is shown? I guess I can make it like this but it would require me to rewrite a lot of current logic. I would much rather show the coolant temp in a "notification box" that sometimes appears in the top right corner of GID/CID, able to be toggled on or off. Do you think that would work for you?

Vortecsz commented 6 months ago

fYpTDQNOJ2mItZ7v That's my current setup, in the top the current media, like aux etc in the bottom consumption etc, my main goal would be to add like coolant in the top right, but if is it hard, I would understand maybe one day I will understand how to program that haha. The notification box would be also not bad at all. Btw if you need to change the gid firmware you can with a Little EEPROM writer, is pretty easy to do. I don't know if you can modify the firmware maybe I can give you some files to look at if you need

PNKP237 commented 6 months ago

Alright, you have a single line GID so writing the coolant info to the album or artist fields won't work because you won't see them anyway. I had the single line version as well but I enabled UHP just to make it display all the three lines of text. The notification box will work fine but it will obstruct the top right part of the display.

As for GID firmware, EEPROM only holds basic data such as settings and carpass (if paired with the radio). and the GID firmware itself is held inside this TSOP flash package I think, difficult to read that data without a TSOP adapter. Don't feel the need to modify the GID firmware anyway, I'd like this project to work plug-and-play with no modification to the rest of the system

IMG_20240402_180641

Vortecsz commented 6 months ago

Oh okay, would be possible to print in the top right with the single line gid? Or just you can't because u need to overwrite an existing text? Like artist aux etc. Btw with the the EEPROM firmware you can change different version 3 line version, single etc, but if you don't want to modify any firmware that's pretty useless. I don't know if you know but a Russian guy seel an obd device probably something similar to your setup, that can show DPF status etc, in the gid, that's only an idea for the project, I don't need DPF status etc. My main focus is to see the coolant temperature and maybe battery in the main page as stock as possible. Because Opel decided to not add any temperature gauge in the cluster... Thank you for the help.

https://www.pepas.cz/projekty/opel-mkj-cz/

PNKP237 commented 6 months ago

Yes the notification box can be displayed even with single line GID. As I have already stated in the other issue there is no way to read DPF status from MS-CAN and that's the only CAN bus I'm going to support in this project, mainly because ESP32 only has a single CAN peripheral. Otherwise I would need additional hardware to be able request DPF measurement blocks from ECU through HS-CAN. I recently learned that such module exists but making menu interfaces is not something I would like to focus on at this time even though I have already reverse engineered how the menu can be created. The problem is that if this is put in a vehicle equipped with UHP it could cause problems because that module "fakes" being an UHP interface menu

PNKP237 commented 6 months ago

Nevermind, the notification box does not show up when the main audio page is displayed. I guess I'll try to fit coolant info on the right of the middle line or find another way to display notifications I'm surprised you prefer the single line version though

Vortecsz commented 6 months ago

Oh okay, I prefer the single line because I watch a lot the consumption and the autonomy of the car so I would need to swap page every time. The first page of the three line only display audio information and I only use aux so I would see only aux and nothing more. I prefer to see the consumption

PNKP237 commented 6 months ago

The display is not very good at handling longer strings and as a result the coolant temp is printed on top of the title text. Sometimes it's ignored and not printed at all, for very long song titles

image001 image002 image004

I don't know if I should go ahead with this, the result is kinda bad

Vortecsz commented 6 months ago

You are right, that's not good at all for posting it, I don't know if you can put the string down the song or you can just write in the line of artist/song name. Btw can you give me the code? I can use the coolant on the right of the AUX string? Because I just use aux so is not a problem for me and thank you for all the help and the amazing work you are putting in the project.

PNKP237 commented 6 months ago

You can't "add" anything to the AUX string sent by the radio, you can only overwrite it. I built this test version on top of EHU32 which is still not ready for release, but once it's finished I'll give you the code with this functionality added, with a way to customize the text displayed to your liking

Tomi8609 commented 6 months ago

I will keep an eye on this part of the project!

PNKP237 commented 6 months ago

Just pushed v0.9, added an additional mode (accessible by long pressing "3") for displaying just the coolant temp in a single line, looking like so: IMG_20240506_215940_1

You can change whatever is written there by modifying line 157 in CAN.ino. If you want the text to be aligned to the right, you can also change lines 110, 111 and 112 in TextHandler.ino to reference "DIS_rightadjusted" rather than "DIS_leftadjusted". There is also a "DIS_centered" option which should be self-explanatory.

Vortecsz commented 6 months ago

That's beautiful thank you so much for the work! Currently waiting for the esp and the modules to arrive to get it working.

Wop57 commented 6 months ago

There is an example for showing information in the electronic climate tab. It is in the issue #3 in the Car-CAN-Message-DB of JJToB. Here is the link: https://github.com/JJToB/Car-CAN-Message-DB/issues/3

PNKP237 commented 6 months ago

There is an example for showing information in the electronic climate tab. It is in the issue #3 in the Car-CAN-Message-DB of JJToB. Here is the link: JJToB/Car-CAN-Message-DB#3

Thanks, never noticed that one. Even though I have considered showing the temperatures there it still does not solve the underlying issue - if the car does not have ECC (or at least not enabled in Display Variant Programming, changing which requires opcom, which kinda defeats the "as cheap and easy as possible" approach) then we can't utilize that field.

Already tested with UHP but it does not send any notification boxes, only menu-like screens. I'll do some additional research to see if I can simulate Navi notifications, but that has to wait since I'm super busy with other things. Also I need to get the CD ROM drive back into my Navi since it refuses to display anything without the drive mechanism.

Vortecsz commented 6 months ago

Hello is possible to change the pinout with this board? CP2102 Type-C 38P

image

PNKP237 commented 6 months ago

I don't exactly understand what do you mean by "change the pinout", please elaborate. Is it just changing the pins, as in you'd prefer the CAN TX/RX or I2S on different pins than provided in my example?

Defining CAN RX TX pins is done here: twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(_TX_PIN, _RX_PIN, TWAI_MODE_NORMAL);

If you want to redefine I2S output pins, here is how to do it.

Vortecsz commented 6 months ago

Oh yes sorry, I searched for the defaults pin out of can Rx tx and i2s, example for can Rx and tx io4 and io5 wired them up in my esp board but isn't working at all. Maybe is the board? And I need to define manually the gpio? I find that the default pins are the same for the 38 pins board and the 30 pins board so I don't know why isn't working

Vortecsz commented 6 months ago

After reflashing the esp every time I connect the board to the car the aux text go away and the current date is displayed is like the radio doesn't work because the buttons don't do nothing but I can hear the sound from the speaker so the radio is on. If I remove the esp everything work as usual

PNKP237 commented 6 months ago

Curious. I do most development on a setup like yours (GID and I assume CD30MP3) and never had the radio stop responding. What model year is your vehicle?

Vortecsz commented 6 months ago

I don't have the cd30 mp3 I have the cd40 USB btw the car is a Corsa d from 2013. if I inject 5v with the USB c the radio crash but I if inject 5v directly to the board the radio doesn't crash but if I long press button 1 nothing happen. Using Ms can from obd pin 3 and 11. I disconnected the i2c just for the testing and the problem persist. I will try with another board as soon as it arrives, can you confirm that without the i2s interface the mode "coolant mode" with button 1, or that the esp enables Bluetooth

PNKP237 commented 6 months ago

i2s is just an output and if you leave it not connected it does not matter to the ESP32 at all (it doesn't receive any data from PCM5102). Also please use a 12V to 5V USB car charger and not the CD40's USB port for power. If you have any electrolytic capacitors on hand you can also solder it to the ESP32 board just to make sure it is not dirty power.

EHU32 will enable bluetooth and start sending stuff to the screen after it notices that the radio has sent some text to the display, it starts with the "1" mode active (audio metadata). You don't have to connect to switch to the "3" mode (1-line coolant info).

If you can, please download version 0.7 from releases and try connecting your phone and playing something to see if the audio title is displayed at all. Of course it won't have the "3" mode and "2" won't work but I would like to see if the "radio message blocking" feature is the problem here (v0.7 is the last version without it).

Vortecsz commented 6 months ago

Okay, my problem is the 5v and grounds using a car charger with USB port. Gonna try others configuration. Anyway mode 1 work with song names, mode 2 show coolant hope I'm correct, mode 3 show speed and rpm, the rpm and speed are wrong when I'm idle at 800 it shows 3000 same for the speed I'm going 90kmh and it shows 45. Mode 2 coolant is partially wrong if I long press settings and after bc I can access the secret menu of the gid and I can see the little difference between the two coolant value, your is a bit high like 3/4 °c. The audio quality sucks, but that's my problem with the connection, I would love to see you PCB design did you manage to get that done?

Btw if I connect the pcm5102 with vin and ground from esp the can interface crash and the radio also crash, I still didn't understand why

PNKP237 commented 6 months ago

It's the other way around, mode 2 should show speed and RPMs and if there is no ECC detected it will try to pull that data from CAN but as I said earlier in my vehicle I would read random values so I haven't had much luck testing that. I guess I'll remove that option from next version since it doesn't work that well - I'll make it only show speed that's read from the display.

I think that the ground of the audio input in CD40 might be either floating or coupled with caps to ground, I'd suggest to measure with a multimeter between the audio input ground and vehicles ground to see if there is any voltage there. If there is then one fix would be to either modify the radio or buy some kind of an audio separation transformer.

Thanks for the feedback, I'll correct the speed display (just multiply it by 2 I guess?) when I have some free time next week to possibly test it within my vehicle. As for coolant I'd say it's the GID that's lying since these cars notoriously run hot. As for the PCB... I'll get around to finish it one day but I've got a lot of things going on right now.

Vortecsz commented 6 months ago

Okay I resolved all the problem with the connections, the problem is that the audio quality sucks really bad. I don't know why the power is from a car charger with a USB cable, not from the radio. It's connected with an aux cable to the radio the aux female input is factory from the car as the cd40 USB has aux input

Btw the speed yes divided by 2 is gonna be perfect

PNKP237 commented 6 months ago

I hope your PCM5102 isn't broken, here's a test program for you to flash the ESP32 with, please connect it to an amplifier at home so you can check whether the audio output works properly. It has no CAN functionality so you can connect to it and just play music from your phone. ESP32_Audio_Stereo.zip

Additionaly please check whether you connected BCK, LRCK properly and ensure the pads on the back of PCM5102 are shorted according to the schematic (with H3L not shorted).

Vortecsz commented 6 months ago

As soon as I have a chance I'll try it thank you very much. Just a question: the ESP power supply should be given through the USB connector or i can give it directly to the vin and gnd pins?

PNKP237 commented 6 months ago

Yes, you can power the board through the VIN pin, on some boards it's connected the same 5V line as the USB VBUS pin, on other boards it's connected through an additional diode. Just make sure you don't power the board through VIN and through the USB connector (from PC) both at once.

Vortecsz commented 6 months ago

Perfect all working but i found some minor problem; the qualitify of the music is not the best, the sound has some distortion in the background, i'll attach a video below. Sometimes the esp(i think) crashes and the bluetooth is disconnected, and the can also, after some seconds it recconect automatically. Did your setup also have some distortion noise with the aux? I have an aux bluetooth buyed from amazon and it doesn't has background noise

https://github.com/PNKP237/EHU32/assets/61433353/eaeeabb6-ca29-4399-9362-cfa626972faa

PNKP237 commented 6 months ago

I found that the ESP is prone to crashing when the 5V source is not very good. Did you try with additional electrolytic capacitors soldered to the ESP32 board, between VIN and GND? ESP32 is way more power hungry compared to those bluetooth audio boards found everywhere, which is what I used before. My own setup uses a linear 5V regulator (7805) taking power from the radio itself with many additional capacitors on the 12V and 5V lines. Distorted sounds like in your video do happen in case the I2S driver has no new data to process (it loops the last received music sample, often when bluetooth gets disconnected or gets out of range) or during a crash, but it's never that long, maybe 1 sec max. I have honestly not used the external aux much since I bought a CD70 from scrapyard and it has no aux circuitry (therefore my EHU32 is soldered inside the radio directly to aux). Although I did test it briefly with the original CD30MP3 (EHU32 connected to external aux and OBDII port) my car came with and I only had some slight noise from unsmoothed DC-DC converters when I tried to power it with the worst quality step down board I could source.

Vortecsz commented 6 months ago

Right now i'm testing all the setup, and after i'm planning to take the power from the radio as well. Maybe if you will find the time would be fantastic to post also the schematic to power the esp32 from the radio with the capacitators and the 7805

Btw tried with a power bank and a lot of the noise goes away, when I turn up the volume of the stereo and down the volume of the smartphone I can ear a little noise, is the same for you? Both with music playing and not

PNKP237 commented 6 months ago

I should probably clarify in the readme that you should not use the phone's volume control and leave it on max since volume control on I2S results in the audio quality getting worse (the lower the volume, the less bits per sample of audio there is). Only use vehicle's volume control and optionally you can go into CD40 settings and modify the "Aux in volume" to a value of -5 to lower the noise floor.

The best setting for the CD30 family (so CD40USB as well) would be to use the 7805 inside the radio, it makes the experience more seamless since it powers on/off with the radio itself by using the switched 12V or 8V voltage rail inside the radio unit, but an ESP32 module with an antenna is highly recommended because the radio cage acts like a shield. I actually did test it inside the CD30MP3 as well and the method of connecting it inside should work for CD40 as well. As for caps I think I've got 470uF + 100nF on the input of the 7805 and 1000uF + 100nF on the output, additionaly there is a 220uF cap soldered directly to the PCM5102 board. MS-CAN is hooked up directly to the legs of TJA1041 CAN transceiver, audio is soldered to the internal AUX vias. Power can be taken either from switched 12V (on the tab of this large SOT-223 package on the right) or from a 8V rail powering the CD drive. Here are the photos of the mod: IMG_20240105_220551 Internal Aux vias: cdaux white is left channel, black is audio ground, red is right channel

Vortecsz commented 6 months ago

Thanks so much, I'll follow your "schematic" as soon as I can. Btw,my radio hasn't worked in FM mode for a year now, it remains in search and no noise is emitted, do you have any idea what it could be? Has it ever happened to you? Sorry for the OT

PNKP237 commented 6 months ago

I had the radio in my old insignia do it when it got very cold outside (like -10c) but as for cd30 and cd70 there was no issues with the FM reception. My guess is cracked solder joints or a fault with an antenna, next time you will be removing the radio unit from the vehicle try fitting a long wire antenna in place of the antenna connector while leaving the other connector in place so you can test with a substitute antenna.

KingSilverHaze commented 1 month ago

I think this project is great. I bought the ESP 32 WROOM 32U and flashed the software v0.9.2. Unfortunately I can't get a Bluetooht connection. The name is not displayed with the Bluetooht devices. I then flashed ESP32 Audio Stereo for testing. The Bluetooht name ESP32 ADP is displayed, but no connection is established. What is the error?

PNKP237 commented 1 month ago

The name is not displayed with the Bluetooht devices.

With release versions, the bluetooth connection is only available when the board is connected to the vehicle's MS-CAN bus (pins 3 and 11) using a CAN transceiver module (such as MCP2551, SN65HVD230 or TJA105x). Once both the radio and the car's display are on then the bluetooth part is initialized.

As for ESP32_Audio_Stereo not working it could be that the board is reset when trying to connect, I'll investigate with my boards. EDIT: Tested two WROOM-32U boards, everything seems to work properly with the Audio stereo test program. You could try to disconnect everything from the board apart from USB (for power).

KingSilverHaze commented 1 month ago

Thank you for your answer. I have installed it in the CD30MP3 and it works perfectly. The car is a Corsa D. Only the speed is displayed too high. But it is important to me that it works with the Bluetooth stream. Hope this project continues, it's a great alternative for an older vehicle.

Thanks for your work and the know-how.

PNKP237 commented 1 month ago

Glad it works - thanks for the feedback. I'm working on an update and I'd like to fix the speed readout - if you can, please tell me what speed value is displayed on the screen when you're driving, for example: 20 km/h, 50 km/h, 70 km/h (shown on the speedometer). This way I'd be able to correct the conversion. Also provide me with an engine code of your vehicle for clarity.

KingSilverHaze commented 1 month ago

Today I looked at how the values are displayed. It is the A14XER engine.

The RPM shows 3500 and the EHU32 shows 1400 RPM. When idling, the EHU32 shows 3000 RPM. When I drive at 130, the EHU32 shows 60 - 65.

PNKP237 commented 1 month ago

Thanks for taking the time note down the data. Earlier, you said that the speed was displayed too high, but at 130 km/h it was showing half the actual vehicle speed, is that correct?

KingSilverHaze commented 1 month ago

Yes, that's right, it shows exactly half of what it is. The speedometer shows 130 km/h and the display shows 60 to approx. 65 km/h.

NME157 commented 1 month ago

Hello,

Thank You for your great input! I was looking for something similar and what I found is even better. Just wanted to ask if it is possible to connect mic that esp32 would act as handsfree device? What code changes should be made? Btw,will it show on the screen the name of the caller as it is now or code changes should also be made?

PNKP237 commented 1 month ago

Just wanted to ask if it is possible to connect mic that esp32 would act as handsfree device?

There's currently no support for Bluetooth HFP profile under arduino from what I was able to gather, but if I manage to move away from the arduino core I'll try to implement basic HFP where you can hear the caller through the car's speakers but it will still use your smartphone's microphone. Showing caller ID and stuff like that should be easy if I can manage the first part.

NME157 commented 1 month ago

Just wanted to ask if it is possible to connect mic that esp32 would act as handsfree device?

There's currently no support for Bluetooth HFP profile under arduino from what I was able to gather, but if I manage to move away from the arduino core I'll try to implement basic HFP where you can hear the caller through the car's speakers but it will still use your smartphone's microphone. Showing caller ID and stuff like that should be easy if I can manage the first part.

Thank You very much for quick reply!

NME157 commented 1 month ago

By the way,one more question - song name and artist is only displayed of music is played by phone player or does it display info even of music is played from Spotify?

PNKP237 commented 1 month ago

Depends on the application playing the music, but in my experience it works with all default music players, YouTube app and Spotify. Works with Spotify on iPhone as well.