Home

Awesome

<h3 align="center">PSA (Peugeot, CitroΓ«n) VAN bus Live Connect</h3> <p align="center">Live data from your PSA vehicle (Peugeot, CitroΓ«n) on your smartphone or tablet, directly from the VAN bus.</p>

Release Version Release Date

Platform ESP8266

Framework

Build Sketch

πŸ“ Table of Contents

πŸ“Ÿ Screenshots<a name = "screenshots"></a>

Don't bore us, give us the screenshots!

πŸ‘‰ See some exciting live videos and pics at https://drive.google.com/drive/folders/1PScPrWulKUc7Rnl3Ug-_TO_tbdkDwQCP !

Main entry screen:

screen

Tuner:

screen

Tuner presets popup:

screen

Audio settings:

screen

CD player:

screen

CD changer:

screen

Second trip counter:

screen

"Pre-flight" checks:

screen

Instrument cluster (YMMV 🀣):

screen

Current location:

screen

Sat nav main menu:

screen

Sat nav enter destination - city:

screen

Sat nav - personal address entry (not mine!):

screen

Sat nav guidance:

screen

Door open popup:

screen

Warning popup:

screen

🎈 Description <a name = "description"></a>

This application creates a Wi-Fi access point to which you can connect with your smartphone. It contains a captive portal so as soon as you are connected a message gets displayed on your phone to log in. If you tap the message, a browser opens, giving a live visual display of the data as read from the VAN bus.

Of course you can modify the SSID and choose your own password by editing the Config.h file.

πŸ•ΉοΈ MFD functions supported

See also the screenshots above.

πŸ‘‰ Note: availability will depend on your vehicle's configuration.

Will not support:

βš™οΈ Technical Details<a name = "details"></a>

In the beginning of 2000's the PSA group (Peugeot and CitroΓ«n) used "VAN" bus as a communication protocol between the various comfort-related equipment. Later, around 2005, they started to replace this protocol in their newer cars with the CAN bus protocol, however some models had VAN bus inside them until 2009. This overview lists vehicles that are supposedly fitted with a VAN (comfort) bus.

The application will tap in on the vehicle's VAN bus and visualize the captured data in a browser on your smartphone, tablet, laptop or any other device that runs a web browser. The application will run on any ESP8266 / ESP8285 based board, e.g. Wemos/Lolin D1 mini is supported.

The application will host a HTML web page on standard port 80. It will also host a WebSocket server on standard port 81. The served web page comes with some JavaScript that connects to this WebSocket server in order to stream the live data to be visualized.

The web page itself, as served by this sketch, uses and self-hosts the following open-source bundles:

As said, the served web page self-hosts all resources. No Internet connection is needed!

πŸ”Œ Schematics <a name = "schematics"></a>

You can usually find the VAN bus on pins 2 and 3 of ISO block "A" of your head unit (car radio). See https://en.wikipedia.org/wiki/Connectors_for_car_audio and https://github.com/morcibacsi/esp32_rmt_van_rx#schematics .

There are various possibilities to hook up a ESP8266 based board to your vehicle's VAN bus:

  1. Use a MCP2551 transceiver, connected with its CANH and CANL pins to the vehicle's VAN bus. As the MCP2551 has 5V logic, a 5V ↔ 3.3V level converter is needed to connect the CRX / RXD / R pin of the transceiver, via the level converter, to a GPIO pin of your ESP8266 board.

    A board with the MCP2551 transceiver can be ordered e.g. here or here.

    Two variants are possible:

    • Using +12 Volt switched line (pin 4 of the "A" block of the ISO connector): schema
    • Using +12 Volt permanent line (pin 7 of the "A" block of the ISO connector). To prevent battery drain, the ESP board will go to sleep after 5 minutes (configurable in Config.h). This setup requires GPIO line D1 to be connected, so that the ESP board wakes up as soon as any activity occurs on the VAN bus. schema

πŸ‘‰ Notes:

  1. Use a SN65HVD230 transceiver, connected with its CANH and CANL pins to the vehicle's VAN bus. The SN65HVD230 transceiver already has 3.3V logic, so it is possible to directly connect the CRX / RXD / R pin of the transceiver to a GPIO pin of your ESP8266 board.

    A board with the SN65HVD230 transceiver can be ordered e.g. here or here.

    schema

    The "+12 Volt permanent" variant as described above is possible for this setup too.

πŸ‘‰ Notes:

  1. The simplest schematic is not to use a transceiver at all, but connect the VAN DATA line to GrouND using two 4.7 kOhm resistors. Connect the GPIO pin of your ESP8266 board to the 1:2 voltage divider that is thus formed by the two resistors. Results may vary.

schema

πŸ‘‰ Note: I used this schematic during many long debugging hours, but I cannot guarantee that it won't ultimately cause your car to explode! (or anything less catastrophic)

Infra-red control

When the IR remote control is used to navigate, e.g. through the sat nav menus, this is usually not reflected on the comfort bus. So, reading the VAN comfort bus is not enough to detect e.g. scrolling through the menus or lists presented.

To see the navigation through the menus and lists also on the browser screen, simply connect an infra-red receiver, e.g. like this one, on pins D5, D6 and D7, facing outward; see also the above schematics.

πŸ‘‰ Notes:

πŸš€ Building the Project<a name = "building"></a>

Before proceeding with this project, make sure you check all the following prerequisites.

1. Install Arduino IDE

See Arduino IDE. I am currently using version 1.8.19 but other versions may also be working fine.

2. Install ESP8266 Board in Arduino IDE

We’ll program the ESP8266 using Arduino IDE, so you must have the ESP8266 add-on installed. You will need:

Follow the next tutorial to install the IDE and the ESP8266 Board Package:

3. Install Libraries

In the Arduino IDE, go to the "Sketch" menu β†’ "Include Library" β†’ "Manage Libraries...". Make sure to install:

For more explanation on using the Arduino library manager, you can browse to:

πŸ‘‰ Note: for best performance and stability, make sure to copy all the patched files inside and under the VanLiveConnect/Patches/ directory to the indicated directories in your system. In my experience, these patched files significantly improve the stability of the WebSocket (TCP/IP over Wi-Fi) communication.

4. Board Settings

In the Arduino IDE, go to the "Tools" menu, and choose:

Here is a picture of board settings that have been tested to work:

Board settings

I seem to have better Wi-Fi performance by setting the variable build.sdk to:

build.sdk=NONOSDK22x_191122

inside the following file:

%LOCALAPPDATA%\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\platform.txt (Windows)
$HOME/.arduino15/packages/esp8266/hardware/esp8266/3.1.2/platform.txt (Linux)

5. Uploading

To upload the compiled project you will need the following:

First time upload is always via the serial port over USB. After that, the "Over The Air" (OTA) update function will allow uploading via Wi-Fi using a "network port" in the Arduino IDE. See this documentation for help on using the OTA feature of the arduino-esp8266.

Compile and upload

If you have no experience in compiling and uploading, have a look at this excellent tutorial for the Wemos D1 mini board

6. First Run

When the compiled sketch is started for the first time on fresh hardware, it will take a few seconds to initialize the flash-based file system. In my experience, a sketch binary uploaded to fresh hardware sometimes causes the board to crash the very first time, but after that it works (uploads) fine.

πŸ’‘ Hints, tips<a name = "hints_tips"></a>

Android Connected to Both Wi-Fi and Mobile Data Simultaneously

Android does not like a Wi-Fi connection that does not have an Internet connection.

When connecting to the Wi-Fi access point as offered by the ESP, your android device will present a system notification "PSA display AP has no Internet connection. Tap for options.", similar to this:

<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Android/Network%20has%20no%20internet%20access%20status%20bar%20notification.png" width="33%">

When tapping, a popup like this appears:

<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Android/Network%20has%20no%20internet%20access%20popup%20checked.png" width="33%">

Make sure to check-mark "Don't ask again for this network", then tap "Yes".

The Wi-Fi icon at the top is now shown, but it has a small "X" in it. This small "X" indicates that the Wi-Fi connection does not offer an Internet connection. Even though, the landing page 'http://<...>/MFD.html' of the ESP can be accessed successfully.

However, it now becomes impossible for the Android device to access the Internet. All network access is routed towards the Wi-Fi connection, which does not offer Internet. This prevents any apps from accessing the Internet.

A commonly suggested option is to turn on the Android developer-option "Settings > System > Developer options > Mobile data always active". But it doesn't work: all apps will still try to use the Wi-Fi connection for their Internet connection. Moreover, having "Mobile data always active" turned on, decreases battery life, so it is a bad idea anyway.

Ideally, we would like all the Android apps to be able to connect to the Internet via mobile data, while at the same time the Android client device is showing the vehicle data as coming in via the (non-Internet) "PSA display AP" Wi-Fi connection

To make the latter possible with mobile data enabled on the Android device, the web server ("WebServer.ino") in the ESP offers a special feature: it will respond to any request for '.../generate_204'. This makes make Android believe that the Wi-Fi connection has an Internet connection, and therefore it chooses Wi-Fi as the preferred medium.

However, even though "Internet access" via Wi-Fi seems now enabled to the Android device, it still sees that the connection is pretty limited. Android tries to access all kinds of other Internet addresses, which (obviously) fails. Therefore, the Android device now presents a different system notification: "PSA display AP has limited connectivity. Tap to connect anyway.":

<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Android/Network%20has%20limited%20connectivity%20status%20bar%20notification.png" width="33%">

Make sure to check-mark "Don't ask again for this network", then tap "Yes":

<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Android/Network%20has%20limited%20connectivity%20popup%20checked.png" width="33%">

The Wi-Fi icon at the top is now shown without the small "X" in it. The landing page of the ESP can now be accessed via Wi-Fi, even with mobile data enabled.

Unfortunately, the effect is still the same as above: all apps will try to use the (non-Internet) Wi-Fi connection, so all apps still fail to access the Internet.

The solution is to have the web server in the ESP stop responding to requests for '.../generate_204' as soon as a data (WebSocket) connection between the ESP and the Android device is well established.

In this way, the following sequence of events takes place:

  1. As soon as the ESP powers up (or wakes up from sleep), it starts to offer its "PSA display AP" Wi-Fi access point.
  2. The Android device connects to the Wi-Fi access point. The Wi-Fi icon at the top is now shown without the small "X" in it (because the ESP is responding to the '.../generate_204' requests).
  3. The landing page 'http://<...>/MFD.html' of the ESP can be accessed by the browser on the Android device, using Wi-Fi to connect.
  4. The JavaScript code in the landing page sets up a WebSocket connection: vehicle data is sent to the Android device and displayed in its browser.
  5. About 7 seconds after the WebSocket connection is established, the web server on the ESP stops responding to the '.../generate_204' requests.
  6. After a few retries, Android now thinks that the Wi-Fi access point is no longer offering Internet connectivity. As a result, it switches to its mobile connection. However, <i>the WebSocket (TCP/IP) connection remains established!</i>
  7. The apps on the Android device can now access the Internet via the mobile connection, while the vehicle data is coming in on the just established WebSocket (TCP/IP) connection.

More background information and explanation can be found here and here.

OpenVPN

If you are using OpenVPN for Android in "Always-on VPN" mode, you will need to add a route to the local network. Without this route, your smartphone or tablet device will not be able to find the ESP device after it connects to the ESP's Wi-Fi access point.

To add the route:

Then press the Android 'Back' button to go back to the overview of connection profile.

Automating your smartphone or tablet

It is possible (and very convenient!) to automate all actions that are needed to start displaying your vehicle information on your smartphone or tablet as soon as you enter the vehicle. An excellent app that offers all necessary functions is MacroDroid - Device Automation

Below are screenshots that show two macros which perform all the necessary actions:

<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Screenshots/MacroDroid%20overview.png" width="250">
<img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Screenshots/MacroDroid%20connect.png" width="250"><img src="https://github.com/0xCAFEDECAF/VanLiveConnect/blob/main/extras/Screenshots/MacroDroid%20disconnect.png" width="250">

"VanLiveConnect" macro

Upon connection to the Wi-Fi SSID "PSA display AP", performs the following actions:

"VanLiveDisconnect" macro

Upon disconnection from "PSA display AP", performs the following actions:

Of course, the above actions are just a suggestion. Customize as you like!

πŸ“š Used Libraries<a name = "libraries"></a>

Arduino/ESP8266

In the Arduino IDE, the following libraries are used:

Attributions

The application itself embeds:

πŸ‘· Work to be Done<a name = "todo"></a>

❓ Frequently Asked Questions<a name = "faq"></a>

<b>Question:</b> Will this work on my vehicle?

<b>Answer:</b> I have only tested with one vehicle: a 406 from year 2003 DAM number / Build Code: 9586; see also this page (in Dutch). My vehicle has a so-called "type C" Multi-Functional Display (MFD).

It will work (at least to some extent) if you have a Peugeot of around 1996-2004, fitted with a VAN comfort bus.

As mentioned, VAN bus was used in the beginning of 2000's by the PSA group (Peugeot and CitroΓ«n) as a communication protocol between the various comfort-related equipment. Later, around 2005, they started to replace this protocol in their newer cars with the CAN bus protocol.

This overview lists vehicles that are supposedly fitted with a VAN (comfort) bus.


<b>Question:</b> Do I still need the original multi-functional display (MFD)?

<b>Answer:</b> Yes, you do. But you do not need its (crappy) LCD to be working. The MFD is only needed to generate the necessary VAN-bus packets to drive the equipment (Tuner, CD-changer, Sat nav, etc.). Maybe in a later stage, I will be able to reverse-engineer the higher-level protocols and state machines that the MFD implmements. But that will take time...


<b>Question:</b> Which web browsers will this work with?

<b>Answer:</b> I have tested successfully on:

πŸ“œ References<a name = "extref"></a>

For background reading:

πŸ“– License<a name = "license"></a>

This application is open-source and licensed under the MIT license.

Do whatever you like with it, but contributions are appreciated!