My ODB II module is arriving today, so I began to study the provided driver software.
The driver internals support the selection of English or Metric units for appropriate measurements,
but the OBD_II class, which is the interface to the user, does not allow for changing the
selection from the default, which is English.
It is possible to configure the module for Metric units, by not using the code generated
by the designer, and manually configuring the module constructor after adding a using or two.
I suggest a method/property be added to the OBD_II class for setting the measurement units.
We plan on changing the driver quite a bit in the next release to allow users to better use the underlying OBDII class. For now, your best bet would be to just use the OBDII class, that way you have full control over the commands and units.
Ideally, it might want to be more finely configurable than just a straight choice like that. For instance, here in the UK we have a somewhat confused system whereby we use miles and mph, but we now buy fuel in litres and talk about fuel tank capacities in litres. On the other hand we still most often refer to fuel consumption in miles per gallon even though weâre buying it at the pump in litres. Even more confusingly, the British definition of gallons (the Imperial gallon) differs from the US gallon, itâs about 20% bigger, making it doubly confusing what might be meant by configuring to use âEnglishâ units, as I imagine that would mean US gallons and not anything thatâs ever been in use in England. So for OBDII-based guages in my car, I would want speed in mph, distances in miles, fuel consumption in mpg (using Imperial gallons) but to enter fuel added to the tank in litres. This is usually possible in OBDII-based car computers available here, although I expect theyâre just handling the unit conversions in software from whatever units the hardwareâs measuring in.
I just gave the driver a cursory glance, but I noticed that there seem to be many more PIDs (iirc) than what the driver exposes.
My plan was to extend the driver when I got around to working with this device.
One other suggestion for a future HW rev â could the OBDII be used as a power module as well? If I understood this correctly, then I am assuming that the OBDII port is putting out ~12v :
[quote]/// Gets the battery voltage reading. Note that this value is read
/// directly off the supply pin from the OBD port[/quote]
I am trying to connect to the OBD_II module with the Hydra and continuously receive the following error (car is on and sitting in car running program with OBD_II module plugged in).
An unhandled exception of type âSystem.Exceptionâ occurred in GTM.GHIElectronics.OBD_II.dll
Additional information: Failed to connect to the ELM327
It seems to get caught at this line of code:
obd_II.Connect();
Any suggestions? Iâm been stuck on this for a while now with no luck. I might be overlooking something simple (I hope) that maybe someone with experience with this device can share with me.
I am connecting the modules as shown below on port 7 of the Hydra. I connected the adapter straight end into the OBD port of the car.
Using this OBD_II module: http://ghielectronics.com/catalog/product/365
Program.Generated.CS
using Gadgeteer;
using GTM = Gadgeteer.Modules;
namespace Hydra_OBD2
{
public partial class Program : Gadgeteer.Program
{
// GTM.Module definitions
Gadgeteer.Modules.GHIElectronics.LED7C led7c;
Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClientDP;
Gadgeteer.Modules.GHIElectronics.OBD_II obd_II;
public static void Main()
{
//Important to initialize the Mainboard first
Mainboard = new GHIElectronics.Gadgeteer.FEZHydra();
Program program = new Program();
program.InitializeModules();
program.ProgramStarted();
program.Run(); // Starts Dispatcher
}
private void InitializeModules()
{
// Initialize GTM.Modules and event handlers here.
usbClientDP = new GTM.GHIElectronics.UsbClientDP(2);
obd_II = new GTM.GHIElectronics.OBD_II(7);
led7c = new GTM.GHIElectronics.LED7C(14);
}
}
}
Program.cs
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Elm327.Core;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Hydra_OBD2
{
public partial class Program
{
String VIN, fuelType, obdProtocol;
Double fuelLevel, battVolts, ambAirTemp, engCoolTemp, intAirTemp, rpm, throttlePos, speed;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
led7c.SetColor(LED7C.LEDColor.Red);
Debug.Print("Program Started");
getVehicleData();
}
void getVehicleData()
{
obd_II.Connect();
bool connect = obd_II.Connected;
while (connect == false)
{
led7c.SetColor(LED7C.LEDColor.Red);
Thread.Sleep(1000);
led7c.SetColor(LED7C.LEDColor.White);
Thread.Sleep(1000);
connect = obd_II.Connected;
}
if (connect == true) led7c.SetColor(LED7C.LEDColor.Green);
// Debug Printing is Enabled
obd_II.DebugPrintEnabled = true;
// Gets ELM357 Version Number
string elmversid = obd_II.elm.ElmVersionID;
// Get Initial Parameters
obd_II.GetAmbientAirTemp();
obd_II.GetBatteryVoltage();
obd_II.GetEngineCoolantTemp();
obd_II.GetFuelLevel();
obd_II.GetIntakeAirTemp();
obd_II.GetOBDProtocolType();
obd_II.GetRPM();
obd_II.GetThrottlePosition();
obd_II.GetVehicleFuelType();
obd_II.GetVehicleSpeed();
obd_II.GetVIN();
}
}
I am connecting the modules as shown below on port 7 of the Hydra. I connected the adapter straight end into the OBD port of the car.
Using this OBD_II module: http://ghielectronics.com/catalog/product/365
Program.Generated.CS
using Gadgeteer;
using GTM = Gadgeteer.Modules;
namespace Hydra_OBD2
{
public partial class Program : Gadgeteer.Program
{
// GTM.Module definitions
Gadgeteer.Modules.GHIElectronics.LED7C led7c;
Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClientDP;
Gadgeteer.Modules.GHIElectronics.OBD_II obd_II;
public static void Main()
{
//Important to initialize the Mainboard first
Mainboard = new GHIElectronics.Gadgeteer.FEZHydra();
Program program = new Program();
program.InitializeModules();
program.ProgramStarted();
program.Run(); // Starts Dispatcher
}
private void InitializeModules()
{
// Initialize GTM.Modules and event handlers here.
usbClientDP = new GTM.GHIElectronics.UsbClientDP(2);
obd_II = new GTM.GHIElectronics.OBD_II(7);
led7c = new GTM.GHIElectronics.LED7C(14);
}
}
}
Program.cs
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Elm327.Core;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Hydra_OBD2
{
public partial class Program
{
String VIN, fuelType, obdProtocol;
Double fuelLevel, battVolts, ambAirTemp, engCoolTemp, intAirTemp, rpm, throttlePos, speed;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
led7c.SetColor(LED7C.LEDColor.Red);
Debug.Print("Program Started");
getVehicleData();
}
void getVehicleData()
{
obd_II.Connect();
bool connect = obd_II.Connected;
while (connect == false)
{
led7c.SetColor(LED7C.LEDColor.Red);
Thread.Sleep(1000);
led7c.SetColor(LED7C.LEDColor.White);
Thread.Sleep(1000);
connect = obd_II.Connected;
}
if (connect == true) led7c.SetColor(LED7C.LEDColor.Green);
// Debug Printing is Enabled
obd_II.DebugPrintEnabled = true;
// Gets ELM357 Version Number
string elmversid = obd_II.elm.ElmVersionID;
// Get Initial Parameters
obd_II.GetAmbientAirTemp();
obd_II.GetBatteryVoltage();
obd_II.GetEngineCoolantTemp();
obd_II.GetFuelLevel();
obd_II.GetIntakeAirTemp();
obd_II.GetOBDProtocolType();
obd_II.GetRPM();
obd_II.GetThrottlePosition();
obd_II.GetVehicleFuelType();
obd_II.GetVehicleSpeed();
obd_II.GetVIN();
}
}
I just tested this with a Hydra and the OBDII module. I was able to connect to the ELM327, Now we need to find out why you are unable to connect. When you plug in the module into your carâs OBDII port, do the LEDs light up?
When I plug in the module adapter to the carâs OBD port, It cycles down through the LEDâs and stops at the red led and keeps the red led lit the entire time after that.
Also, not sure if this is of any importance but I am using Microsoft Visual Studio 2010 with my target framework as .NET Micro Framework 4.2. The entire project is a .NET Gadgeteer Application (NETMF 4.2) as well.
After looking at the image of this module in the designer yesterday, before this thread was resurrected, I notice itâs basically an ELM327 cable with RS232 signal levels with RS232 module. So a simple test to halve the problem space would be to use the RS232 module portion to connect to a PC and exchange serial data. You will need a PC with a (legacy) serial port or a USB-RS232 adapter, do you have either of those? If you can successfully communicate with the PC over just the RS232 module, your problem likely is with the ELM327 device.
Unfortunately I do not have either of these adapters. I do understand what you are saying. Iâm hoping to hear back from Steven soon about whether the red light being on the whole time is normal or not. I appreciate your feedback for sure. Worst case, I can go pick up a USB-RS232 adapter and attempt that. It makes me think that the RS-232 module might not be working if the OBD-II module portion is lighting up and seems to be working so far. Not sure though.
So This morning I noticed that the ribbon cable connector on the RS232 board was completely coming off of the soldered connections holding it onto the board. So Iâve ordered a new one and hoping this might be a majority of the problem. It canât quite communicate or connect with ELM327 with connections that arenât holding in place.