Passing Serial Data from Wideband AFR Gauge

The end goal of this is to mirror my wideband’s display to a smaller OLED screen I have mounted to my dash (that currently displays ethanol content), but the first part of getting readable data is what’s really stumping me -

I’m attempting to read serial data from the wideband air/fuel gauge (gauge/sensor seen here - https://www.amazon.com/AEM-30-4110-UEGO-Ratio-Gauge/dp/B00N3VGPYS/). The gauge has a serial output that works as expected and as documented with a serial-to-USB cable (shown in the left side of the screenshot attached) but isn’t outputting the data I expect when I try to read it with my Arduino.

The pattern of numbers is repeating depending on what is shown on the gauge and PuTTY display. For example, when the gauge starts up it shows 14.7 on the gauge display and the serial cable output into PuTTY, but displays the repeating value 2292350103217139 in the Arduino serial monitor.
I’m using SoftwareSerial to read the data from the gauge -

#include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }



  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.print(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.print(Serial.read());
  }
}

Documentation for the gauge says the following should be defined in terminal/serial software for the correct data to display -

Bits Per Second = 9600
Data Bits = 8
Parity = None
Stop Bits = 1
Flow Control = Hardware

This work perfectly in PuTTy

If Arduino uses 8N1 for serial data as I’ve read, what am I doing wrong to recieve those numbers instead of a mirror of the data that displays on the gauge?

I’m using an Uno to get everything working, but would like to use a Micro once this is all figured out.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Have you got an RS232 to 5V logic converter between the AFR and the Arduino.
The RS232 will be a signal that goes positive AND negative, the Arduino can only interface 5V logic.

What model Arduino are you using?

Thanks.. Tom.. :slight_smile:

Post a link to the datasheet for the gauge so that we can read the specifications.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Have you got an RS232 to 5V logic converter between the AFR and the Arduino.
The RS232 will be a signal that goes positive AND negative, the Arduino can only interface 5V logic.

What model Arduino are you using?

Thanks.. Tom.. :slight_smile:

Thanks for the reply. I don't have one between them. Should I? I didn't need one when using the RS232/serial cable so I had assumed I didn't need one between the Arduino and the gauge. Is there a way the Arduino can emulate that? I'd rather not add another piece of hardware to the puzzle if possible.
For the testing part of the project I'm using an UNO, but would like to use a Micro for the end result.

Robin2:
Post a link to the datasheet for the gauge so that we can read the specifications.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

This is the info for the gauge - http://aemelectronics.com/files/instructions/30-4110%20Digital%20Wideband%20UEGO%20Gauge.pdf

Serial output instructions begin on page 8.

It looks as if the device uses RS232 voltage levels so you will need something like a MAX232 to convert to the Arduino's TTL voltage levels.

...R

Robin2:
It looks as if the device uses RS232 voltage levels so you will need something like a MAX232 to convert to the Arduino's TTL voltage levels.

...R

I appreciate you looking into this. I don't have one of those so I ordered one today. I'll report back with my findings once it's delivered

Beaten to it! You need to convert from 232 to TTL levels - had this very problem when trying to program a sleepy-pi with the wrong cable!

Nice project, by the way. I'm currently trying to find an analogue output on my 14point7 SLC AFR wideband AFR to feed into an arduino to drive a bar graph nixie tube.

mt86:
I'm attempting to read serial data from the wideband air/fuel gauge (gauge/sensor seen here - https://www.amazon.com/AEM-30-4110-UEGO-Ratio-Gauge/dp/B00N3VGPYS/). The gauge has a serial output that works as expected and as documented with a serial-to-USB cable (shown in the left side of the screenshot attached) but isn't outputting the data I expect when I try to read it with my Arduino.

The Amazon documentation shows that this gauge has a 0-5v analog output. Have you tried reading that?

fall-apart-dave:
Beaten to it! You need to convert from 232 to TTL levels - had this very problem when trying to program a sleepy-pi with the wrong cable!

Nice project, by the way. I'm currently trying to find an analogue output on my 14point7 SLC AFR wideband AFR to feed into an arduino to drive a bar graph nixie tube.

Thanks! I'm hoping to have my hardware in by Saturday so I can do some more troubleshooting

oldvetteguy:
The Amazon documentation shows that this gauge has a 0-5v analog output. Have you tried reading that?

Attempted to, but the readings were very sporadic. I tried adding a delay to the code as well but the numbers still jumped around a lot. The code for the 0-5v readings is below

#include "U8glib.h"

#define OLED_RESET 4
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // I2C / TWI


void setup() {

  // screen is mounted upside down. 180 rotation is needed to display correctly
  u8g.setRot180();
  Serial.begin(9600);
}


void loop() {

  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);

  // convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);

  // convert voltage to a value mirroring AFR data displayed on the AEM gauge
  float AFR = (voltage * 2.375) + 7.3125;

  // print the AFR value on serial monitor
  Serial.println(AFR);

  // draw the value on the OLED screen
  u8g.firstPage();
  do
  {
    u8g.setFont(u8g_font_unifont);
    u8g.setPrintPos(36, 10);
    u8g.print("AIR/FUEL");
    u8g.setPrintPos(36, 30);
    u8g.print(AFR);

  }
  while ( u8g.nextPage() );

  // delay added to slow readings displayed. didn't work
  //delay(100);

}

If you do not have a ground from the 5v signal source connected to an Arduino ground pin you will get "sporadic" readings.

oldvetteguy:
If you do not have a ground from the 5v signal source connected to an Arduino ground pin you will get "sporadic" readings.

All ground were tied together but the issue remained

The serial to TTL converter came in today. I connected everything but I'm still not getting the data I hoped to. It displays repeating values again. This time different values, such as -

255255255302552552552552551350255255255255255255962552552552552551270255255255255255625525525525

Have you connected a voltmeter to check the 5v analog output?
I tried your code (removing the U8g specific stuff) using a 1.5v battery and it gave me correct constant readings, removed the ground to the Arduino GND pin and readings immediately started to fluctuate.

oldvetteguy:
Have you connected a voltmeter to check the 5v analog output?
I tried your code (removing the U8g specific stuff) using a 1.5v battery and it gave me correct constant readings, removed the ground to the Arduino GND pin and readings immediately started to fluctuate.

Using a voltmeter shows very smooth, stable readings. I need to re-check my grounds and report back