0xCAFEDECAF / VanLiveConnect

Live data from your PSA vehicle (Peugeot, Citroën) on your smartphone or tablet, directly from the VAN bus
MIT License
39 stars 3 forks source link

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

Closed Drsimson closed 2 years ago

Drsimson commented 2 years ago

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

0xCAFEDECAF commented 2 years ago

Thanks!

In my vehicle (406, 2.0 HDI), the fuel level is reported as number of litres left (0...73), in packet IDEN 664, data byte 4. See also: https://github.com/0xCAFEDECAF/VanLiveConnect/blob/4012c4dc46d7faf58a93145d753b6cd15a6db702/VanLiveConnect/PacketToJson.ino#L1768

I think in your vehicle the fuel level is reported as a percentage, in packet IDEN 4FC, data byte 7; see also: https://github.com/0xCAFEDECAF/VanLiveConnect/blob/4012c4dc46d7faf58a93145d753b6cd15a6db702/VanLiveConnect/PacketToJson.ino#L1018

Have a look also at http://pinterpeti.hu/psavanbus/PSA-VAN.html ; scroll down to IDEN 4FC.

You might want to adapt the code around line 1018 of PacketToJson.ino to report into the fields "fuel_level_filtered" and "fuel_level_filtered_perc", which drive the display on the HTML page. You would have to adapt the code around line 1808 of that same file to not report those fields from there.

If you give your VIN number, I can also try to determine from that what is the vehicle type, so that the correct IDEN is parsed for reporting fuel level. Or you can point to an entry in the following table: http://www.peugeotlogic.com/workshop/wshtml/specs/vincode.htm

For the gear values, you have to find the ratios yourself. I do not have a 206+ vehicle at hand. Please adapt the code around: https://github.com/0xCAFEDECAF/VanLiveConnect/blob/4012c4dc46d7faf58a93145d753b6cd15a6db702/VanLiveConnect/MFD.js.ino#L3824

Drsimson commented 2 years ago

Yes, in my car the fuel information is distributed in byte 7 of IDEN 4FC But the change in the structure and lines of 1018-1808 had no result for now. According to the VIN table, the car is (2JNFUA). Regarding the display of the gearbox status, it takes time because I change the 1st gear and the others are not displayed correctly. Of course, I have been familiar with your project for a few days now. And I will spend more time on it

Drsimson commented 2 years ago

Also, there is a compilation error in the last commit . . VanLiveConnect:126:10: fatal error: PrintEx.h: No such file or directory 126 | #include | ^~~ compilation terminated. exit status 1 PrintEx.h: No such file or directory

0xCAFEDECAF commented 2 years ago

Also, there is a compilation error in the last commit . . VanLiveConnect:126:10: fatal error: PrintEx.h: No such file or directory 126 | #include | ^~~ compilation terminated. exit status 1 PrintEx.h: No such file or directory

--> Fixed!

Drsimson commented 2 years ago

Hello I saw that IDEN 4FC fuel level is defined in the last commit. Your work was great I tested it, the fuel percentage is displayed correctly, but some changes need to be made in the HTML file because the fuel level icon continues to the moon :)) Screenshot_20220919-023908_Chrome

0xCAFEDECAF commented 2 years ago

Ah, I see the mistake. Will fix. Thanks for reporting! :-)

0xCAFEDECAF commented 2 years ago

Fuel level reported as percentage now displayed

Drsimson commented 2 years ago

Thank you 👍 . The annoying problem is the random change of language and units % ---> liters ---> gallons And it is displayed only in the correct percentage mode. For example, a strange number of 120 liters is displayed in a liter Of course, the language problem was solved by removing other languages, but there are problems with units

0xCAFEDECAF commented 2 years ago

I think your vehicle is sending non-zero data in byte# 4 of bus packets of IDEN 664. This is interpreted as litres of fuel. You could comment out or remove the if-statement starting at line 1828 of PacketToJson.ino.

That should suppress reporting of fuel level in litres/gallons for your vehicle.

Drsimson commented 2 years ago

Hello . In the screenshots, the background has an image whose file is available in the Extras folder, but it is not uploaded in the html address! Should the file link be defined somewhere?

0xCAFEDECAF commented 2 years ago

The background image is found in the data directory.

To have that served by the web server, you need to use the SPI Flash File System (SPIFFS). This is done by uncommenting the #define in line 133 of the Config.h file. You must the also upload the data directory into the ESP board using the "Arduino ESP8266 filesystem uploader", as found at https://github.com/esp8266/arduino-esp8266fs-plugin/releases . See also https://randomnerdtutorials.com/install-esp8266-filesystem-uploader-arduino-ide/ for installation instructions.

Note that, in order to work correctly in combination with the VanBus library, the SPIFFS must be compiled in "read only" mode. For detailed instructions, please read Config.h line 102 and onwards.

Drsimson commented 1 year ago

Hello, sir I changed line 42 in MFD.JS function updateDateTime() { var locales = { "set_language_french": "en-GB", "set_language_german": "en-GB", "set_language_spanish": "en-GB", "set_language_italian": "en-GB", "set_language_dutch": "en-GB" }; I tried to block the display of other languages But I still see automatic language change. With language changes in Packet to json There are problems in performance and execution. In my country, there is no Type C remote control. Is there a simple way to make the project monolingual? TNX

0xCAFEDECAF commented 1 year ago

I would try changing function setLanguage(language) to simply ignore the passed parameter and overwrite it with the language of you choice, e.g. "set_language_english".

Unfortunately, I do not have a Type B MFD, so I cannot test with that :-(

Drsimson commented 1 year ago

I would try changing function setLanguage(language) to simply ignore the passed parameter and overwrite it with the language of you choice, e.g. "set_language_english".

Unfortunately, I do not have a Type B MFD, so I cannot test with that :-(

this is great I have type B screen and can test :) There is also the problem that the fuel percentage will not show in beginning. For example, after running the IP address, I have to turn on the high beam or the indicator so that the fuel percentage is displayed because it is dashed at the beginning.

0xCAFEDECAF commented 1 year ago

I have type B screen and can test :)

True, but for real development I would prefer to have this on my desk... ;-)

0xCAFEDECAF commented 1 year ago

There is also the problem that the fuel percentage will not show in beginning. For example, after running the IP address, I have to turn on the high beam or the indicator so that the fuel percentage is displayed because it is dashed at the beginning.

Indeed, some data is not regularly sent over the VAN bus. For that, there is the function EquipmentStatusDataToJson. It will be called to report data as soon as a new WebSocket client connects.

Currently, fuel level is not part of that report, but it could be added. The fuel level percentage is already available as a global variable, see line 938.

0xCAFEDECAF commented 1 year ago

Currently, fuel level is not part of that report, but it could be added.

Just pushed commit https://github.com/0xCAFEDECAF/VanLiveConnect/commit/1aa909e9f3851014fa09bce5dceb32b7c0bf2afa . You may want to test.

Drsimson commented 1 year ago

Currently, fuel level is not part of that report, but it could be added.

Just pushed commit 1aa909e . You may want to test.

Oh, thank you Sorry for the late reply, I have little free time and spend it all on my car I tested and it works for fuel but the same functions should be applied for service and oil mileage as they are still dashed . I will try to add them according to the fuel instructions

Drsimson commented 1 year ago

Hi sir I found that it works on my car, but on a similar car it is processed but not displayed Information. The BSI version was one Both 206+. My car is a 2007 model, this car is a 2006 model!

https://user-images.githubusercontent.com/113470395/208313465-f6c5cca6-5dc6-4d7f-972f-e1834ddb0a9c.mp4

0xCAFEDECAF commented 1 year ago

Hi, difficult to say what is the issue here. The blue flashing light is from the ESP?

Do you see any packets on the Serial output when you run VanBusDump.ino?

Drsimson commented 1 year ago

Hi, difficult to say what is the issue here. The blue flashing light is from the ESP?

Do you see any packets on the Serial output when you run VanBusDump.ino?

Yes. Blue flashing is from ESP. I will test it, but I don't think the problem is network packets. The version a few months ago was related to the display of indicator icons and lights, it was tested and it worked. Maybe changing the IwIP settings will solve the problem. I will test

0xCAFEDECAF commented 1 year ago

Sure, hope it works out :-)

The LED normally flashes on each packet communicated via the WebSocket. (It also flashes 2 times per second if configured in Wi-Fi "station" (client) mode while connecting to a an Access Point, but I assume you are using the standard Access Point mode (#define WIFI_AP_MODE in Config.h.)

My best lwIP settings are shown here: https://github.com/0xCAFEDECAF/VanLiveConnect#3-board-settings . I am using "v2 Lower Memory (no features)".

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

You may also want to connect the USB serial and see the output after uncommenting the following lines in Config.h:

#define DEBUG_WEBSERVER
#define DEBUG_WEBSOCKET
#define PRINT_RAW_PACKET_DATA
#define PRINT_JSON_BUFFERS_ON_SERIAL
#define SELECTED_PACKETS VAN_PACKETS_SAT_NAV_PKTS
Drsimson commented 1 year ago

Sure, hope it works out :-)

The LED normally flashes on each packet communicated via the WebSocket. (It also flashes 2 times per second if configured in Wi-Fi "station" (client) mode while connecting to a an Access Point, but I assume you are using the standard Access Point mode (#define WIFI_AP_MODE in Config.h.)

My best lwIP settings are shown here: https://github.com/0xCAFEDECAF/VanLiveConnect#3-board-settings . I am using "v2 Lower Memory (no features)".

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

You may also want to connect the USB serial and see the output after uncommenting the following lines in Config.h:

#define DEBUG_WEBSERVER
#define DEBUG_WEBSOCKET
#define PRINT_RAW_PACKET_DATA
#define PRINT_JSON_BUFFERS_ON_SERIAL
#define SELECTED_PACKETS VAN_PACKETS_SAT_NAV_PKTS

https://user-images.githubusercontent.com/113470395/209234134-0e4d4513-8bce-4220-bb5c-3a037a6dbe55.mp4

Wi-Fi performance settings are adjusted according to the instructions . First test and websockets.sendTXT = Fail

Drsimson commented 1 year ago

https://user-images.githubusercontent.com/113470395/209234638-a01d8a51-328d-4533-9376-41a4afd3aee7.mp4

The second test, but again, the information was not displayed in the HTML !!! It's interesting that it works well in my car and I'm really confused!!! //Video speed is 2X faster//

0xCAFEDECAF commented 1 year ago

Your problem is with the WebSocket connection. It is either not working at all, or continuously connecting and disconnecting. Maybe try another browser client, or another device?

If you have a laptop, you can see what is happening in the browser console by pressing F-12.

Drsimson commented 1 year ago

Your problem is with the WebSocket connection. It is either not working at all, or continuously connecting and disconnecting. Maybe try another browser client, or another device?

If you have a laptop, you can see what is happening in the browser console by pressing F-12.

I use one device and one browser in two cars. One works and the other does not

0xCAFEDECAF commented 1 year ago

I use one device and one browser in two cars. One works and the other does not

That is really strange... I would still advise to try with another browser or device.

Drsimson commented 1 year ago

Hello, sir . After some time, I returned to your project. I retested commit 9907a76. Everything works well, but the last commit still has the above problems that I sent you in the video. Which file do you think I should start with for troubleshooting?

0xCAFEDECAF commented 1 year ago

Looking carefully at the second video, I see some strange characters for the "vin" number in in the JSON object (around 0:02). It could be that it causes the client browser to disconnect while it parses this invalid JSON data.

Could you try to comment out the if-statement on lines 5201...04 in PacketToJson.ino ? That might help.