Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

G29_ShifterSniffer

A wireless gear shift sniffer and transmitter for Logitech G29 racing wheel simulation using ESP8266 and ESP-NOW protocol. This project interfaces directly with the G29 shifter hardware, reads analog gear position data, and transmits it wirelessly to display or receiver units.

Features

  • Hardware Interface: Direct analog reading from G29 shifter potentiometers
  • Wireless Communication: ESP-NOW protocol for low-latency gear data transmission
  • SPI Monitoring: Intercepts and decodes SPI communication from shifter
  • Gear Mapping: Intelligent mapping of analog values to gear positions (R, N, 1-6)
  • Reverse Detection: Special handling for reverse gear with button press detection
  • High Precision: 200Hz polling rate for responsive gear detection
  • Guaranteed Delivery: Retry mechanism until packet delivery is confirmed
  • PlatformIO Compatible: Built for embedded development with PlatformIO

Hardware Requirements

  • MCU: ESP8266 (NodeMCU v2 or compatible)
  • Shifter: Logitech G29 shifter with analog potentiometers
  • Power Supply: 5V power source for ESP8266
  • Receiver: ESP8266 device running G29_ShifterReceiver or G29_ShifterDisplay
  • Optional: External antenna for improved wireless range

Wiring Configuration

Component ESP8266 GPIO Description
Analog Input GPIO A0 X-axis potentiometer reading
Control X GPIO 13 (D7) X-axis analog mux control
Control Y GPIO 15 (D8) Y-axis analog mux control
Status LED GPIO 14 (D5) Visual feedback indicator
Reverse Button GPIO 4 (D2) Reverse gear button detection
SPI CS GPIO 5 (D1) SPI chip select interrupt

Analog Multiplexer Setup

The shifter uses two potentiometers (X and Y axis) multiplexed to a single analog input:

  • X-axis: Left-right shifter movement
  • Y-axis: Forward-back shifter movement

SPI Interface

The shifter communicates via SPI bus:

  • CS Pin: Triggers interrupt on SPI communication
  • Reverse Detection: Monitors reverse button state via SPI data

Installation

Prerequisites

  • PlatformIO installed
  • ESP8266 development board support installed
  • Access to G29 shifter internal wiring

Setup Steps

  1. Open Shifter: Disassemble the G29 shifter to access internal wiring
  2. Identify Connections: Locate the analog potentiometer wires and SPI lines
  3. Wire Connections: Connect according to the wiring table above
  4. Update MAC Address: Modify receiver MAC address in src/main.cpp:
    uint8_t broadcastAddress[] = {0xBC, 0xFF, 0x4D, 0x18, 0xBB, 0x31};
  5. Build and Upload:
    pio run --target upload
  6. Monitor Serial Output:
    pio device monitor

Usage

Basic Operation

  1. Power on both the shifter sniffer and receiver devices
  2. Move shifter - Analog values are read and mapped to gear positions
  3. Monitor serial output to verify gear detection and transmission
  4. Check LED feedback for transmission status

Gear Detection Algorithm

The shifter uses analog voltage levels to determine gear positions:

// Y-axis thresholds
int y_low = 180;   // Forward gears threshold
int y_high = 750;  // Reverse gears threshold

// X-axis thresholds
int x_low = 310;   // Left side threshold
int x_mid = 330;   // Center threshold
int x_high = 600;  // Right side threshold

Gear Mapping Logic

  • Reverse (-1): Y > 750, X position varies, Reverse button pressed
  • Neutral (0): Y between 180-750, X in center range
  • 1st Gear (1): Y < 180, X on left side
  • 2nd Gear (2): Y > 750, X on left side
  • 3rd Gear (3): Y > 750, X in center
  • 4th Gear (4): Y < 180, X in center
  • 5th Gear (5): Y > 750, X on right side
  • 6th Gear (6): Y < 180, X on right side

Serial Debug Output

Enable serial monitor to see:

  • Raw analog X and Y values
  • Calculated gear positions
  • SPI communication detection
  • Transmission status and confirmations

Dependencies

  • Arduino Framework: Core ESP8266 functionality
  • ESP8266WiFi: WiFi connectivity for ESP-NOW
  • espnow: Wireless peer-to-peer communication

Configuration

Pin Configuration

const int8_t analog_pin = A0;      // Analog input from mux
const int8_t control_x_pin = D7;   // X-axis mux control
const int8_t control_y_pin = D8;   // Y-axis mux control
const int8_t status_led_pin = D5;  // Status LED output
const int8_t reverse_pin = D2;     // Reverse button input
const int8_t CS = D1;              // SPI chip select interrupt

Timing Parameters

  • Polling Rate: 5ms (200Hz gear detection)
  • SPI Debounce: Interrupt-driven for precise timing
  • Transmission Retry: Immediate retry until delivery confirmed
  • Serial Monitor Speed: 115200 baud

Analog Thresholds

int y_low = 180;   // Forward gears threshold
int y_high = 750;  // Reverse gears threshold
int x_low = 310;   // Left side threshold
int x_mid = 330;   // Center threshold
int x_high = 600;  // Right side threshold

Troubleshooting

Common Issues

No gear detection:

  • Verify analog wiring connections (A0, D7, D8)
  • Check shifter potentiometer values in serial monitor
  • Adjust threshold values if shifter calibration differs
  • Test with known voltage sources on analog input

No wireless transmission:

  • Verify receiver MAC address is correct
  • Check ESP-NOW initialization in serial monitor
  • Ensure both devices are on same WiFi channel
  • Verify receiver is powered and running compatible code

SPI reverse detection not working:

  • Check CS pin interrupt wiring (D1)
  • Verify reverse button wiring (D2)
  • Monitor serial output for SPI activity
  • Test with direct button press detection

Inaccurate gear mapping:

  • Fine-tune threshold values for your specific shifter
  • Check analog readings for each gear position
  • Verify mux control pins are working correctly
  • Consider hardware calibration if values drift

Intermittent transmission:

  • Check power supply stability
  • Verify antenna connections
  • Consider adding external antenna for better range
  • Monitor serial output for delivery confirmations

Debug Information

Enable serial monitor at 115200 baud to see:

  • Raw analog X and Y values (for calibration)
  • Gear position calculations
  • SPI interrupt detection
  • ESP-NOW transmission status
  • Error messages from initialization

Hardware Calibration

  1. Monitor Analog Values: Uncomment printXY(x,y) in loop()
  2. Record Values: Note X,Y values for each gear position
  3. Adjust Thresholds: Modify threshold constants to match your shifter
  4. Test Calibration: Verify correct gear detection for all positions

Development

Project Structure

G29_ShifterSniffer/
├── src/
│   └── main.cpp          # Main application code
├── include/              # Header files (empty)
├── test/                 # Unit tests (placeholder)
└── platformio.ini        # PlatformIO configuration

Adding Features

  • Implement automatic calibration routine
  • Add support for different shifter models
  • Extend gear mapping for sequential shifters
  • Add clutch pedal support
  • Implement data filtering for stable readings

Testing

  • Use PlatformIO unit testing framework
  • Create mock shifter hardware for testing
  • Test with multiple receiver devices
  • Verify timing accuracy with oscilloscope

Hardware Interface

The shifter sniffer interfaces with:

  • Analog Multiplexer: Reads X and Y potentiometer values
  • SPI Bus: Monitors communication for reverse button state
  • Interrupt Handling: CS pin interrupt for precise SPI detection

Communication Protocol

Transmits gear data via ESP-NOW:

typedef struct struct_message {
    int16_t gear;  // Gear position: -1=Reverse, 0=Neutral, 1-6=Gears
} struct_message;

Data Flow

  1. Read analog values from both potentiometers
  2. Apply gear mapping algorithm
  3. Detect reverse button via SPI monitoring
  4. Send gear data via ESP-NOW with retry logic
  5. Update status LED based on transmission success

Reverse Gear Detection

Reverse gear requires two conditions:

  1. Position: Shifter in reverse gear slot
  2. Button: Reverse button pressed (detected via SPI)

The SPI interrupt monitors the chip select line to detect when the reverse button is pressed, providing precise timing for reverse gear detection.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the terms specified in the License file.

Related Projects

  • G29_CustomSteeringWheel - Custom steering wheel with display
  • G29_Handbrake - Wireless handbrake controller
  • G29_ShifterDisplay - Gear shift indicator display
  • G29_ShifterReceiver - Wireless shifter receiver

Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Verify shifter hardware connections and wiring
  3. Review serial monitor output for analog values and gear detection
  4. Ensure proper ESP-NOW initialization
  5. Check threshold calibration for your specific shifter model

Hardware Notes

Shifter Disassembly: The G29 shifter requires partial disassembly to access:

  • Analog potentiometer connections
  • SPI communication lines
  • Reverse button detection circuit

Analog Calibration: Each shifter may have slightly different analog ranges. Use the serial monitor to calibrate threshold values for accurate gear detection.

SPI Monitoring: The SPI interface provides precise timing for reverse gear detection but requires careful interrupt handling.

Version History

  • v1.0.0 - Initial release with basic functionality
  • Direct hardware interface to G29 shifter
  • Analog gear position detection with custom mapping
  • SPI-based reverse gear detection
  • Wireless transmission with guaranteed delivery
  • High-precision 200Hz polling rate

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages