Using Uart ...TX and RX

So I have code put together (borrowed from here and there) to take in temperature and read it to an LCD. Now I am trying to take that temperature data and transmit it to a Xbee module (Xbee 1). Xbee1 will then send to Xbee2 and go into the RX port of the Arduino to print once again to a different LCD. A wireless transmission to say the least. My issue is that I am have a rough time staring out. All of the resources I find explain to put the Xbees into API mode… which I dont want to do.

Anyone have any guidance for understanding how the TX and RX ports will work? I am using the Arduino Duemilanove.

Heres the code so far for the temperature circuit

#include <onewire.h>
#include <liquidcrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight

OneWire ds(8); // ds18b20 pin #2 (middle pin) to Arduino pin 8
// ds18b20 pin #1 GND
// ds18b20 pin #3 +5vdc
// 5k ohm resistor between pins 2 & 3

byte i;
byte present = 0;
byte data[12];
byte addr[8];
 
int HighByte, LowByte, SignBit, Whole, Fract, TReading, Tc_100, FWhole;

void setup(void) {
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(2,16);              // rows, columns.  use 2,16 for a 2x16 LCD, etc.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0
 
    if ( !ds.search(addr)) {
      lcd.clear(); lcd.print("No more addrs");
      delay(1000);
      ds.reset_search();
      return;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      lcd.clear(); lcd.print("CRC not valid!");
      delay(1000);
      return;
  }
}

void getTemp() {
  int foo, bar;
 
  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);

  for ( i = 0; i < 9; i++) {
    data[i] = ds.read();
  }
 
  LowByte = data[0];
  HighByte = data[1];
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
 
  if (SignBit) {
    TReading = -TReading;
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
  Whole = Tc_100 / 100;          // separate off the whole and fractional portions
  Fract = Tc_100 % 100;
  if (Fract > 49) {
    if (SignBit) {
      --Whole;
    } else {
      ++Whole;
    }
  }

  if (SignBit) {
    bar = -1;
  } else {
    bar = 1;
  }
  foo = ((Whole * bar) * 18);      // celsius to fahrenheit conversion section
  FWhole = (((Whole * bar) * 18) / 10) + 32;
  if ((foo % 10) > 4) {            // round up if needed
       ++FWhole;
  }
}

void printTemp(void) {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temp is: ");
  lcd.setCursor(0,1);  
 
  if (SignBit) { 
     lcd.print("-");
  }
  lcd.print(Whole);
  lcd.print(" C / ");
  lcd.print(FWhole);
  lcd.print(" F");
}

void loop(void) {
  getTemp();
  printTemp();
  delay(1000);
}

jlaugh87: All of the resources I find explain to put the Xbees into API mode... which I dont want to do.

Not sure why you don't want to use API mode, but the fact that all the resources you found recommend it should tell you something. Sorry if I sound like an API bigot, but, well, I guess I am! ;)

Granted a bit more learning curve, but well worth it, your project will be much more solid and less error-prone.

The XBee, if the right type and properly configured, takes everything that comes in on the serial port (the RX pin) and broadcasts it. It takes everything that comes in over the air and writes it to the serial port.

Having an Arduino with XBee send data to another Arduino with XBee is as simple as Serial.print(ln)(theData);. Having an Arduino with XBee receive data send by another Arduino with XBee is as simple as Serial.read() (after checking Serial.available(), of course).

So if my data(from the sensor) were coming into port 3 of the arduino, the instruction would be Serial.print(ln)(3)? If so, the the TX port should be able to send the data to the xbee via jumper wire?

Again I am very new at this, so forgive my amateur inquiries.

On another note. I didnt fully understand how switching the xbee to API would help me understand the syntax of how the arduino TX and RX will work.

So if my data(from the sensor) were coming into port 3 of the arduino, the instruction would be Serial.print(ln)(3)? If so, the the TX port should be able to send the data to the xbee via jumper wire?

What do you mean by "port 3"? You said you have Duemilanoves. They only have one serial port. Did you mean pin 3?

When I wrote "Serial.print(ln)()", I meant that you could use either Serial.print() or Serial.println(), depending on whether you want the carriage return/line feed sent, or not.

No, you would not be sending the value 3 to the serial port.

How is your XBee connected to the Arduino? Using a shield?

Oh I get that now... I meant pin 3, and my xbee does not have a shield, its is only the module with a regulator board on it.

my xbee does not have a shield, its is only the module with a regulator board on it.

Got a link? The XBee does not come with "a regulator board on it".

heres a link to the board I am using. It regulates the voltage to the xbee http://www.sparkfun.com/products/8276

and will it be difficult to take in the data via serial RX and print it to the LCD display?

and will it be difficult to take in the data via serial RX and print it to the LCD display?

Why? Character data coming in on the RX pin. Character data going out to the LCD. Couldn't be a better match.

I guess so, I understand the hardware side of things, but programming has never been my forte... which is why I am cruising we forums to get knowledge! I appreciate the help.

If my celcius data is called "Whole" and fahrenheit data is called "FWhole", would the transmit instruction be as simple as serial.print(Whole) and serial.print(FWhole) ?

I guess I should try to be more formal I mean this code snippet...

void setup() {
  // open the serial port at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  delay(800);
  Serial.print(FWhole);
}

If my celcius data is called "Whole" and fahrenheit data is called "FWhole", would the transmit instruction be as simple as serial.print(Whole) and serial.print(FWhole) ?

Yes, it would.