//Hardware Components Needed:
//Arduino Board (e.g., Arduino Uno, Arduino Nano, etc.)
//4-Wire Lambda Sensor (ensure compatibility with your application)
//OLED Display (e.g., SSD1306 based, with I2C interface for easier connection)
//Voltage Divider Circuit (if necessary to step down the sensor output voltage)
//Connecting Wires
//Breadboard (optional, for prototyping)
//Steps:
//1. Connect the Lambda Sensor to Arduino:
//Signal Wire: This wire provides the output voltage proportional to the oxygen content in the exhaust gas. Connect it to an analog input pin on the Arduino (e.g., A0).
//Heater Ground Wire: Connect this wire to the ground (GND) of the Arduino or a common ground if using a separate power supply.
//Heater Power Wire: Connect this wire to a 12V power source or a suitable power supply for the lambda sensor's heater.
//Sensor Ground Wire: Connect this wire to the ground (GND) of the Arduino or a common ground.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Open_24_Display_St10pt7b.h"
#include "Open_24_Display_St28pt7b.h"
// Define OLED parameters
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Analog input pin for lambda sensor
const int sensorPin = A0;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize OLED display
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
// Clear the buffer
display.clearDisplay();
// Display initial message
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 30);
display.println("Lambda Sensor");
display.display();
delay(2000);
}
void loop() {
// Read analog value from lambda sensor
int sensorValue = analogRead(sensorPin);
// Convert analog reading to voltage (if needed)
float voltage = sensorValue * (5.0 / 1023.0); // Assuming Arduino is using 5V reference
// Display the reading on OLED
display.clearDisplay();
display.setFont(&Open_24_Display_St28pt7b);
display.setCursor(26, 42);
//display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
//display.setCursor(0, 0);
//display.print("AFR: ");
display.println(voltage);
display.setFont(&Open_24_Display_St10pt7b);
display.setCursor(53, 62);
display.setTextSize(1);
display.print("AFR");
display.display();
// Delay before next reading
delay(1000); // Adjust as needed
}