Home

Awesome

RejsaCAN

RejsaCAN is a 3x5 centimetre small ESP32 or ESP32-S3 based board aimed at car use that I put together for my own use in my assorted crazy car projects. The board has an onboard CAN interface and can be powered directly from the car (5-24V). It also includes the option to auto shutdown so not to drain the car battery. This is especially important if you have it plugged in to a car OBD2 connector since these always supply constant 12V power to the connector, even when the car is parked and turned off.

There is no bespoke code for the board apart from pin definitions, it's just a piece of universal hardware, but by using easy to use open source Arduino libraries it can be made to interface not only to various CAN buses, Network/Wifi and Bluetooth but to numerous sensors and other peripherals using the ESP32's built in interfaces.

You can assemble your own board if you want, you find schematics, Gerber files and bill of materials in the <a href=Schematics>schematics folder</a>. I currently don't make any boards but if you need factory assembled boards in quantitites you can always contact me at magnust@gmail.com and we can discuss and see.

Nice review and get started guide at cnx-software

https://www.cnx-software.com/2023/05/12/rejsacan-esp32-s3-can-bus-board-arduino-car-hacking/

Navigate

<hr>

IMG_20221009_144837

Pinout

See complete pinout.h

ESP32 https://github.com/MagnusThome/RejsaCAN-ESP32/blob/main/v2.4%20pinout.h
ESP32-S3 https://github.com/MagnusThome/RejsaCAN-ESP32/blob/main/v3.2%20pinout.h

S3 rear

Schematics

click to get full schematics

<a href=https://github.com/MagnusThome/RejsaCAN-ESP32/tree/main/Schematics><img src=https://github.com/MagnusThome/RejsaCAN-ESP32/assets/32169384/1679f1cd-1905-4c42-a11c-f8b68e32965e></a>

The board is based around an ESP32 or ESP32-S3 chip

The ESP3232-S3 is a very nice and capable chip that supports a mind boggling range of different communication standards and hardware auxiliaries making it a very versatile "hub" for shuffling data between different systems.

Examples

Ideas for peripherals

<a target=_blank href=https://github.com/MagnusThome/RejsaRubberTrac><img align=right width=50% src=https://user-images.githubusercontent.com/32169384/195158064-2a3aa449-2554-4737-a2f2-7ac039983e5e.png></a>

One of the 3D printed housings with OBD2 connector I've made

IMG_20211116_203136

Or just the board and screw terminals

IMG_20211116_202642

CAN interface

You can hook the board up straight to the car's OBD2 port or attach it directly to any CAN bus. You just need to connect the four wires. 12V power, ground, CAN high and low. There is of course a bus termination resistor on the board, it can be disabled if not needed by cutting a pcb trace and optionally mounting a pin header and jumper.

Functionality

The idea was to make an as small as possible CAN + ESP32 board with as many cool and useful "good to have" functions as possible included. You know as well as I do that when tinkering around you suddenly get a new idea and need x or y :-D

Auto shutdown

When the engine is running and charging the car battery the incoming voltage used to power the board is a little bit higher than when the engine is stopped. This can be used to automate board shutdown so not to drain the car battery. As default the on board DC-DC power circuit will shutdown the whole board when the power voltage is below the "engine is running" threshold and boot up the board when it is above. But you can run the board in a number of other ways too, for example using ESP32 sleep mode, waking it and putting it to sleep depending on CAN traffic, voltage level from the car, delays and so on.

Either one can just let the board turn on and off with the auto shutdown hardware circuitry straight out of the box or you can run it in combination with software. For example, when the car voltage rises and the board boots you can pull FORCE_ON high to make sure the board keeps running even if there is a drop of voltage, for example due to red light start/stop functionality in the car or modern cars turning down battery charging even when driving. Then you just monitor either the threshold with SENSE_V_DIG or set your own thresholds using SENSE_V_ANA and then add your own timer delays or whatever. And of course, you can use CAN to check if the car is stopped in a multitude of ways, rpm, speed, gear...

Fine tuning on/off voltage thresholds

If your car has a more modern battery type than the old acid/led type or if it does the battery charging slightly different you might want to adjust the on/off voltage thresholds. If you keep R5 as 33k and adjust R4 you can get these switch-on and -off voltages:

R4Turn on atTurn off at
91k13,7V13,0V
90k13,6V12,9V
89k13,5V12,8V
88k13,4V12,7V
87k14,3V12,6V
86k13,2V12,5V
85k13,1V12,4V

24V vehicles

For 24V vehicles you can change the on/off voltage threshold by soldering on a resistor at the empty "ADJUST" position. I don't know what voltages one can expect in these vehicles while charging and not charging the battery so I have no idea what an appropriate resistor value should be there.

matrix power scenarios

"Good to haves"

Three on board LEDs

Extra UART RX/TX

The ESP32-S3 has a built in USB port for uploading firmware, OTG support(!) and general communication. But on the board's rear there are breakout pads for a second UART (TXD0 and RXD0) so you can use this as a serial port and the board's USB port for other tasks like JTAG or OTG, acting as a peripheral keyboard, mouse, wireless storage and so on.

3V3 HIGH DRIVER

The GPIO pins on the ESP32-S3 can, in addition to general digital circuitry, also drive 10-20mA loads like LEDs and other smaller loads. But on the RejsaCAN board there is an added more powerful driver circuit that can drive slightly larger loads of a few hundred mA at 3,3V. This can be used for different things like powering external sensors or a small display that you want to be able to shutdown fully to minimize power consumption while in sleep mode for example. This 3V3_SWITCHED output is controlled by HI_DRIVER (GPIO21). The ESP32-S3 can keep this on or off when in sleep mode.

There is also a 3,3V power output pad in the row of connection pads on the board that is turned on whenever the board is running. Keep in mind that this is not a 3V3 input to drive the board, it is only an output to drive external I2C, SPI and other sensors.

SD card reader

The ESP32-S3 has an SD micro card reader on the rear of the pcb. It is connected to SPI and select SD_CARD (GPIO45)

Other general IO pins

All the GPIOs found on the row of connector pads are general purpose. They can be PWM, analog, digital in/out whatever, special protocols driving or reading most things you can think of. But for ease of use for me with occasional lousy memory I have marked some default uses:

I2C SDA (GPIO1) (A0)
I2C SCL (GPIO2) (A1)
GND
3V3

SPI MISO / MTDI (GPIO41)
SPI CLK / MTCK (GPIO39)
SPI MOSI / MTDO (GPIO40)

General (GPIO12)
General (GPIO48)
General (GPIO47)
High driver switched output max 500mA (GPIO21)

On the rear side of the pcb you can get to a few extra pins but it's not possible to solder pin headers here due to the esp-module being on the other side of the board where these pads are.

General (GPIO6) (A5)
General (GPIO7) (A6)
General (GPIO15)
General (GPIO16)
MTMS (GPIO42)
PROG (GPIO0)
JTAG_ENABLE (GPIO3)
TXD0
RXD0

CAN bus

As mentioned earlier the CAN_RX (GPIO13) can wake the ESP32-S3 from sleep whenever any traffic is seen on the CAN bus.

To minimize power draw when not using the CAN bus, for example not listening to the bus to detect traffic to wake the ESP32 from sleep mode, the CAN transceiver can be put in standby mode by pulling CAN_RS (GPIO38) high. The ESP32-S3 can keep this pin high even when in sleep mode reducing the complete boards power draw to an absolute minimum.

The rise time of the CAN transceiver chip can be changed pulling CAN_RS (GPIO38) low. Default is keeping the pin unmodified in high impedance state for an optimal not-to-fast rise time setting. See specs for the transceiver chip SN65HVD230DR.

JTAG

You can either run JTAG over the USB port or optionally keep the USB port free by connecting your JTAG hardware to MTDI, MTDO, MTCK and MTMS on the board. Note that MTMS is only available on the board's rear. The other are available in the row of connecting pads. Incidentally the MTDI, MTDO and MTCK are the same as the SPI default pins.

To enable JTAG mode you need to pull the JTAG_ENABLE pad, found on the rear of the board, high or low at boot.

Board version

On v3.x boards you can programmatically check what version of the board your code is running on and adjust accordingly for the small changes that have been made on the boards. Set GPIO4 and GPIO5 to input pullup and check if the inputs are high or low.

Changes

from v3.1 to v3.2

From v2.3 to v.2.4

From v2.4 to v.2.5 and 3.2 to 3.3

Power consumption

At 14V the complete board draws on average roughly:

Housing

Check out 3D printable housings in the <a href=3dprint>the 3D-print directory</a>. So far I've made one housing where you connect using a cable and another one with an integrated OBD2 connector to plug directly into the car.

4

transparent-case-1

small-housing(0)

IMG_20230926_152918

Connecting the board

When not using the housing with an integrated OBD2 connector or the screw terminals as seen in the picture above I've used a widely available OBD2 splitter cable (flat cable) that has one male and two female connectors. I hook up the male connector to the car, cut off one female connector and wire the remaining pig tail cable into the RejsaCAN board and one female connector is then free for other equipment to hook up to the car.

Picture showing what wires to use but please measure your cable and don't trust all these splitter cables to be 100% identical. (the second female splitter connector is not visible in pic)

OBD2 splitter pinout

small-housing(3)

small-housing(2)