Page 1 of 1

I want to display data in Serial Monitor

Posted: Tue Sep 27, 2016 9:17 am
by eraldino
Hello good day! I finally got my hands on one of the OBD-II adaptor today and i tried out the sample sketch. All is good, the LED pin on pin 13 Lights up when my vehicles RPM goes beyond 3000 RPM but there seems to be something weird going on my Serial Monitor.

Here is my code:
I modified it a bit to display the data in the serial monitor.


Code: Select all

/*************************************************************************
* Sample sketch based on OBD-II library for Arduino
* Distributed under GPL v2.0
* Visit http://freematics.com for more information
* (C)2012-2014 Stanley Huang <stanleyhuangyc@gmail.com>
*************************************************************************/

#include <OBD2UART.h>

COBD obd;

void setup()
{
Serial.begin(9600);
  // we'll use the debug LED as output
  pinMode(13, OUTPUT); 
  // start communication with OBD-II UART adapter
  obd.begin();
  // initiate OBD-II connection until success
  while (!obd.init()); 
}

void loop()
{
  int value;
  if (obd.readPID(PID_RPM, value)) {
    // RPM is successfully read and its value stored in variable 'value'
    // light on LED when RPM exceeds 3000
    digitalWrite(13, value > 3000 ? HIGH : LOW);
Serial.println(value);
  }
}


http://imgur.com/a/2IlpN

I am using an Arduino UNO R3 and I'm trying to display the RPM data stored in "value" into the serial monitor attached here in this post is the screen shot of my Serial Monitor feed.

You can see that it's displaying weird data. This usually happens when there is a problem in the baudrate (in my experience) but i want to know first hand from the support team what I must do.

My real goal is to display all data in serial monitor and pass it on using Bluetooth,Serial,WIFI etc etc.

Re: I want to display data in Serial Monitor

Posted: Mon Oct 10, 2016 10:40 pm
by stanley
Arduino UNO only has one hardware serial so you need to use software serial to output data to serial monitor. You can consider using Arduino MEGA which has multiple hardware serial.