Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-S3 GPS Logger and Wind Speed Display with Dual OLED and CAN Bus

View and Edit Project In Cirkit DesignerImage of ESP32-S3 GPS Logger and Wind Speed Display with Dual OLED and CAN Bus

Circuit Documentation

Summary

This circuit is designed around an ESP32-S3-DevKitC-1-N8R2 microcontroller. It interfaces with various peripherals including an SD card module, two OLED displays, a CAN bus module, and a GPS module. The primary functions of the circuit are to record GPS data to an SD card every second, display speed in knots on the first OLED display, and display wind speed from the CAN bus in NMEA 2000 format on the second OLED display.

Component List

  1. ESP32-S3-DevKitC-1-N8R2

    • Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: GND, 5Vin, 14, 13, 12, 11, 10, 9, 46, 3, 8, 18, 17, 16, 15, 7, 6, 5, 4, 3v3, TX, RX, 1, 2, 42, 41, 40, 39, 38, 37, 36, 35, 0, 45, 48, 47, 21, 20, 19
  2. BE - 880

    • Description: A GPS module.
    • Pins: GND, VCC, SDA, TX, RX, SCL
  3. SD SDHC

    • Description: An SD card module for data storage.
    • Pins: 3V3, CS, MOSI, CLK, MISO, GND
  4. 128x64 OLED Display (I2C IIC SPI Serial)

    • Description: A 128x64 pixel OLED display.
    • Pins: GND, SDA, SCL, VCC
  5. CAN BUS

    • Description: A CAN bus module for communication.
    • Pins: INT, SCK, SI, SO, CS, GND, VCC, J1, J11, H, L, VDD

Wiring Details

ESP32-S3-DevKitC-1-N8R2

BE - 880

SD SDHC

128x64 OLED Display (I2C IIC SPI Serial) - First Display

128x64 OLED Display (I2C IIC SPI Serial) - Second Display

CAN BUS

Code Documentation

/*
 * This Arduino Sketch is for an ESP32-S3-DevKitC-1-N8R2 connected to various
 * peripherals. It records GPS position to an SD card every second, displays
 * speed in knots on the first OLED display, and displays wind speed from the
 * CAN bus in NMEA 2000 format on the second OLED display.
 */

#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <CAN.h>

// Pin definitions
#define SD_CS 5
#define OLED1_SDA 8
#define OLED1_SCL 9
#define OLED2_SDA 8
#define OLED2_SCL 9
#define CAN_CS 21
#define CAN_SCK 45
#define CAN_MISO 47
#define CAN_MOSI 48

// OLED display objects
Adafruit_SSD1306 display1(128, 64, &Wire, -1);
Adafruit_SSD1306 display2(128, 64, &Wire, -1);

// GPS data
String gpsData = "";

void setup() {
  // Initialize serial communication
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Starting...");

  // Initialize SD card
  if (!SD.begin(SD_CS)) {
    Serial.println("SD card initialization failed!");
    while (1);
  }

  // Initialize OLED displays
  Wire.begin(OLED1_SDA, OLED1_SCL);
  if (!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("OLED1 initialization failed!");
    while (1);
  }
  if (!display2.begin(SSD1306_SWITCHCAPVCC, 0x3D)) {
    Serial.println("OLED2 initialization failed!");
    while (1);
  }
  display1.clearDisplay();
  display2.clearDisplay();

  // Initialize CAN bus
  CAN.setPins(CAN_CS, CAN_MISO, CAN_MOSI, CAN_SCK); // Move this line before CAN.begin()
  if (!CAN.begin(500E3)) {
    Serial.println("CAN bus initialization failed!");
    while (1);
  }
}

void loop() {
  // Record GPS data to SD card
  File dataFile = SD.open("gps.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(gpsData);
    dataFile.close();
  } else {
    Serial.println("Error opening gps.txt");
  }

  // Display speed in knots on OLED1
  display1.clearDisplay();
  display1.setTextSize(1);
  display1.setTextColor(SSD1306_WHITE);
  display1.setCursor(0, 0);
  display1.print("Speed: ");
  display1.print(getSpeedInKnots());
  display1.print(" knots");
  display1.display();

  // Display wind speed from CAN bus on OLED2
  display2.clearDisplay();