Beginner Question about connecting to sensors

Hello every, I received my FEZ Hydra kit for Christmas and I’ve got it set up and running and I can do some simple things with the joystick, the led and the light sensor. All is well on that front.

My next big step is that I want to use the Hydra to “read” voltage levels from sensor in my car. It’s an ODB1 car and I’d like to start off with some simple items like the fuel level sensor, or the engine coolant sensor. The sensors put out a varying voltage from 0 to 5 volts.

Can I simply tap into the sender wire and read the voltage, and if so, what sort of module would I use to do this?

I have a second question too… the ECU in my car has a usb (serial) connector that I use to connect to my laptop. I’ve written software that can request and read the data. I should be able to do the same thing with my FEZ Hydra if I can use the USB Host Module at Does this module work with the FEZ Hydra?

Last question… how do you get a clock (for time keeping purposes) on the Hydra?

Thanks in advance.

hi Campbell, nice Christmas gift ! :slight_smile:

if you can’t read the OBD sensor network directly, then you’d have to tap into the sensor itself; note that if they output a varying voltage, they’re analog, and therefore you’d connect to them to an analog input pin, of which most mainboards don’t have many. the other big thing to note is that Hydra is only tolerant to 3v3 input, so a full fuel tank for instance might blow up your hydra’s analog input circuitry; you need to limit the voltage by using a voltage divider circuit on each of the inputs to keep the maximum voltage at the pin to be 3v3.

if your ECU has RS232 connection, you should need the RS232 module; if it’s TTL serial then you just need to connect to the UART pins directly. How did you connect your PC to the car, was it an RS232 or TTL to USB connector? note: the USB Host adapter will NOT work on Hydra, it needs a H socket (and firmware features) that the Hydra doesn’t have.

So the first module I suspect you should have is the extender/makebread/breakout 5pack. that will allow you to connect all of those

there are recent threads on RTC and Hydra IIRC, there was even a digikey part number for what you will need to buy and solder to the board (a minimum of a crystal, then a battery)

good luck!

@ campbell -

Is the vehicle OBD I, or OBD II? I ask because GHI sells an OBD II module, which would make interfacing with the vehicle quite easy:

You can definitely read a voltage from a sensor on an Analog pin (any socket marked A will have 3 analog pins you can work with…check the socket pin specifications here: GHI Electronics – Where Hardware Meets Software)

Connecting the sensor(s) can be accomplished by using something like GHI’s breakout module (, either by soldering the sensor outputs directly to the pins on the breakout, or by soldering header pins on the breakout, and plugging it into a breadboard (really useful for temporary circuits).

Here’s a thread on enabling the RTC on Hydra:

Hope that helps.

You guys are awesome.

I currently connect to the ECU using a special USB cable which attaches to a 4 pin connector on the ECU board. The ECU eprom has been modified to allow the communication. I use System.IO.Ports object to send and receive via COM port.

The description on the cable states:

So… if I am reading this correctly, it means that I can connect to the UART pins directly? First question: Where are the UART pins? Second question: Is there a UART object in the Micro Framework. And… the ECU is 5 volts, so would that mean I can not connect directly to the UART?

The car is definitely ODB1. I did see the ODBII module, but that won’t work in my case. One of the reasons I want to “speak” to some sensors directly is that not everything goes thru the ECU. In addition, I’d like to get some sensor readings directly, instead of going thru the ECU for performance reasons.

Now… the voltage divider. I’m a computer guy… but not in the sense of electronics. Could you give me some pointers on the voltage divider circuit? I’m assuming I will need a breadboard to allow connecting the circuit, putting the voltage divider in place and then having a connector to the Hydra, or the breakout module?

To give you guys a little more background on my project, my goal is to create a “Digital Dashboard” for my 91 Honda. There are a ton of potential sub projects (climate control, backup camera, security system) but at the moment I am trying to get the basics down pat. First part is to connect to an analog sensor, which looks like it won’t be too tough. Next step will be connecting to a digital sensor (speedometer, tachometer) which uses PWM.

The Hydra might not be the board for this in the long run, but it’s possible I might use it as a sub-system (such as climate control).

A voltage divider is two resistors, connected so that the signal from the 5v sensor is the “input” and the 3.3v signal is the output. See Voltage divider - Wikipedia for a simple diagram and explanation.

Uart is a serial port is a com port. So your code is probably going to be fairly close to what you use in big .net on the pc, but note there are some definite differences.

You’ll probably find your USB cable has an MAX232 or equivalent chip in it that changes the rs232 signal to be a TTL signal, but then also converts to USB signalling. So if you’re intending to use that cable, you might have some challenges. Here’s a decision for you. I personally like neat solutions, so I’d make a socket coming from the ECU, then put a plug on the end of your existing cable. I’d then buy an rs232 module and connect hydra that way; it makes sense to use sockets that mate directly to the module.

Actually, they do make a cable that just has a serial connector at the computer end, so I’m guessing I could use that and the RS232 module Wait… that’s what you just said isn’t it. Ok… that’s what I’ll do on that front. Here’s a link to the actual cable I’ll use instead of the USB on… The one I am currently using is here:

The problem with the communication with the ECU is that you can only transfer data every 300-400ms and, when you send a command for a data point, there’s no telling when (and sometimes if) it will be returned. As the motor RPM rise above 1200 rpms I start missing data points because the ECU can’t respond fast enough. For many sensors, it doesn’t matter, but for some it might. The other issue is that I’d like my Gadgeteer to work even if there is no ECU data connection. If I were to put my Gadget in another car, it would be reliant on the car having a modified ECU. I’d rather be able to plug my gadget into the harness and just have it work without relying on the ECU communication.

As for the voltage divider, I understand the principle. The analog sensors put out 0 to 5v, and the input can only be 0 to 3.3v so the voltage has to be brought down in scale (losing resolution in the process) I read the wiki page and it’s got the formulas. I’m guessing that I want a Resistive Divider. I’ll do more research on that to figure out what resistors I need and if I can’t figure that part out, I’ll post here again looking for pointers in the right direction.

the xeno serial cable seems to be an expensive $30 cable with no intelligence. The header you have, already in place, right? so all you really need is $5 DB9 connector and $1 in cable to achieve the same goal :slight_smile:

yep you got all the voltage divider stuff right; you shouldn’t lose resolution if you make the divider come out exactly at 3.3v max, assuming the same resolution of what you use to take the reading… an 10-bit AD converter still gives 10 bits of resolution across 0-3v3 is still the same resolution as a 10-bit AD that could support 0-5v range. You may find a bigger noise impact though.

sounds like you’re getting a lot more of the electronics stuff sorted now, very cool progress in 3 posts ! :slight_smile:

How would I notice the noise impact?

Also, I did some searching… and site suggested the a 20K resistor with a 39K resistor would be perfect, but those resistor sizes are not common, so 10K and 15K would work fine.

If I splice off the sender wire with the original wire still heading to the gauge, and install the resistor on my parallel wire, will that affect the voltage going to the gauge at all? Is that a correct way to do it?

By header, do you mean on the ECU board? It has 4 pins sticking out of the circuit board, and the current cable has the plug that connects to the pins. Looks like the same sort of plug you would use to connect a sound card to a cdrom unit in a pc. The Xeno folks build things for dopes like me who aren’t sure how to, so I can’t blame them on the price, however, if I know how to make it cheaper I surely will. :slight_smile: And I’m not above pinning or even re-pinning a set of wires if need be.

noise impacts it more because it is likely to remain the same voltage of noise offset, which will be a larger percentage of the lower voltage in 3v3 mode.

the correct way is to join the wire at the sensor so that you don’t interfere with the original wire. That’s unlikely to be practical in all circumstances, so doing as you say will be ok.

where abouts are you located? all you need is GND RX and TX wires. search out a RS232 pinout diagrm and uou should be right to go, you just need to figure out what the 4-pin header wires are for ! :slight_smile:

I’m in Delaware.

I found the pin out. Pin 1 (GND), Pin 2 (TX), Pin 3 (+5v), Pin 4 (RX)

Pretty straight forward. Radio shack should have a DB9 connector and the wire.

On the connections to the sensors. All of these sensors are OEM from Honda. They almost always have molded casing around the wires at the sensor for protection from the elements.

My thinking was to connect to the sensors where they run into the cabin. There are several major wire harness bundles that have male/female plug connections. Using spare parts I could create my own harness connectors that insert in between the existing plugs. At this point, it’s only an idea, but there are many circuits I’d like to connect into and the wiring could get ugly real fast.

If I were to make a complete digital dash (as I would like to) there are many circuits; blinkers, seat belt warning light, high beams, CEL, hand brake, door open, trunk open, dash lights (for dimming things at night), plus gauges, water temp, tach, speed, fuel, alternator, idiot oil light. All of those circuits are available right at the cluster. Others like Air Intake Temp, Coolant Temp, Manifold Air Pressure, O2 Sensor, Throttle Position Sensor, and more are available at the ECU harness which ends in the cabin not far from the cluster.

And then to add to the big bowl of spaghetti I’m planning, I’d like to add in a compass, interior temperature, exterior temperature, humidity, accelerometer, some cameras (back up and blind spots), light sensor etc… Plus possibly (if I ever get there) some active components, such as servos to control the temperature valve (based on feed back from the light sensor, temp sensor, and humidity sensor.)

I’m not sure how many displays I’ll end up with but at least the larger touch panel display and probably several others. I’m also not sure if one Hydra will do the job. So that mean I’ll have to have some sort of network for the devices to talk to each other. And then of course, it makes sense to save some of the data (gas mileage, oil changes)

Big ideas… but I’ve got to start somewhere.

Try radioshack, should be worth a try anyway :wink: DB9’s are getting seriously old-skool but still in use, maybe not as common as they are in jaycar here

Great plans, sounds awesome. yep I agree with your thoughts about breaking into one of the wiring points under the dashboard before they are used by the regular instruments.