Porting Alpine M-Bus emulator from Arduino Pro Mini to Esp32 dev
Posted: Thu Jul 01, 2021 11:44 am
Hi everybody,
I’m new to this forum. Being neither an engineer nor a programmer, I’ve started some years ago with some homebrew modules for home automation (eq3 and others). I can handle a soldering iron, modify code written by somebody who knows writing code, and I succeed normally with compiling and flashing etc.
But as a non-programmer I have clear limits when it comes to understanding and applying software/hardware issues, and this is the point where I am with my latest project.
My latest project is to create a AUX input for the original radio of my youngtimer car (a 1995 Jaguar XJS). It’s an Alpine head unit (HU) with a CD changer in the trunk, and Alpine’s M-Bus, used for communication between the HU and the CD changer, is the clue for the AUX input.
The HU only opens the audio signal coming in throug the CD line when it’s able to „talk“ to the changer via the M-Bus. So you would need a kind of M-Bus emulator to make the HU think that it was actually talking to a CD changer.
Fortunately, there was now need to reinvent the wheel, as this task has been adressed by several guys more familiar with coding and hardware than I am. The „mother of all M-Bus back-engineering“ would be http://www.hohensohn.info/mbus/
I successfully use Olystyle’s M-Bus library for Arduino with a Pro Mini (https://github.com/Olstyle/MBus); Picohar's approach with an AT128 also worked for me (https://github.com/picohari/atmega128_a ... s-emulator). For both, I am using Picohari’s hardware suggestion to split up the bus signal with a couple of transistors and resistors (https://raw.githubusercontent.com/picoh ... dapter.png). Interestingly, this is working fine without connecting to a 5 V source (or 12 Volt as in Jörg Hohensohn's suggestion).
Now I would like to go one step further, integrating A2DP bluetooth into the M-Bus dongle. This way, the original buttons of the HU (for example the buttons for selection of CD 1 to 6) could be used e.g. for sending play/pause/fwd/stop etc. commands to the connected smart phone.
This is when I decided to give the Esp32 a try, as it comes with integrated Bluetooth and there are nice libraries for a non-professional like me. I have the „ESP32 NodeMCU Dev Kit C with CP2102“. I was hoping to be able to use Olstyle’s library and sample code for the Esp32 (via Arduino IDE). The sample code (working, as said, with a Pro Mini), is https://github.com/Olstyle/MBus/blob/ma ... uttons.ino
Compiling and upload are working, but once connected to the HU, the bus doesn’t seem to enter into conversation.
I’ve changed the pin definitions for IN and OUT from 10 and 12 (Olstyle’s Pro Mini sample script) to pins 4 and 5 for the Esp32. I didn’t change the definition
in Mbus.cpp, as I understood that it was ok for the Esp32, too.
But I’m afraid that there is more need for changes to have the ino running on the Esp32.
I would be very thankful if sb. could help me to achieve this.
Thanks & best regards
Martin
I’m new to this forum. Being neither an engineer nor a programmer, I’ve started some years ago with some homebrew modules for home automation (eq3 and others). I can handle a soldering iron, modify code written by somebody who knows writing code, and I succeed normally with compiling and flashing etc.
But as a non-programmer I have clear limits when it comes to understanding and applying software/hardware issues, and this is the point where I am with my latest project.
My latest project is to create a AUX input for the original radio of my youngtimer car (a 1995 Jaguar XJS). It’s an Alpine head unit (HU) with a CD changer in the trunk, and Alpine’s M-Bus, used for communication between the HU and the CD changer, is the clue for the AUX input.
The HU only opens the audio signal coming in throug the CD line when it’s able to „talk“ to the changer via the M-Bus. So you would need a kind of M-Bus emulator to make the HU think that it was actually talking to a CD changer.
Fortunately, there was now need to reinvent the wheel, as this task has been adressed by several guys more familiar with coding and hardware than I am. The „mother of all M-Bus back-engineering“ would be http://www.hohensohn.info/mbus/
I successfully use Olystyle’s M-Bus library for Arduino with a Pro Mini (https://github.com/Olstyle/MBus); Picohar's approach with an AT128 also worked for me (https://github.com/picohari/atmega128_a ... s-emulator). For both, I am using Picohari’s hardware suggestion to split up the bus signal with a couple of transistors and resistors (https://raw.githubusercontent.com/picoh ... dapter.png). Interestingly, this is working fine without connecting to a 5 V source (or 12 Volt as in Jörg Hohensohn's suggestion).
Now I would like to go one step further, integrating A2DP bluetooth into the M-Bus dongle. This way, the original buttons of the HU (for example the buttons for selection of CD 1 to 6) could be used e.g. for sending play/pause/fwd/stop etc. commands to the connected smart phone.
This is when I decided to give the Esp32 a try, as it comes with integrated Bluetooth and there are nice libraries for a non-professional like me. I have the „ESP32 NodeMCU Dev Kit C with CP2102“. I was hoping to be able to use Olstyle’s library and sample code for the Esp32 (via Arduino IDE). The sample code (working, as said, with a Pro Mini), is https://github.com/Olstyle/MBus/blob/ma ... uttons.ino
Compiling and upload are working, but once connected to the HU, the bus doesn’t seem to enter into conversation.
I’ve changed the pin definitions for IN and OUT from 10 and 12 (Olstyle’s Pro Mini sample script) to pins 4 and 5 for the Esp32. I didn’t change the definition
Code: Select all
pinMode(_in, INPUT);
pinMode(_out,OUTPUT);
But I’m afraid that there is more need for changes to have the ino running on the Esp32.
I would be very thankful if sb. could help me to achieve this.
Thanks & best regards
Martin