B4R Tutorial PS4 F1 2020 Interfacing using ESP8266

Cableguy

Expert
Licensed User
1 - INTRODUCTION

Hi Guys,

My wife's eldest son is addicted to PS4 F1 2020 game, even bought himself a Rig for a Steering Wheel and Pedals.
He works alongside with me and on one of our lunch breaks, he mentioned an add-on display for his steering wheel, that would need some re-working of his existing steering wheel, and costed about 150$.
1612376881200.png


So, after a quick search for this subject in the forum, I came across an OLD @DonManfred thread about this exact theme, I was sure it could be done, but had no clue where to start...

So I started this Chit-Chat Thread and soon came the firsts progress...

Sooooo....

This thread is to be a Journal of my "journey" into creating a "PS4 F1 2020 Telemetry Steering Wheel Display"

The goal will be something that optfully will look somewhat like...

1612378415503.png



The Parts that will be used to achieve this are :

ESP8266 Wemos D1 board

1612377521793.png

2.8" NEXTION DISPLAY
1612377634549.png



This Journal will be made of 5 parts:

1- Introduction of the project (This Post)
2 - Code development
3 - Electronics
4 - Graphics
5 - Putting all Together... maybe even creating a Franken-Steering-Wheel using 3D printed parts.

This Project is now a team effort:
@avalle
@Daestrum
@Cableguy

So if these kind of things interests you, keep posted...
 
Last edited:

Cableguy

Expert
Licensed User
2 - CODE DEVELOPMENT

The UDP data structure can be found here:
F1 2020 UDP Specification - Technical Assistance - Codemasters Community

The part I am most interested in is car telemetry.

As suggested by @avalle, I first started with a very basic B4J test app, just to confirm that I could sniff those UDP packets.

This first test was successfull, so I can now test further.

1612378883326.png


@avalle was able to get a Data.dump and then to analyse it and found that the outcomming structure is as follows (real data from game)
B4X:
Packet header (total: 24 bytes)
-----------------------------------------------
struct PacketHeader
{
    uint16    m_packetFormat;             // 0xE407 (2020)
    uint8     m_gameMajorVersion;         // 0x01
    uint8     m_gameMinorVersion;         // 0x0F
    uint8     m_packetVersion;            // 0x01
    uint8     m_packetId;                 // Packet type (0 to 9)
    uint64    m_sessionUID;               // 0x E3 68 86 A5 E9 41 2E 73
    float     m_sessionTime;              // 0x 91 3B 98 43  =>  304.465362548828125  05'04.465
    uint32    m_frameIdentifier;          // 0x 78 0D 00 00
    uint8     m_playerCarIndex;           // 0x15  =>  21
    uint8     m_secondaryPlayerCarIndex;  // 0xFF (no second player)
};

Search header for a new Car telemetry packet: 0xE407010F0106
Found at offset: 3233 8770 15776 21313 26850 33658 etc.

Car telemetry packet sample (offset: 3233):
-----------------------------------------------
struct PacketCarTelemetryData                   // total: 1307 bytes
{
    PacketHeader        m_header;                  // Header

    CarTelemetryData    m_carTelemetryData[22];    // 22 cars => 22x58 = 1276 bytes

    uint32              m_buttonStatus;        // 0x00000000  =>  No button pressed
    uint8               m_mfdPanelIndex;       // 0xFF  =>  MFD panel closed
    uint8               m_mfdPanelIndexSecondaryPlayer;   // 0xFF  =>  MFD panel closed
    int8                m_suggestedGear;       // 0x00  =>  no gear suggested
};

struct CarTelemetryData                           // total: 58 bytes
{
    uint16    m_speed;                         // 0x0000
    float     m_throttle;                      // 0x00000000
    float     m_steer;                         // 0x00000080  =>  -0.0
    float     m_brake;                         // 0x00000000
    uint8     m_clutch;                        // 0x00
    int8      m_gear;                          // 0x00  =>  N
    uint16    m_engineRPM;                     // 0x B6 0D  =>  3510
    uint8     m_drs;                           // 0x00  =>  Off
    uint8     m_revLightsPercent;              // 0x00  =>  0%
    uint16    m_brakesTemperature[4];          // 0x 23 00 (x4)  =>  35°C
    uint8     m_tyresSurfaceTemperature[4];    // 0x37 0x37 0x47 0x47  ==> 55°C / 71°C
    uint8     m_tyresInnerTemperature[4];      // 0x37 0x37 0x55 0x55  ==> 55°C / 85°C
    uint16    m_engineTemperature;             // 0x 5A 00  =>  90°C
    float     m_tyresPressure[4];              // 0x 00 00 AC 41 (x2)  0x 00 00 B8 41 (x2)  =>  21.5 PSI / 23.0 PSI
    uint8     m_surfaceType[4];                // 0x00 (x4)
};
So now we will start, step by step, bringing this to life....
 
Last edited:

Cableguy

Expert
Licensed User
4 - GRAPHICS

I have taken on me the Graphical interface, and started "sketching" things up in Paint.net before tansposing to the Nextion Editor...
This is what I have so far... (built from scratch)

1612464923223.png


After a quick brainstorming with "the client", we decided for a simplistic version...

Nextion.png


And even this has proven to be too much... (actually, some decisions were made based on the fact that my Nextion display can't reproduce fonts smaller than size 16)
SO, the car tyre section is for now discarted, and the DRS on screen presence is still under discussion..

Working with the Nextion is not as easy as one expects, but not as difficult as one fears.

I set the background of Page0 with this image...

1612628509966.png


And after all is placed in the right positions...

1612628587097.png


This is now in alpha version... The final version shouldn't be too different from this...
Comments or suggestions will be welcomed.
 
Last edited:

Toley

Active Member
Licensed User
Why not putting it on an Android phone/tablet interface? You could even generate ads incomes from it!
 

Cableguy

Expert
Licensed User
Why not putting it on an Android phone/tablet interface? You could even generate ads incomes from it!
simply because, there are already plenty of phone based solutions, and the purpose of this is to prove it can be done with B4R... and a lot cheaper than any comercial solution.
A phone based solution would also mean a dedicated phone would be needed, and this is not an option for me.
 

dariosxx81

New Member
Hi
i have a NEXTION interface with a dash for F12018.
I was only given the TPL part (template) and I wanted to understand how to update and program a new one starting from a base.

BUT you can have the project here to understand how to do it?
The NEXTION comes with an ESP and from the display septum the WIFI.
I also have an old example with an .ino file where you set SSID and PASS but I didn't understand how to connect the display?

can you help me? is there any way to see this project?
 

dariosxx81

New Member
Hi
i have a NEXTION interface with a dash for F12018.
I was only given the TPL part (template) and I wanted to understand how to update and program a new one starting from a base.

BUT you can have the project here to understand how to do it?
The NEXTION comes with an ESP and from the display septum the WIFI.
I also have an old example with an .ino file where you set SSID and PASS but I didn't understand how to connect the display?

can you help me? is there any way to see this project?
@Cableguy help me
 

Cableguy

Expert
Licensed User
Hi @dariosxx81,

The software part is still on drawing board, mainly due to the lack of time. I hope to get back to this very very soon.
I promise a full disclosure of the code is my partners in this project are OK with it.
 

elvlacho

New Member
Hello, I´m interested in doing the same, it seems really cool.
The problem is that I dont´t know anything about Arduino and how to connect it with ps4, I only have little knowledge about python.
Did you manage to finish it?

Regards
 
Top