1 / 3
Gauge for Assetto Corsa — zdjęcie 1
1 / 3

Gauge for Assetto Corsa

Zamów wydruk tego modelu

Obliczymy ostateczną cenę na podstawie wybranego pliku. Sprawdzisz ją i zaakceptujesz przed płatnością.

Zapisane na tym urządzeniu.

its a gauge for Assetto Corsa, Utilizes Sim Hub, I have the code for the Arduino but not for sim hub. (code below)

Ocena
0 / 5
Polubienia
1
Pobrania
0
Wydruki
0
Wyświetlenia
3
Oceny
0

Aktualizacja u źródła:

Informacje o modelu

Źródło
Printables
Kategoria
Video Games
Licencja
Creative Commons — Attribution — Noncommercial — Share Alike

Components

Component

Details

Microcontroller

Arduino Uno

Display

GME12864-11-12-13 V3.6, 4-pin OLED display

RPM gauge

Servo motor with a pointer, covering 0–9000 RPM

Shift light

Red LED, activates at 8500 RPM

Engine warning light

Yellow/orange LED, activates when RPM exceeds 7000 for 5 seconds in the later version

Resistors

Two 1 kΩ resistors, one for each LED

Connections

Breadboard and jumper wires

USB connection

Connects the Arduino Uno to the computer

Software and programming

  • Arduino IDE 1.8.19 — used to write and upload the Arduino code.

  • SimHub — sent live racing telemetry from the simulator to the Arduino over USB using a Custom Serial Device.

  • Arduino libraries: Servo, Wire, Adafruit GFX and Adafruit SSD1306.

  • Serial data: RPM, speed in km/h, fuel percentage and gear information.

  • Display function: showed live vehicle information, while the servo physically moved the RPM gauge pointer.

  • Warning system: LEDs provided visual alerts based on engine RPM.

Simple project description

I built an Arduino powered sim racing dashboard using an OLED display, a servo driven RPM gauge and two LED warning lights. The system connects to SimHub to receive live telemetry from a racing simulator, allowing the gauge to display engine RPM and the screen to show vehicle information in real time.

that's most of the detail I can remember, as I remember more I will put on, code is below. If you have any questions, please ask me. P.s for the servo size I think it is fairly common around 24x22.5. some parts are best laser cut, the glass in particular of course. but with enough determination everything can be 3d printed.

Arduino Uno wiring guide

ARDUINO® Uno Rev3 – Robot Pi Shop

1. Arduino Uno

Connect the Uno to your computer using USB. This supplies power to the Arduino and carries telemetry from SimHub.

0.96 inch OLED Graphic Display | 128x64 I2C | High Contrast Monochrome PMOLED | Compact 26mm Module

2. OLED display

Display pin

Arduino pin

GND

GND

VCC

5V*

SDA

A4

SCL

A5

*Use 5V only if your particular display module supports it.

SG90 9G 180 Derece Servo Motor (China Chip) Fiyatı

3. Servo motor (RPM gauge)

Servo wire

Connection

Signal (orange/yellow/white)

D9

Positive (red)

5V supply

Ground (brown/black)

GND

The needle moves from 180° at 0 RPM to 0° at 9000 RPM. A separate regulated 5V supply may be needed if the servo draws too much current; connect its ground to Arduino GND.

Kingbright L-7113LSURDK 5mm Super Bright Red LED Low Current | Rapid Electronics

4. Red shift light

  • Arduino D7 → 1 kΩ resistor → LED long leg (positive).

  • LED short leg (negative) → GND.

The LED flashes when RPM reaches 6500.

Kingbright LED orange rond 5 mm 25 mcd 30 ° 30 mA 2 V

5. Yellow/orange check engine light

  • Arduino D8 → 1 kΩ resistor → LED long leg (positive).

  • LED short leg (negative) → GND.

The LED turns on after RPM remains at or above 6000 for 5 seconds. Once activated, it stays on until the Arduino restarts.

Important code details

  • Serial speed: 115200 baud.

  • Display address: 0x3C.

  • Telemetry received: RPM and speed are displayed; fuel and gear are received in the serial packet but are not used by this code.

  • Warning thresholds: the comments in your code are outdated. The actual settings are 6500 RPM for the shift light and 6000 RPM for the check engine light.

and the code, I believe this is the right code but uhh yeah dont quote me. ALSO VERY IMPORTANT, you must download two libraries through the Arduino IDE Library Manager.

Library

Purpose

Adafruit GFX Library

Provides graphics and text functions for the OLED display.

Adafruit SSD1306

Controls the SSD1306 OLED display.

How to check if they're installed

  1. Open Arduino IDE 1.8.19.

  2. Go to Sketch → Include Library → Manage Libraries.

  3. Search for Adafruit GFX Library and check that it is installed.

  4. Search for Adafruit SSD1306 and check that it is installed.

You may also need the Adafruit BusIO library, which is a dependency of Adafruit GFX and is generally installed automatically when installing the required libraries.

You don't need to download these libraries again if they're already installed.

But yeah the Arduino uno code:

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <Servo.h>

// ============================================================

// SETTINGS

// ============================================================

const int MAX_RPM = 9000;

const int SHIFT_RPM = 6500;

const int HIGH_RPM_THRESHOLD = 6000;

const unsigned long HIGH_RPM_TIME = 5000UL;

// Arduino pins

const int SERVO_PIN = 9;

const int SHIFT_LED_PIN = 7;

const int CHECK_ENGINE_PIN = 8;

// OLED

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define OLED_ADDRESS 0x3C

// ============================================================

// OBJECTS

// ============================================================

Servo rpmServo;

Adafruit_SSD1306 display(

SCREEN_WIDTH,

SCREEN_HEIGHT,

&Wire,

-1

);

// ============================================================

// VARIABLES

// ============================================================

float rpm = 0.0;

float speedKph = 0.0;

float servoPosition = 180.0;

bool checkEngine = false;

bool highRpmTimerRunning = false;

unsigned long highRpmStartTime = 0;

String serialBuffer = "";

// ============================================================

// SETUP

// ============================================================

void setup()

{

Serial.begin(115200);

pinMode(SHIFT_LED_PIN, OUTPUT);

pinMode(CHECK_ENGINE_PIN, OUTPUT);

digitalWrite(SHIFT_LED_PIN, LOW);

digitalWrite(CHECK_ENGINE_PIN, LOW);

rpmServo.attach(SERVO_PIN);

rpmServo.write(180);

if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS))

{

while (true)

{

}

}

display.clearDisplay();

display.setTextColor(SSD1306_WHITE);

display.display();

}

// ============================================================

// MAIN LOOP

// ============================================================

void loop()

{

readSerialData();

updateServo();

updateShiftLight();

updateCheckEngine();

updateDisplay();

}

// ============================================================

// READ SIMHUB SERIAL DATA

//

// Expected:

//

// RPM;SPEED;FUEL;GEAR

//

// Example:

//

// 7342;247;82;5

// ============================================================

void readSerialData()

{

while (Serial.available() > 0)

{

char incomingChar = Serial.read();

if (incomingChar == '\n')

{

processSerialData(serialBuffer);

serialBuffer = "";

}

else if (incomingChar != '\r')

{

serialBuffer += incomingChar;

}

}

}

// ============================================================

// PROCESS SIMHUB DATA

// ============================================================

void processSerialData(String data)

{

int firstSeparator = data.indexOf(';');

int secondSeparator =

data.indexOf(';', firstSeparator + 1);

int thirdSeparator =

data.indexOf(';', secondSeparator + 1);

if (firstSeparator == -1 ||

secondSeparator == -1 ||

thirdSeparator == -1)

{

return;

}

String rpmString =

data.substring(0, firstSeparator);

String speedString =

data.substring(

firstSeparator + 1,

secondSeparator

);

rpm = rpmString.toFloat();

speedKph = speedString.toFloat();

if (rpm < 0)

rpm = 0;

if (speedKph < 0)

speedKph = 0;

}

// ============================================================

// SERVO

//

// 0 RPM = 180 degrees

// 9000 RPM = 0 degrees

// ============================================================

void updateServo()

{

float targetPosition;

if (rpm >= MAX_RPM)

{

targetPosition = 0.0;

}

else

{

targetPosition =

180.0 - ((rpm / (float)MAX_RPM) * 180.0);

}

const float servoStep = 2.0;

if (servoPosition < targetPosition)

{

servoPosition += servoStep;

if (servoPosition > targetPosition)

servoPosition = targetPosition;

}

else if (servoPosition > targetPosition)

{

servoPosition -= servoStep;

if (servoPosition < targetPosition)

servoPosition = targetPosition;

}

if (servoPosition < 0)

servoPosition = 0;

if (servoPosition > 180)

servoPosition = 180;

rpmServo.write((int)servoPosition);

}

// ============================================================

// SHIFT LIGHT

//

// Flashes above 1000 RPM

// ============================================================

void updateShiftLight()

{

static unsigned long lastFlashTime = 0;

static bool shiftLightState = false;

if (rpm >= SHIFT_RPM)

{

if (millis() - lastFlashTime >= 100)

{

lastFlashTime = millis();

shiftLightState = !shiftLightState;

digitalWrite(

SHIFT_LED_PIN,

shiftLightState ? HIGH : LOW

);

}

}

else

{

shiftLightState = false;

digitalWrite(SHIFT_LED_PIN, LOW);

}

}

// ============================================================

// CHECK ENGINE

//

// Above 1000 RPM for 5 seconds

// Then stays ON until Arduino restarts.

// ============================================================

void updateCheckEngine()

{

if (checkEngine)

{

digitalWrite(CHECK_ENGINE_PIN, HIGH);

return;

}

if (rpm >= HIGH_RPM_THRESHOLD)

{

if (!highRpmTimerRunning)

{

highRpmTimerRunning = true;

highRpmStartTime = millis();

}

if (millis() - highRpmStartTime >= HIGH_RPM_TIME)

{

checkEngine = true;

digitalWrite(CHECK_ENGINE_PIN, HIGH);

}

}

else

{

highRpmTimerRunning = false;

highRpmStartTime = 0;

digitalWrite(CHECK_ENGINE_PIN, LOW);

}

}

// ============================================================

// OLED

//

// Shows ACTUAL RPM received from SimHub

// and current speed.

// ============================================================

void updateDisplay()

{

static unsigned long lastDisplayUpdate = 0;

if (millis() - lastDisplayUpdate < 100)

return;

lastDisplayUpdate = millis();

display.clearDisplay();

display.setTextColor(SSD1306_WHITE);

// RPM

display.setTextSize(2);

display.setCursor(0, 0);

display.print("RPM:");

display.println((int)rpm);

// Speed

display.setCursor(0, 30);

display.print("SPD:");

display.print((int)speedKph);

display.println(" km/h");

display.display();

}

Tagi