Read/Write Serial Console Data From Arduino to BeagleBone Black via I2C

Hi all,

I have a project using an Arduino to read the outputs of multiple sensors (temperature/electrical conductivity/etc). Currently, we set up a console text structure to communicate with the arduino through I2C and it displays the current readings, for example when you type this command,

INPUT command: { T }

This data is output,

OUTPUT: Temperature: 76F (updates periodically on new line)

This is great, however, we are placing this sensor stack with the arduino on an underwater rover that runs from a BeagleBone. So I have been tasked with figuring out how to have the Arduino communicate this data via I2C (cannot use USB because of the custom PCB) to the BeagleBone terminal(which we can see on the laptop above ground) so we can run these input commands from the beaglebone terminal and receive the sensor output from the arduino. Does that make sense?

I have scoured the internet the past few work days searching for a solution, but I only seem to find TX/RX or USB solutions or an outdated Angstrom Linux solution. Does anyone have experience or would be willing to help walk through this section of the project with me? I'd love to learn and I am stuggling to find a foothold on this portion of our project.

Thanks for any and all help, please feel free to ask questions if you need more info.

Really you are using I2C? Not Serial? Because that's a very odd way to use I2C but normal for Serial.

I2C has slaves and masters and it's totally different to Serial. It's also unusual to use I2C over a USB connection but USB works quite well for Serial.

MorganS:
Really you are using I2C? Not Serial? Because that's a very odd way to use I2C but normal for Serial.

I2C has slaves and masters and it's totally different to Serial. It's also unusual to use I2C over a USB connection but USB works quite well for Serial.

Thanks for your response.

Unfortunately it was not my decision, the arduino sensor unit was already developed before I was brought on. The PCB that the arduino is soldered on to was designed in a way where I can connect a 3.3v (level translated) SCL/SDA wiring to the i2c 3.3v ports of a BeagleBone. To me, it makes complete sense to transfer serial data back and forth via...something that isn't I2C. What's the best plan of attack, do you think?

Inter integrated circuit communication (I2C) was designed for links between ICs located on the same PCB or a few centimeters apart, not over a long cable. Think I would abandon I2C and look at Rs422 and line drivers.

edgemoron:
Inter integrated circuit communication (I2C) was designed for links between ICs located on the same PCB or a few centimeters apart, not over a long cable. Think I would abandon I2C and look at Rs422 and line drivers.

This is a great point, however, the beaglebone is connected on the same rover. Then serial data would then be sent out to a laptop above ground..so that long range cable isn't I2C

OK, so you have some technical debt to pay. Keep the I2C but just making this one change isn't the total value of that debt. It is going to cost you more in the future.

So... are you really sending the letters "T" "e" "m" "p" "e" "r"... over I2C? Or is there some other protocol and the Beagle is printing those letters after it gets the I2C temperature?

Which one is the master?

Did you previously have a "bare" I2C sensor? Can you tell us which one? Do you have the datasheet for it?

Have you read: Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino?

MorganS:
OK, so you have some technical debt to pay. Keep the I2C but just making this one change isn't the total value of that debt. It is going to cost you more in the future.

So... are you really sending the letters "T" "e" "m" "p" "e" "r"... over I2C? Or is there some other protocol and the Beagle is printing those letters after it gets the I2C temperature?

Which one is the master?

Did you previously have a "bare" I2C sensor? Can you tell us which one? Do you have the datasheet for it?

Have you read: Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino?

Hey Morgan, great questions! Here is the setup. We have an Arduino mini that has multiple sensors, think: temperature, electrical conductivity, pH, pump control and more. When the arduino boots up, it is expecting a serial input like: { P 100101 10 } This command tells the Pump (P) to open values 1, 4, 6 for 10 seconds or {T} to turn temperature readings on (this will display the temperature to be sent to serial monitor every few seconds) and {t} turns off the temperature readings from being sent to the serial monitor.

Now here is the plan, this sensor module is being placed on the payload of an underwater rover, and we would like for this arduino to send it's serial monitor data to the beaglebone (this is what is controlling the underwater rover) and relay that up to the surface. The underwater rover provides a camera for us to see where we are moving the rover so we would also like to send/receive this serial information so that we can control when the arduino takes measurements! The arduino is the master of the sensors, it would be nice just to have the beaglebone receive and send the serial commands and data while the arduino parses these commands apart and sends the commands to the relevant sensor (as a master should do to slave devices).

Say you pull up the serial monitor on arduino, all I need to do is read the serial output from that screen and then be able to input text into that serial monitor field. Once the arduino receives these commands it understands and can take care of the rest. Does that make sense?

The arduino master/slave setup works flawlessly, it's just the relaying this information from the arduino to beaglebone output/input that I struggle with.

I have not read the article you posted, but will do that.

I guess I'm missing something,

You have a dedicated PCB with an Arduino that currently talks to some PC application via I2C. That would mean that you have an I2C device connected to the PC.

Now you want to connect the Arduino to the Beaglebone in the rover and send the data through that same I2C device that is connected to the PC.

Is this a correct description?

If so, it sounds to me that you need another device between the Beaglebone and the I2C device that can receive from the Beaglebone, convert to I2C and connects to your current I2C device. That way you can use any means of communication between the Beaglebone and the I2C device that is connected to your PC (e.g. serial).

sterretje:
I guess I'm missing something,

You have a dedicated PCB with an Arduino that currently talks to some PC application via I2C. That would mean that you have an I2C device connected to the PC.

Now you want to connect the Arduino to the Beaglebone in the rover and send the data through that same I2C device that is connected to the PC.

Is this a correct description?

If so, it sounds to me that you need another device between the Beaglebone and the I2C device that can receive from the Beaglebone, convert to I2C and connects to your current I2C device. That way you can use any means of communication between the Beaglebone and the I2C device that is connected to your PC (e.g. serial).

Here is a poorly drawn text schematic:

(| Beaglebone |) < ------ > (| Arduino | < ----- > | Sensors |)

The beaglebone is on the rover and the arduino and sensor stack is separated and placed on the payload beneath the rover

So what we have working so far is just:

| Arduino | < ------ > | Sensors |

The way it currently works is that when the arduino is plugged in to a computer the serial monitor page opens, and you are confronted with:

SENSORS CONNECTED TYPE A COMMAND: { Enter command in these curly braces }

we have developed firmware that parses this command and communicates with the sensors via i2c to start sending the data to the serial monitor.

The beaglebone is the controller of the rover. This is connected via wire to a laptop at the surface, so instead of having the arduino plugged into the computer, we would like to have just the beaglebone connected. We want to see the serial data that is output by the arduino and send commands from via the beaglebone. Does that help?

Does the Beaglebone have a spare Serial port? I should think that will be easier than cramming the serial stuff into I2C.

Note that both Serial and Wire classes inherit from the Stream class, so at a certain level these two are interchangeable. So you can write most of your code to use #define MySerial Serial and then later change it to #define MySerial Wire (you just don't try to give Wire.begin() a baud rate.)

MorganS:
Does the Beaglebone have a spare Serial port? I should think that will be easier than cramming the serial stuff into I2C.

Note that both Serial and Wire classes inherit from the Stream class, so at a certain level these two are interchangeable. So you can write most of your code to use #define MySerial Serial and then later change it to #define MySerial Wire (you just don't try to give Wire.begin() a baud rate.)

So I asked at work, and the reasoning behind I2C is that the rover we are using has a shielded waterproof cable that is already connected to the Beaglebone (that's inside the rover) available for us to connect our sensor module externally...if that makes sense. Once we figure out a basic programming configuration, I can go from there but I'm not sure where to plant my feet and get going just yet

No it doesn't make sense. I2C won't work over the long waterproof cable unless this is just a fishtank rover. So you must be using something else there.

If the Beaglebone has a spare serial port then that's the best way to go.