# Very No0b and very confused - esp32 emulating CAN

**URL:** <https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166>\
**Category:** General Discussion\
**Created:** [April 26, 2025, 12:57pm UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166 "2025-04-26T12:57:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![willsspam](https://forum.realdash.net/letter_avatar_proxy/v4/letter/w/db5fbb/32.png) [@willsspam](https://forum.realdash.net/u/willsspam)\
**Post date:** [April 26, 2025, 12:57pm UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166/1 "2025-04-26T12:57:41Z")

</div>

Hi there, I’ve tried reading documentation and I don’t seem to be able to find a no0b primer on this software.  
The goal is putting this in my 68 cutlass to read sensors and send them to RealDash via Holley Sniper 2 CAN. Reason is, and maybe this is dumb, I plan on putting a Sniper2 on the car in the future and would like to merge the data?!?! Anyhow, that’s my thought process. I’ve tried this in other CAN formats too like generic GM and I still seem to be missing something huge, because I can get CAN data into the CAN Monitor but I have never been able to get any of the gauges to act upon said data.

I am using a Raspberry PI with the carhat/Linux for RealDash, version 2.5.0  
esp32 dev board with MCP2515 module.  
SocketCAN / can0 with the “HOLLEY: SNIPER V2” CAN Description file.

I’ve used chat GPT to check/refine the code, pulling from existing examples. I would have thought that if I got data into the CAN Monitor I’d be half way there. I keep seeing references to edit the .XML file but any time I do, the file reverts back to its original state. I’ve even tried editing before RealDash had a change to load and it still reverts?

I’m a linux no0b too so, I got that going against me as well.. getting the description file from the file selector window was a treat since no matter what resolution the left side of the screen is off to the left with no way to resize the selector screen, btw – but whatever, got the holley stuff imported it seems.

 ![image](https://forum.realdash.net/uploads/default/original/2X/b/bf76474614c834637d86a80bf557e09610427d09.png)  
 ![image](https://forum.realdash.net/uploads/default/original/2X/2/27336690ef65cff34940b7de25fdf971cfb772b0.png)  
 ![image](https://forum.realdash.net/uploads/default/original/2X/f/f91d8c382bc4f2674077887b55edee4f1cc82354.png)

#include \<SPI.h\>  
#include \<mcp\_can.h\>  
#include \<Wire.h\>  
#include \<TinyGPSPlus.h\>  
#include \<HardwareSerial.h\>  
#include \<OneWire.h\>  
#include \<DallasTemperature.h\>

// Pin configuration  
#define ONE\_WIRE\_PIN 36  
#define INT\_PIN 4  
#define VSPI\_CS\_PIN 5  
#define VSPI\_SCLK\_PIN 18  
#define VSPI\_MISO\_PIN 19  
#define VSPI\_MOSI\_PIN 23  
#define TACH\_PIN 26  
#define BATT\_VOLTS\_PIN 27  
#define OIL\_PRESS\_PIN 32  
#define FUEL\_LEVEL\_PIN 34  
#define COOLANT\_TEMP\_PIN 35  
#define GPS\_RX\_PIN 17  
#define GPS\_TX\_PIN 16

// Generic ECU serial number  
const uint16\_t ECU\_SERIAL = 0x0123;

MCP\_CAN CAN(VSPI\_CS\_PIN);  
HardwareSerial GPS\_Serial(1);  
TinyGPSPlus gps;  
OneWire oneWire(ONE\_WIRE\_PIN);  
DallasTemperature sensors(&oneWire);

unsigned long lastSend = 0;  
const unsigned long sendInterval = 100; // 100ms between sends

void setup() {  
Serial.begin(115200);  
GPS\_Serial.begin(9600, SERIAL\_8N1, GPS\_RX\_PIN, GPS\_TX\_PIN);  
sensors.begin();

pinMode(TACH\_PIN, INPUT\_PULLUP); // (optional if not using real tach)

while (CAN\_OK != CAN.begin(MCP\_ANY, CAN\_500KBPS, MCP\_8MHZ)) {  
Serial.println(“CAN BUS init Failed”);  
delay(100);  
}  
Serial.println(“CAN BUS Shield init OK!”);  
CAN.setMode(MCP\_NORMAL);  
}

void loop() {  
while (GPS\_Serial.available()) {  
gps.encode(GPS\_Serial.read());  
}

if (millis() - lastSend \> sendInterval) {  
lastSend = millis();

```
float GPSSPEED = gps.speed.kmph();
int currentRPM = simulateRPM();
float battVoltage = simulateBattVoltage();
float oilPressure = simulateOilPressure();
float coolantTemp = simulateCoolantTemp();
float fuelLevel = simulateFuelLevel();
sensors.requestTemperatures();
float DTemp = sensors.getTempCByIndex(0);

// Output to Serial for debugging
Serial.println("=== Sending CAN Data ===");
Serial.print("GPS Speed : "); Serial.println(GPSSPEED);
Serial.print("RPM : "); Serial.println(currentRPM);
Serial.print("Battery Voltage: "); Serial.println(battVoltage);
Serial.print("Oil Pressure : "); Serial.println(oilPressure);
Serial.print("Coolant Temp : "); Serial.println(coolantTemp);
Serial.print("Fuel Level : "); Serial.println(fuelLevel);
Serial.print("Dallas Temp : "); Serial.println(DTemp);

// Send sensor data over CAN
sendHolleyCAN(0x1E001023, currentRPM, 60.0); // Engine RPM
sendHolleyCAN(0x1E001028, GPSSPEED, 1.0); // Vehicle Speed
sendHolleyCAN(0x1E00102A, oilPressure, 1.0); // Oil Pressure
sendHolleyCAN(0x1E00102C, coolantTemp, 1.0); // Coolant Temperature
sendHolleyCAN(0x1E00102E, battVoltage, 0.1); // Battery Voltage (scale to 0.1V)
sendHolleyCAN(0x1E001034, fuelLevel, 1.0); // Fuel Level
sendHolleyCAN(0x1E00103A, DTemp, 1.0); // Dallas sensor as another temp

// Send Heartbeat (fixed ID!)
byte heartbeat[8] = {0};
CAN.sendMsgBuf(0x1E000000, 0, 8, heartbeat); // No ECU_SERIAL offset

```

}  
}

// Holley-style CAN frame sender with serial number offset  
void sendHolleyCAN(uint32\_t baseId, float value, float scale) {  
byte data[8] = {0xFF}; // Fill with 0xFF (optional, improves realism)  
uint16\_t scaled = (uint16\_t)(value / scale);  
data[0] = scaled & 0xFF; // little endian  
data[1] = (scaled \>\> 8) & 0xFF;  
uint32\_t actualId = baseId + (ECU\_SERIAL & 0x7FF);  
CAN.sendMsgBuf(actualId, 0, 8, data);

// Debug output  
Serial.print(“Sending ID: 0x”);  
Serial.print(actualId, HEX);  
Serial.print(" Data: “);  
for (int i = 0; i \< 8; i++) {  
Serial.print(data[i], HEX);  
Serial.print(” ");  
}  
Serial.println();  
}

// Simulated sensor reading functions for testing  
float simulateBattVoltage() {  
return 13.5 + random(-5, 6) \* 0.1; // Simulate 13.0-14.0V  
}

float simulateOilPressure() {  
return 110 + random(-10, 11); // Simulate around 100-120 psi  
}

float simulateCoolantTemp() {  
return 90 + random(-5, 6); // Simulate around 85-95 C  
}

float simulateFuelLevel() {  
return 70 + random(-5, 6); // Simulate around 65-75%  
}

int simulateRPM() {  
return 3400 + random(-200, 201); // Simulate around 3200-3600 RPM  
}

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [April 28, 2025, 11:29am UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166/2 "2025-04-28T11:29:39Z")

</div>

Very complicated setup to try to help remotely.

But in general, if you see the data in CAN monitor, the missing piece must be the CAN XML file. Try to make a XML file that only handles one frame to verify that its working. Then gradually add frames as you get more comfortable on working on the XML file.

---

<div class="post-metadata">

**Author:** ![willsspam](https://forum.realdash.net/letter_avatar_proxy/v4/letter/w/db5fbb/32.png) [@willsspam](https://forum.realdash.net/u/willsspam)\
**Post date:** [April 28, 2025, 11:22pm UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166/3 "2025-04-28T23:22:31Z")

</div>

> [@realdashdev](#):
>
> CAN XML

Do you mean the ones here?

 ![image](https://forum.realdash.net/uploads/default/original/2X/2/2b67b2084e1f942f8cb7a9076b041cd38e5fca80.png)

Because the custom car I’m using, every time I alter the file, it reverts back to its basic settings. if there is a CAN XML doc somewhere else, to my chagrin, I dont know where it is

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [April 29, 2025, 5:56am UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166/4 "2025-04-29T05:56:28Z")

</div>

CAN XML documentation:

[RealDash-extras/RealDash-CAN/realdash-can-description-file.md at master · janimm/RealDash-extras](https://github.com/janimm/RealDash-extras/blob/master/RealDash-CAN/realdash-can-description-file.md)

If you are working with local files, yes when you edit the XML file it needs to be re-imported into connection settings. Current Android devices do not allow direct access to user filesystem, and files must be imported to apps own ‘sandbox’ before they can be used.

Currently most efficient way is to use My RealDash service ([my.realdash.net](http://my.realdash.net)), which has XML editor and RealDash can then import the XML file from My RealDash on connection settings.

---

<div class="post-metadata">

**Author:** ![willsspam](https://forum.realdash.net/letter_avatar_proxy/v4/letter/w/db5fbb/32.png) [@willsspam](https://forum.realdash.net/u/willsspam)\
**Post date:** [June 29, 2025, 12:53pm UTC](https://forum.realdash.net/t/very-no0b-and-very-confused-esp32-emulating-can/8166/5 "2025-06-29T12:53:07Z")

</div>

ok, I’ve played around a little bit more and made some progress. I can get most of the values im interested in with bluetooth now. however, when I use the GM “channel description” I can see my fuel level but not oil pressure. its the opposite with SAE… how do I get both!!!
