Arduino -> Arduino (New to Arduino)

So here's the problem:

I have a temperature sensor that is connected to a Arduino Diecimila (Arduino1). The temperature sensor output (temperature is indicated by a voltage 0 - 3.3V) is connected to Analogue In (pin 5). This is the sender unit.

I am trying to send the data from Analogue Output (pin pwm 11) of that board to a Arduino Duemilanove (Arduino2), where the data is received on Analogue In (pin 5) and read by the PC to which it is connected. This is the receiver unit.

So basically the data goes from Temp Sensor -> Arduino1 (Analogue In pin 5) -> Arduino1 (Analogue Out pin pwm 11) -> Arduino2 (Analogue In pin 5) -> PC (via USB).

Arduino1 (sender) is powered by 9v external supply and has code:

int analogValue5, val5;

void setup() {

Serial.begin(9600);
}

void loop() {

analogValue5 = analogRead(5);


val5 = map((analogValue5*1.515), 0, 1023, 0, 255);


Serial.println(val5);

analogWrite(11,val5);


}

Arduino2 (receiver) is powered by USB from PC and contains code:

int val1;

void setup() {

Serial.begin(9600);
}

void loop() {
 val1 = analogRead(5);

Serial.println(val1);
}

Unfortunately it does not seem to be working. The correct voltages are coming out of Arduino1, but it all seem to get messed up as soon as it enters Arduino2.

Is there anything that stands out as glaringly wrong (all signals are grounded by the way).

Eventually the link between the 2 boards will be wireless (XBEE Pro) but until I can get it sorted with wires I can't progress.

This is part of a Uni Final Year project so your help is very much appreciated.

Make sure that the two arduinos share a common ground. i.e., run one more wire with the analog output from GND of arduino 1 to the GND of arduino 2.

!c

I dont think analogue read on the second Arduino would read the pwm from the first.
Doesnt analogue read just read a voltage, wheras pwm is not a voltage level.

Wouldnt sending the info to the second Arduino by serial message or I2C be more reliable and less prone to error?
This could still be done wirelessly or you could stick to a wire over a fair distance.

Im not sure what you are working on, but do you even need a second Arduino?
If all you are doing is sending a value representing the temp from the sensor you could do that directly to the pc without a second Arduino.

Gordon

What I'm working on is a wireless weather station.

The idea is I will have 3 sensors, each will be an individual portable unit:

  1. Tempeature sensor
  2. Humidity Sensor
  3. Windspeed senor.

I was going to put an arduino in each sensor unit. Technically I know I don't need one with each as they are all going to communicate with a basestation containing an arduino.

The idea of them each having an arduino was for a later development where a hand held display could be attached to each unit to get that units readings alone. This is because this station will be used on a golf course and the senors will be placed at differnet locations (a sort on maintenance check option if you like).

Ignoring the fact I don't need the 2. How would I attach them serially as you suggested and how would I alter the code?

I'm guessing it would be attach tx of Arduino1 to rx of arduino 2

Would the code then change to:

Sender

void setup() {

Serial.begin(9600);
}

void loop() {

analogValue5 = analogRead(5);


val5 = map((analogValue5*1.515), 0, 1023, 0, 255);


Serial.println(val5);




}

receiver

int val1;

void setup() {

Serial.begin(9600);
}

void loop() {
 val1 = Serial.read();

Serial.println(val1);
}

I really don't no much about Arduino I didn't realise using PWM 11 would not work .

I may be being stupid, but what is an I2C ?

what is an I2C

If you don't know what something is then Google it or Wikipedia it.

In this case it is a method of passing data between devices, it stands for "Inter Integrated Circuit" or "I squared C"

P.S. Or it could be "Inter IntegratedCircuit Communications"

I may be being stupid, but what is an I2C ?

I know that was a stupid statement and I did google it straight away, it was more a back up incase I couldn find much on it.

Found an example on the net using one with Arduino. I will investigate. In the meantime advice on my code above would be helpful

You are going to have to be careful with your code as the tx/rx lines are all connected together with your pc, both arduinos and the ide. So things can get a bit confusing.
Your sender is sending to the receiver and the ide terminal.
Your receiver, if it does get the data, is then sending to both the ide terminal and the original sender board.
You will have to output your debug code to maybe an lcd rather than the terminal in the ide.
Also there could be interference when uploading your sketches unless you disconect the connections between the two boards.

This guy is trying to do something similar communicating between 2 arduinos.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1233839105/0
Have a look at his code as he has something working but with a few bugs.

You might want to dive straight in with the xbee stuff.
Have you looked at the examples in the playground?
Under Communication and wireless.
http://www.arduino.cc/playground/Main/InterfacingWithHardware#Communication
They might get you running quicker and get some more inspiration on how to solve your problem.

Gordon

I am trying to send the data from Analogue Output (pin pwm 11) of that board to a Arduino Duemilanove (Arduino2), where the data is received on Analogue In (pin 5) and read by the PC to which it is connected. This is the receiver unit.

You cannot wire a PWM "analog" output pin directly to a analog input pin as a PWM signal is not a real analog voltage but rather a series of highs and low of variable duty cycle. One must first filter the PWM signal with a low pass filter to obtain a true analog voltage that can then be wired to a analog input pin.

http://arduino.cc/en/Tutorial/PWM

Lefty

Thanks for the help.

While I'm waiting to get hold of a I2C and or LP filter, I've decided to have a go at the XBee as I have 2 pro modules.

As it was suggested earlier that I don't need 2 Arduinos, I've deciede to connect the temp sensor to and XBee module (XBee2) and the other to an Arduino (XBee1).

Having looked through the playground stuff on XBee I have set the modules up as follows:

XBee1:
Coordinator
ATMY 1234
ATDL 5678
ATDH 0
ATID 1111

XBee2:
End Device
ATMY 5678
ATDL 1234
ATDH 0
ATID 1111

As stated before the output from the temp sensor is 0-3.3V. Can I connect the sensor straight to AD0 if I set that pin up as a ADC in X-TCU or do I need a buffer or anything?

Am I also correct in saying as the 2 module have been set up as detailed above in X-TCU, they will automatically communicate with each other without having an Xbee setup function on the arduino.

Finally I want the the data to enter the arduino on a analogue in pins, so I presume I need a DAC between XBee1 and the arduino.

Also do I have to import any particular libraries into the arduino code in order for it to communicate with XBee.

Thanks in advance for you help