dontwaste / Volvo-RTI-Crankshaft-Canbus-Melbus

I'm not a programmer/coder and this is my first project, so if anyone can help with editing the codes so I could use less hardware, that would be awesome. In a 2005 Volvo V70 the RTI screen displays Crankshaft, can be navigated using the steering wheel buttons and plays sound to the original stereo. Raspberry Pi + 3b, Arduino Nano, ESP32, ESP8266
13 stars 1 forks source link

Need little help steering wheel controls. #1

Open SuBerPL opened 1 year ago

SuBerPL commented 1 year ago

Hi. First of all, it's a great project, it's good to see that you can still get something out of such an old car. I did everything according to your project with minor hardware changes (I replaced the ESP for RTI control with Arduino Nano). However, I have a problem with steering wheel controls. Unfortunately, your code doesn't work for me, even though we have quite similar cars (mine is S60) and are from the same year. Can you explain to me how to check the CAN bus ID? Unfortunately, from the link you provide (https://www.circuitstate.com/tutorials/what-is-can-bus-how-to-use-can-interface-with-esp32-and-arduino/) it is not I understand a lot and I don't know if I really need two ESP32? In the diagram on the website, I don't see where to connect the car's CAN and what code to use. To be honest, it's a bit beyond me.

I would also like to ask if your ARDUINO for audio also lights up with the PWR diode all the time? As soon as I connect the ground to it, it lights up, it receives 3V power from the wires connected to D3, D4, D5, which come from the radio. When I power Ardiuno via the VIN and GND pin, changing to CD-CHR on the radio does not work, but when I power it from USB-C, everything works fine.

If I could ask you for a little help, I would be grateful.

dontwaste commented 1 year ago

Hi!

Thank you for writing.

I'm in the middle of finishing a big project at work this week, so my days are a bit too long to to be clearheaded enough to give you a proper answer this week, but remind me again next week and I'll do what I can to help you.

Parimat!

Sander Ševtšenko (+372) 590 33 621 Skype: sander-sevtsenko

On Mon, Oct 30, 2023, 17:31 SuBerPL @.***> wrote:

Hi. First of all, it's a great project, it's good to see that you can still get something out of such an old car. I did everything according to your project with minor hardware changes (I replaced the ESP for RTI control with Arduino Nano). However, I have a problem with steering wheel controls. Unfortunately, your code doesn't work for me, even though we have quite similar cars (mine is S60) and are from the same year. Can you explain to me how to check the CAN bus ID? Unfortunately, from the link you provide ( https://www.circuitstate.com/tutorials/what-is-can-bus-how-to-use-can-interface-with-esp32-and-arduino/) it is not I understand a lot and I don't know if I really need two ESP32? In the diagram on the website, I don't see where to connect the car's CAN and what code to use. To be honest, it's a bit beyond me.

I would also like to ask if your ARDUINO for audio also lights up with the PWR diode all the time? As soon as I connect the ground to it, it lights up, it receives 3V power from the wires connected to D3, D4, D5, which come from the radio. When I power Ardiuno via the VIN and GND pin, changing to CD-CHR on the radio does not work, but when I power it from USB-C, everything works fine.

If I could ask you for a little help, I would be grateful.

— Reply to this email directly, view it on GitHub https://github.com/dontwaste/Volvo-RTI-Crankshaft-Canbus-Melbus/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL7LPQ7ZQNSOWBC2E43KS43YB7B5NAVCNFSM6AAAAAA6WHARA2VHI2DSMVQWIX3LMV43ASLTON2WKOZRHE3DQNRVGM4TCNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SuBerPL commented 1 year ago

Hi. Thank you for your answer. Of course, if you have some free time, I would like you to describe a little how to read the ID and codes from CAN.

Regarding the Arduino emulating the changer, I noticed that as soon as it is connected to ground in any way, it draws 3V and about 10mA from the battery. It doesn't seem like much, but even though the power supply is cut off, it still consumes it via these 3 pins from the radio. You don't have such a problem at your car?

Good luck with your project at work.

dontwaste commented 1 year ago

So, first: I originally used Arduino Nano (5V) instead of ESP8266 for the RTI screen as well, so that should not be a problem, you just have to cut out the logic converter and it should be ready to go (if you're using a 3,3V Nano, you still need the logic converter and then the microcontroller you're using should not make a difference).

About receiving CAN messages: You don't exactly need 2 sets of esp32 and can transceiver. The link I provided used 2 sets for demonstrating the logic and I used it to determine that I have connected the hardware properly and it works. After I was sure the hardware part works I connected 1 esp32 with the transceiver to the car. (I'm going to upload the code I THINK I used to receive all the can messages to the project under "Testing" - I don't have the computer, I was using, with me at the moment so I'm going to double check the code at some point.)

After connecting the ESP32 to the car I started seeing can messages via serial, but the problem was I wasn't able to copy all of them from the Arduino IDE interface, so I used a program called CoolTerm (You should find what you need to know about it from here: https://www.youtube.com/watch?v=RWgyCcnUxPY ).

Coolterm saved the messages in a notepad file and then I think I copied them to a Word file, did some editing and then copied it to an Excel file, so I could filter the messages and get a better understanding of what I was receiveing.

Now the difficult part with doing it the way I did, was understanding which ID was the one I was after. I was lucky enough to stumble on a project that had the ID I needed. In my projects "README" I have linked to that project. You were saying your car is a S60 - so maybe the ID you need is the one, that Luuk used in his project: https://github.com/LuukEsselbrugge/Volve

const int SWM = 0x00400066;

About the Cd changer issue: I'm getting the idea that you are using a 3,3V Arduino Nano. I used a 5V Nano and don't know much about the 3,3V version, but by reading what you described, I want to ask what's the voltage your Arduino gets from the VIN and GND pins? When you use a usb, it receives 5V, maybe that's the difference?

About the Arduino consuming power all the time: I don't think I have that problem but I do have a power relay installed as you can see from my diagram, so my Arduino does not have the chance to get power when the ignition is off (I hope). When the ignition is turned on/the car is started, the relay receives power and switches on the power for the Step-Down.

SuBerPL commented 1 year ago

Okay, I'll try to explain as best I can. I'm using Google Translate to help a bit, so there may be some minor mistakes.

I have two Arduino nanos. Both Arduino nanos are probably 5V, I bought them on Aliexpress and obviously not all the information is provided there.

The first one is connected as RTI screen control. It is connected to the power supply via the VIN and GND pins. An 11V power supply is connected to the VIN pin via a voltage stabilizer, I read that Arduino has a stabilizer and can accept 6-12V on the VIN pin. Everything with the screen works fine and I don't use a voltage converter.

The second one is connected via pins D3, D4 and D5 to the DIN cable that connects to the radio. It is with this Arduino that I have a problem. Originally, it was supposed to be powered like the other one from the same voltage stabilizer. But with this connection it did not work, the radio did not show the CD-CHR option. So I unplugged the VIN cable and then noticed that despite the power supply being cut off (I also have a main relay for the whole thing), one Arduino was still powered. The only thing connected to it were 3 wires from the radio (D3, D4, D5) and GND. I measured the voltage on these pins and it turned out that they were constantly supplying 3V to the Arduino. I decided to check the USB power supply. I connected the cable to the Raspberry Pi and on the other side to the Arduino. And the same, even though the RPI had no power (the key was removed and the relay cut off the power to all devices), the Arduino remained on. In this configuration, however, after turning the key, I could at least change the radio to CD-CHR. Currently, I have the Arduino removed and the radio remains on CD-CHR and it plays sound, but if you accidentally change the source, you will have to connect the Arduino again.

I will try to do the controls this week. If I succeed, I will definitely let you know. I will use the code that is on the page with these two ESP32s. I read that there are two versions, one for sending the other for receiving CAN signals. I will try, but I am not sure about the speed of the CAN line. My S60 is theoretically facelifted, so the speeds may be different from yours.

dontwaste commented 1 year ago

So, from what I understand, the code and the connections to the car for the Arduino CD-changer are all good and the only problem is powering the arduino. I'm just guessing here, but I'm pretty sure, that if you connect it like you had it before, turn off the engine and wait for a while (let's say 10 minutes) the light on the Arduino will turn off, because at some point the car will decide to go to sleep and stop sending signals around.

But since you're having trouble powering the Arduino anyway, I would suggest you get a small/cheap step-down for the arduino: if you want, you can get it with a USB port as well : https://www.oomipood.ee/product/oky3501_1_toitemoodul_dc_dc_step_down_6_24v_5v_3a_usb_pesa_15w

I'm pretty sure I don't have the problem you're describing because the GND signal can't get through unless the step-down is powered on.

SuBerPL commented 1 year ago

Hi, I finally made it. I bought another transcover for CAN, one powered by 3.3V. I connected everything and finally started receiving ID messages. I also checked your code again and it works. steering wheel buttons cause the appropriate letters and numbers to appear on the serial monitor. However, another problem arose. RPI unfortunately does not read these characters and does nothing. I added the code you shared to the "startup.py" file in the crankshaft folder. Apparently when I checked, when PI is started, the script is also run, unfortunately it doesn't work. did you do anything extra on PI with this code? Should I grant any additional permissions?

dontwaste commented 1 year ago

So, first of all. Since you are in the process of doing this, maybe you want to edit the code as well.

  1. The delay system I used is not very good - it works, but if you know anything about coding, maybe you can find a better way to do this (I just didn't have time to test out a better solution and I don't know much about coding).
  2. I have found, that when the turning signals are engaged, the "Enter" (maybe "Back" as well - don't remember) button doesn't work. I'm pretty sure, that when the turning signals are engaged, the can message sent by pressing the "Enter" button is different than from the one sent when the turning signal isn't engaged.

About the startup.py - as I said in my readme: "It took me a while but with the help of ChatGPT i finally managed to get the python code in raspberry to work.

I then turned it into a service and made it run every time the Raspberry was booted."

Basically what I did: I took the raspberry out of the car and brought it inside, connected it to a screen and to a network cable. Then connected to it via SSH. Took 1 ESP32 and connected it to the Raspberry, then put code on the ESP32 so it would send out the same messages as the ESP32 in the car would, but in a infinite loop with a delay of 1 second before evey message (or something like that). Then I tried to get the raspberry to react accordingly and that resulted in the buttons.py code. [I'm going to add my conversations with ChatGPT about turning the buttons.py code into a service to the testing folder]. Then I turned the code into a service and made it run every time the raspberry was booted.

Having done that and having the esp32 with the looped code, I had the option to turn the raspberry on, connect my phone to the raspberry, have the Android Auto run and visually see on the screen that all button press commands worked one by one, with a 1 second delay between them.

SuBerPL commented 1 year ago

Hi, thank you for your quick reply. It took me half a day of trying, but it finally worked. I had to modify the code on RPI a bit because yours had some problem on my setup. With the help of ChatGPT, I managed to create another one that worked. I'm finally done. I'm so tired of it that I don't have the strength to think about what could be improved. I will definitely try to switch to fewer devices, a better screen and newer, faster RPI in the future. For this, however, I will have to learn a little programming. Without your help, I would definitely have abandoned the project, because LUUK's project was a bit too complicated to redo it myself.

I am very grateful to you!

If you want, below is what I added to the whole thing. This is to help you safely close the Raspbery and automatically cut off the power to the whole thing. hXXLSKy

and link to information: https://www.reddit.com/r/crankshaft/comments/9r3m3n/shutdown_wiring_in_ng/

All the best and thank you again.

dontwaste commented 1 year ago

What were the modifications you did on the RPI code? Can I find your project online somewhere?

SuBerPL commented 1 year ago

I didn't make any modifications. Crankshaft openato already has a function for this. Just edit the "crankshaft_env.sh" file, you will find it in the boot/crankshaft folder on your memory card. It is best to do this by connecting the card to the computer. In the file you will find a line called Ignition_PIN. I set it to GIPO 4 and Ignition delay for 15 seconds. And on the time relay I set the power supply to be cut off 45 seconds after disconnecting the control (12V after the key). This function worked for me until I installed steering wheel controls. Now I don't know why, despite the shorted pin 4 and GND, the RPI turns off 15 seconds after disconnecting the phone from the USB. I think I might have messed something up when I added the buttons service. Unfortunately, it's too cold to fix it right now.

dontwaste commented 1 year ago

In the last comment you wrote: " I had to modify the code on RPI a bit..."

That's why I asked.

I'm probably not going to make any changes to my own setup before the summer, cause it's cold here as well.

Where are you from anyway?

SuBerPL commented 1 year ago

Oh! That's what you meant. I am uploading the buttons.py file below. I meant this file when I wrote that I had to change the code to RPI. I also had to add the uinput library and give it the appropriate permissions. I'm from Poland and you? buttons.py.txt

dontwaste commented 1 year ago

Your code looks like it understands actual button presses - am I right? How does it act when you hold down a button (When you want to scroll the recent calls list or scroll when typing in an aadress or something)?

I'm from Estonia. Have passed through Poland a couple of times though.

SuBerPL commented 1 year ago

I'm not sure now, I'll check it tomorrow, but it seems to me that when I hold the down button on the steering wheel, for example, the screen simply jumps down another position every 0.3 seconds (until Android auto decides to stop it with a rest message) .