Sending values from an ATxmega to an Arduino

Hi,

I have an ATxmega128A3U with some sensors attached. I want to connect it to an Arduino Uno and send 6 double values from the ATxmega to the Arduino (either on demand or periodically).

What interface should I use (TWI/I²C, Serial,...)?
I'm looking for the easiest way to do this. The ATxmega will be programmed in C++.

Can you post a link to an example?

What interface should I use (TWI/I²C, Serial,...)?

Those would be good choices.

I'm looking for the easiest way to do this.

Easiest is a superlative. You have defined no criteria for easiest. Note, too, that easiest may not be best. Not that you have defined any criteria for best, either.

How much data? What sensors are you reading double values from? Can you wait until the Arduino gets the data to convert it from int to double? What is the Arduino going to do with a double? The only outputs it has are digital (0 or 1) or PWM (byte values from 0 to 255), unless you are storing the data on an SD card or in EEPROM. How far apart are the two units?

Easiest is a superlative. You have defined no criteria for easiest. Note, too, that easiest may not be best. Not that you have defined any criteria for best, either.

I'm looking for a solution that is easy to code (especially on the ATxmega site).

How much data?

6 double values. About twice a second.

What sensors are you reading double values from?

light, temperature, humidity, wind (frequency), rain (counting), air pressure

Can you wait until the Arduino gets the data to convert it from int to double?

I don't see why it's easier to convert it to int, send it and reconvert it. In both cases I will be sending 4 bytes.

What is the Arduino going to do with a double? The only outputs it has are digital (0 or 1) or PWM (byte values from 0 to 255), unless you are storing the data on an SD card or in EEPROM.

Thats what I'm doing. I will store it and send it to a telephone via bluetooth.

How far apart are the two units?

On the same breadboard.

I don't see why it's easier to convert it to int, send it and reconvert it.

The Arduino only has digital pins that are read using digitalRead() with returns either HIGH or LOW, or analog pins that are read using analogRead() which returns an integer in the range 0 to 1023.

Any other means of reading sensors is most likely performing some form of integer to double conversion.

All I am suggesting is that passing the two byte integer is going to be simpler/faster than passing a 4 byte float/double.

Send the ints before they are converted to doubles, and perform the conversion on the other side.

Thats what I'm doing.

Oh. So, it's not really doubles that you need to send. It's ASCII data. The doubles will be converted to text at some point, so doing that on the sender, and sending text is pretty easy.

On the same breadboard.

The 2 meter by 4 meter breadboard, on opposite corners, or adjacent to each other on a 2 inch by 4 inch breadboard? Details matter.

SoftwareSerial on both devices, with the appropriate pins connected (crossed) along with ground, sending text is the easiest data sharing method to debug.

Thank you for your answer.

I managed to get it working. I implemented an interface with a trigger, clock and data pin. The trigger pin starts an interrupt on the ATxmega and then it sends one bit each time the clock pin rises.
Also, I'm sending long values now. I just multiplied the double by 100 and then converted it to long.

Also, I’m sending long values now. I just multiplied the double by 100 and then converted it to long.

How is that easier? How are you sending the values? Binary or ASCII?

I'm sending them bitwise. And it's easier because I didn't find a way to acces single bits of a double with the Arduino. For a long, I can just use bitwise operators.

And it's easier because I didn't find a way to acces single bits of a double with the Arduino. For a long, I can just use bitwise operators.

The bitwise operators know that they are operating on a variable. They don't know, or care, whether they are operating on a 4 byte float, a 4 byte double, or a 4 byte long.

This is exactly what I tried and Arduino didnt compile it.

I made a thread about it yesterday:
http://forum.arduino.cc/index.php?topic=168767.msg1255792