Skip to content

VAN bus writer library using the ULP coprocessor of the ESP32

License

Notifications You must be signed in to change notification settings

morcibacsi/esp32_ulp_van_tx

Repository files navigation

ESP32 ULP Vehicle Area Network (VAN bus) writer

Arduino VAN bus writer library utilizing the ESP32 ULP coprocessor. The aim of this library is to provide a software based solution to safely write to the VAN bus without a TSS463 or a TSS461 IC. Eventually these are going to be hard to obtain and the only option will be salvaging them from a used radio or BSI.

Features

  • Support for 125kbps bus (VAN COMFORT bus)
  • Bus arbitration logic to safely write on the bus
  • Sending "normal" type frames and "reply request" frames

TODO

  • Support for 62.5kbps bus (VAN BODY bus)
  • Support to reply ACK for frames
  • Support in-frame reply frames

Not planned

There is no plan to extend the library to read the VAN bus. For that you can use my VAN bus reader library using the RMT peripheral. You can use both libraries using the same rx pin.

Schematics

The schematics below can be used to connect to a VAN bus. The SN65HVD230 is a CAN bus transceiver. You can use other CAN bus transceivers as well. Some examples: MCP2551, TJA1042, TJA1050, TJA1051, TJA1052. Note that some of these are 5V devices therefore a logic level converter to 3.3V should be used.

schema

Arduino

Copy the following files to your documents\Arduino\libraries\esp32_ulp_van_tx folder

  • UlpVanTx.cpp
  • UlpVanTx.h
  • keywords.txt
  • library.properties

PlatformIO

Although it is an Arduino library I strongly recommend to use PlatformIO as it makes it possible to define the used libraries and the used framework locked to specific versions. This ensures that you are using the same versions I used while I was testing. I included my platformio.ini for convenience.

Check the esp32_ulp_van_example folder for an example

Example code

#include "UlpVanTx.h"

// Pins used for RX and TX must be in the RTC domain.
// Input/output : 0,2,4,12,13,14,15,25,26,27,32,33
// Input only   : 34,35,36,37,38,39

#define VAN_RX_PIN GPIO_NUM_33
#define VAN_TX_PIN GPIO_NUM_32

UlpVanTx* ulpVanTx;

ulpVanTx = new UlpVanTx(VAN_RX_PIN, VAN_TX_PIN, ULP_VAN_125KBPS);

// Send a normal frame
uint8_t packet[7] = { 0x0F, 0x07, 0x81, 0x1D, 0xA4 ,0x93, 0x56 };
ulpVanTx->SendNormalFrame(0x8A4, packet, sizeof(packet), false);

// Send a query type frame
ulpVanTx->SendReplyRequestFrame(0x564);

Used library

  • HULP - a helper library for the ESP32's Ultra Low Power Co-Processor (ULP)

Thanks

A HUGE thanks goes to @boarchuz the author of the HULP library, without his help this wouldn't have been possible.

See also