Giter VIP home page Giter VIP logo

vanliveconnect's Introduction

PSA (Peugeot, Citroën) VAN bus Live Connect


Live data from your PSA vehicle (Peugeot, Citroën) on your smartphone or tablet, directly from the VAN bus.

📝 Table of Contents

📟 Screenshots

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

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.

  • The SSID of the Wi-Fi access point is: "PSA display AP" (with the spaces, without the quotes)
  • No password is needed.

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.

  • Clock with exterior temperature
  • Instruments (speed, RPM, fuel level, engine temperature)
  • "Pre-flight" checks (oil and fuel level, engine temperature)
  • Odometer and trip counters
  • Live fuel data (consumption, remaining distance)
  • Radio (tuner)
  • Cassette tape player (well... even CD is vintage these days 😉)
  • Head unit internal CD player
  • CD changer unit
  • Notifications and warnings
  • Satellite Navigation (maps are out of date but it's a nice gimmick 😇)
  • Multiple languages: English, French, German, Spanish, Italian and Dutch
  • Setting color theme and brightness
  • Setting format and units

👉 Note: availability will depend on your vehicle's configuration.

Will not support:

  • Setting date and time: your smartphone already knows...

⚙️ Technical Details

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:

  • jQuery v3.5.1 - compressed, production version - original download here.
  • FontAwesome v5.15.2 - original download here.

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

🔌 Schematics

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:

  • The two terminator resistors R3 and R4 (2 x 100 Ohm, near the CANH and CANL pins) on this transceiver board are meant for operating inside a CAN bus network, but are not necessary on a VAN bus. In fact, they may even cause the other equipment on the bus to malfunction. If you experience problems in the vehicle equipment, you may want to remove (unsolder) these terminator resistors. See also this issue.
  • CANH of the transceiver is connected to VAN BAR (DATA B), CANL to VAN (DATA). This may seem illogical but in practice it turns out this works best.
  • The clamping circuit (D1, D2, R1) seems to (somehow) help in reducing the amount of bit errors (packet CRC errors).
  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:

  • The terminator resistor R2 (120 Ohm, near the CANH and CANL pins) on this transceiver board is meant for operating inside a CAN bus network, but is not necessary on a VAN bus. In fact, it may even cause the other equipment on the bus to malfunction. If you experience problems in the vehicle equipment, you may want to remove (unsolder) the R2 terminator resistor. See also this issue.
  • CANH of the transceiver is connected to VAN BAR (DATA B), CANL to VAN (DATA). This may seem illogical but in practice it turns out this works best.
  • The clamping circuit (D1, D2, R1) seems to (somehow) help in reducing the amount of bit errors (packet CRC errors).
  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:

  • Don't remove or unsolder the infra-red receiver (PCB) from the original MFD type C display. The original MFD needs that to receive the commands you send to it, in order to generate the correct VAN bus packets.
  • The infra-red receiver is not needed to switch screens. If you turn on the head unit (radio, CD player, ...) the screen will automatically switch to it. You can also switch screens on your smartphone or tablet simply by tapping the center of the screen. The smartphone or tablet will cycle only through the applicable screens, i.e., if the head unit is not powered on, the head unit screen will be skipped.

🚀 Building the Project

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:

  • Arduino IDE, with
  • ESP8266 Board Package installed. I am currently using version 2.6.3 but other versions may also be working fine (tested on versions 2.6.3 ... 3.0.2; lowest VAN packet CRC error rate was achieved using version 2.6.3).

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:

  • CPU frequency: 160 MHz, and
  • lwIP variant: "v2 Lower Memory (no features)".

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\2.6.3\platform.txt

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

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:

When tapping, a popup like this appears:

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 the Android client device to show the vehicle data as coming in via the (non-Internet) "PSA display AP" Wi-Fi connection, whilst all the apps are still being able to connect to the Internet via mobile data.

To make that possible, 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.

However, even though "Internet access" 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.":

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 without the small "X" in it. The landing page of the ESP can be accessed.

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.
  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, the WebSocket (TCP/IP) connection stays up!
  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 already 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:

  • Open the "OpenVPN for Android" app
  • Tap the 'pen' icon next to your connection profile
  • Tap the 'ROUTING' tab
  • Under the 'IPv4' section:
    • Untick 'Use default route'
    • Tap 'Excluded Networks'
    • Enter 192.168.244.0/24 (note: the "192.168.244." part must match with the IP address as specified in Config.h).
    • Tap 'OK'

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:

"VanLiveConnect" macro

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

  • Set the screen timeout value to 500 minutes, to prevent the screen from going black while driving
  • Browse to the main screen (http://192.168.244.1/MFD.html)
  • Set the screen brightness to 100%
  • Go "full-screen"

"VanLiveDisconnect" macro

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

  • Set the screen brightness back to 88%
  • Set the screen timeout value back to 2 minutes
  • Go back to the system home (launcher) screen

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

📚 Used Libraries

Arduino/ESP8266

In the Arduino IDE, the following libraries are used:

Attributions

The application itself embeds:

👷 Work to be Done

  • No plans 😊

❓ Frequently Asked Questions

Question: Will this work on my vehicle?

Answer: 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.


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

Answer: 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...


Question: Which web browsers will this work with?

Answer: I have tested successfully on:

  • Windows Desktop
    • Firefox, any recent version
    • Chrome, any recent version
  • Mobile
    • Android Firefox 68.11.0 and higher
    • Android Chrome 88.0 and higher

📜 References

For background reading:

  • Vehicle Information Service Specification - defines a WebSocket based API for a Vehicle Information Service (VIS) to enable client applications to get, set, subscribe and unsubscribe to vehicle signals and data attributes.

📖 License

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

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

vanliveconnect's People

Contributors

0xcafedecaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vanliveconnect's Issues

Change UI Language

First you have made an super program !!!

But, on my setup, the data sometimes freeze and not refreshed.[Edit : after closing mobile data app data refresh is ok]

Maybe it's because I haven't navigation system and stock radio unit ?

Also, I don't found how to change language .
I can access to MFD only thru Firefox on Windows PC or Safari on an iPhone. [Fixed after new flash of ESP]

As feedback, on my setups :
Xsara HDI exclusive 2001

  • Speedometer
  • RPM
  • Coolant temp
  • VIN Number and odmeter
  • icons linked to lights is working
  • Some reaction when activate back window heating but with an strange temp

C5 HDI 2001
Same as Xsara +

  • OBD data about autonomy
  • Fuel gauge is ok with quantity
  • Push button on right command (windows washer) is working
  • No reaction to speed limiter command (but maybe normal because I try it static not rolling)

Thanks a lot !

Very kind regards

Compile issue

'virtual bool WebSocketsServer::clientIsConnected(WSclient_t*)' is protected within this context

Probably missing a step somewhere but this is my 8th time running through all the steps checking each one along the way and still get stopped at the message and help would be appreaciated

IR receiver - I don't see any signals

Hello. I use NodeMCU v3. Arduino IDE 2.3.2
I don’t see the port in the monitor, IR signals from the remote control (Samsung, LG)
TSOP 4838
Not connected to the machine (if this is important)
On the NodeMCU they are connected as in the diagrams (D5,D6,D7)
In Config.h I uncommented the line
#define DEBUG_IR_RECV
uploaded a sketch

VanBus version 0.4.0 initialized; VanBusRx queue of size 30 is set up
Setting up IR receiver
ESP will enter light sleep mode after 5:00 minutes of inactivity; listening on pin D1 (GPIO5) for VAN bus activity to wake up from sleep.
Connected to Wi-Fi SSID '*******'
Wi-Fi signal strength (RSSI): -52 dB
Please surf to: http://192.168.1.122/MFD.html

Maybe there is still something that needs to be done?

The amount of fuel is not displayed on the 206+ 1.6L

Hello . It is an interesting project. It works well! thank you
In order to personalize the Brazilian language, I defined it.
The gear values are not displayed correctly, which is related to the power and torque coefficients because the engine is 1.6 liters.
But the display does not show the amount of fuel and only (_ _ /_) is displayed

How to change theme colors?

Hi,
I did the project and works great but I'd like to personalize the interface colors. I tried to make some changes by my own but I don't know how exactly do it because of the different possibilities. Light theme, dark theme, dimmer, etc. I can't identify where are each of them.
Could you give me a little guide on how to do that?.
Thanks in advance.

Newer navigation directions (eg. Google Maps)

I've only just stumbled upon this amazing project, but this thought occurred to me. I see that you were able to reproduce the messages from the original GPS system. Have you perhaps thought about using more recent data for this purpose? I don't know how feasible it would be, but it would be cool to read the navigation directions set with Google Maps or another such service and display them as in the original system.

Change display aspect ratio

hi
first thanks for this project its very attractive
i have peugeot 206 1.6 16v petrol and installed 6.2inch android HU with 800x480 pixels resolution
when web page loaded in fullscreen , bottom of screen goes blank
is any way to change and fix this?

Screenshot_20240307_011246_Gallery

It does not work in Peugeot 206 (2006)

Hello buddy
I was very happy to see your project. It is attractive
In the initial check, I could not see the information on the server!
I tested the first and second methods
I did not try the third method without a network controller.

I tested with 8266 based Ardiono boards but I have no data on the server
I have a compilation error, maybe this is the problem!

#error "...\Arduino\libraries\WebSockets\src\WebSockets.h:"
#error "Value for '#define WEBSOCKETS_TCP_TIMEOUT' is too large; set to at most 1000!"

Weird car behavior

As device is connected, fake Nodemcu with CP2102 USB chip and ESP-12E, sometimes when key is in ACC position, all dash lights light up for about second, then they turn off like they should be, and while driving, left airbag light (not the one with air bag letters) lights up, and stays up for the rest of the ride (until engine is turned off). Also, sometimes dash backlight dims to about half I have it set (like from 81% to about 40%) while driving. Device is connected to VAN bus and also powered from radio connector. As it was more suitable for the case, I connected it to pin D6 on NodeMCU. I'm using SN65HVD230 transceiver.

Data were displayed correctly, I really liked it (except the fuel consumption, 0.2l/100km :) ).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.