
ESP32CanBoard
ieb/CanDiagnose
Small firmware to run on an ESP32 and diagnose devices and messages on a canbus.

Small firmware to run on an ESP32 and diagnose devices and messages on a canbus.
BatteryMonitor is an open-source printed circuit board by ieb, from the ieb/CanDiagnose repository on GitHub. It is a 2-layer board of 102.8 × 42 mm with 28 parts on 22 nets, routed with 272 tracks and 15 vias.
It is built around the MAX3485ED, MAX9918ASA+ and AMS1117. Its parts include 9 resistors, 7 capacitors, 7 connectors and 5 ICs. It belongs with the interfaces and adapters boards and the AVR (ATmega, ATtiny) boards of this library.
Runs on a ESP32 with a webserver exposing an API to diagnose and monitor CanBus traffic. Based on Datadisplay and DeviceAnalyser from the NMEA2000 libraries.
The ESP32 ADC source cannot be made reliable enough or accurate enough to be used to monitor a battery. It is possible to get down to a 0.2% error with a callibrated lookup table, however the ADC mechamism (Sucessive Aproximation Register) produced noisy values that are frequetly as much as +- 3%. At 12.6v this is 0.4v which is unworkable. Offsetting the voltage with a precision opamp so the ESP32 reads from 11 to 15v would reduce this to 0.15v, however this is still to large to be usable. Multi sampling helps generate a stable reading, however this requires 64 samples with a /5 moving average so over at least 60s. This does give and acceptable accuracy, but the speed of measuring the voltage is close to unworkable.
All attenuations were tried, and 1,2,4,16,32,64 clock divisions were tried to see if the rate of the SAR made any difference. It does not appear to change the results.
On that basis, I am giving up on using the ESP32 ADC for this purpose.
It still provides a good platform for a Wifi data server, and Can reader.
The device will boot and connect to wifi controlled by its burned in config file (data/config.txt). There are 2 modes it can run in, a WiFi client or a AP. If its configured to be an AP, then join its network. If its a client find its ip. From now on this will be
Go to its ip on http:// and you will see a data view of the data it is capturing. Go to http:///admin.html and you will see a admin view with the ability to upload a new configuration file and reboot.
Both these views ae SPAs served from static files burned into the ESP32 Flash using APIs.
Connecting to the serial port monitor allows lower level control and diagnostics, enter 'h' to get help.
Project uses PlatformIO in VSCode. WebUI is in ui/einkweb with build files added to data/ to be built into a flash image using ./buidui.sh
because I alwaysforget.
See buildui.sh for SPIFFS image commands.
---------------------------------------------
| a b c d e f g h |
| A |
| B |
| C |
| D H |
| E I |
| F J |
| G i j k l m K |
---------------------------------------------
a SPI BL GPIO13
b SPI RST GPIO12
c SPI DC GPIO26
d SPI CS GPIO25
e SPI SCK GPIO33
f SPI MOSI GPIO32
g SPI GND
h SPI 3V
i i2c GND Display black/blue
j i2c SCL D5 Display green
k i2c SDA D18 Display white
l i2c BTN D19 Display yellow
m i2c 3V Display redThis uses SPI output only with a bunch of additional pins.
eInk DIN <- f SPI MOSI GPIO32
eInk CLK <- e SPI SCK GPIO33
eInk CS <- d SPI CS GPIO25
eInk DC <- c SPI DC GPIO26
eInk RST <- b SPI RST GPIO12
eInk BUSY -> a SPI BL GPIO13uses SPI + a PWM blacklight. Control via a TPP233 Touch switch. Library is TFT_eSPI library. Pin mappings defined as compile definitions.
-D TFT_MISO=GPIO_NUM_35
-D TFT_MOSI=GPIO_NUM_32
-D TFT_SCLK=GPIO_NUM_33
-D TFT_CS=GPIO_NUM_25
-D TFT_DC=GPIO_NUM_26
-D TFT_RST=GPIO_NUM_27
-D TFT_PWM_BL=GPIO_NUM_14
-D ILI9488_DRIVERThe display sleeps after 60s of inactivity to reduce power drain, but turning off the backlight. Sleeping the IMI9488 driver has not been done as of yet. Pages are implemented as classes using widgets. When a page is selected it is allocated into heap and does not exist while not displaying. On other drivers here all pages were compiled in, however the RAM usage is higher on account of full colour and display size.
In most cases attempts to update the screen, on screen causes flickering so double buffering of updates is done using sprits with DMA transfers from the sprite to the screen. Images for screen are stored in jpg on flash, consuming about 30KB per screen.
Drawing to sprites also works in 1bpp, 4bpp or 16bpp.
3d printed case, with 2 touch sensors and round shielded cable, as ribbon will emit too much interference to nearby devices.
Wires
| Red | 5v | 5v | | black | 0v | 0v | | pink | CS | GPIO_NUM_25 | | cyan | Reset | GPIO_NUM_27 | | white | DC/RS | GPIO_NUM_26 | | blue | SDI(MOSI) | GPIO_NUM_32 | | green | SCK | GPIO_NUM_33 | | grey | LED | GPIO_NUM_14 | | Purple | SDO(MISO) | GPIO_NUM_35 | | Orange | 3.3v | 3.3v | | Brown | Touch Lower | GPIO_NUM_19 | | Yellow | Touch Top | TBD |
Due to the additional touch pins a fresh PCB is probably needed.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 6 | R | Resistors_SMD:R_0805 | R102, R103, R105, R106, R107, R108 |
| 3 | 100nF | Capacitors_SMD:C_0805 | C104, C105, C106 |
| 3 | RS+ | Connect:1pin | P103, P106, P107 |
| 2 | 100K | Resistors_SMD:R_0805 | R109, R110 |
| 2 | 10uF | Capacitors_SMD:C_1206 | C101, C103 |
| 2 | CONN_4 | Connect:bornier4 | P101, P102 |
| 2 | MAX9918 | Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm | U102, U103 |
| 1 | 1nF | Capacitors_SMD:C_0805 | C107 |
| 1 | 4K7 | Resistors_SMD:R_0805 | R104 |
| 1 | AMS1117 | TO_SOT_Packages_SMD:SOT-223-3Lead_TabPin2 | U101 |
| 1 | ATTINY84-S | Housings_DIP:DIP-14_W7.62mm | IC103 |
| 1 | C | Capacitors_SMD:C_0805 | C108 |
| 1 | ICSP/UDPI | Pin_Headers:Pin_Header_Straight_2x03 | P104 |
| 1 | MAX3485E | Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm | IC101 |
| 1 | RS- | Connect:1pin | P105 |

ieb/CanDiagnose
Small firmware to run on an ESP32 and diagnose devices and messages on a canbus.

ieb/BatterySensor
A Modbus RTU Battery Current and Voltage sensor board based Attiny3224, MAX485, MAX9918 chips.

klaus-liebler/sensact
Es gibt vier Namespaces für Nachrichten "REQUEST" und "RESPONSE", "EVENT" und "ACKNOWLEDGE". Dies wird mit den beiden LSB des Versions-Namespace-Bytes erklärt (Somit bleiben 64 Versionierungsmöglichkeiten) Alle vier…

anyshake/explorer
🌏 Detecting seismic wave using 3 geophones and 3-axis accelerometer, pack & send data to AnyShake Observer over RS232 / RS485 serial.

hirakuni45/RX
Renesas RX Microcontroller, C++ framework, Library, Sample


emertcakir/OpenAirScope
Open-source air quality and environmental monitoring node with STM32H743 + ESP32-C3, LoRaWAN, RS485, USB-C, Li-ion charging, and multi-sensor support.


rmingon/rs485-spy-injector
RS485 Spy is an open-source hardware tool for real-time monitoring, logging, and testing of RS-485 networks
It measures 102.8 × 42 mm and has 2 copper layers, 1.6 mm thick.
28 parts, built around the MAX3485ED, MAX9918ASA+ and AMS1117. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the ieb/CanDiagnose repository on GitHub, at the commit this page was made from: the board is pcb/BatteryMonitor/BatteryMonitor.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask ieb before reusing the design.