Serial1 with moteino mega

Started by daemach, September 11, 2014, 01:35:50 PM

daemach

I've used software serial in the past to communicate with an RN-XV, which is an xbee-size wifi adapter (https://www.sparkfun.com/products/11047).  I'm attempting to use the Serial1 (arduino-ese) UART with the mega and it doesn't seem to be working.  Has anyone been able to test this?  Any advice would be gratefully received.

Below is the relevant section from the end of the setup function and beginning of the loop function:

...

Serial1.begin(57600);

#ifdef DEBUG
  Serial.println("Setup complete.");
#endif

}

void loop() {

  Serial1.print("S2|123779752F5CFC4EE|77|0|143|55|51|000|3342|32132|1027|");Serial1.println(getTime());  //this should be going to the RN-XV

#ifdef DEBUG
  Serial.print("S2|123779752F5CFC4EE|77|0|143|55|51|000|3342|32132|1027|");Serial.println(getTime());
#endif

...

Felix

There is no issue that I can find. It works using this sketch.
Make sure your wiring is correct. TX goes to RX and vice versa.

#define LED           15 // Moteino MEGAs have LEDs on D15
// the setup routine runs once when you press reset:
void setup() {                
  pinMode(LED, OUTPUT);     
  Serial1.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
  Serial1.print(var++);
  Serial1.print(" - S2|123779752F5CFC4EE|77|0|143|55|51|000|3342|32132|1027|");Serial1.println(millis());
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               
}