Using hardware Serial ports on Adalogger 32u4

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

I'm trying to use an xbee with the adalogger32 but I'm not sure what to use instead of the softserial libraries or if using a board with hardware UART is any different or not

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

You can connect to pins 0 and 1 which are Rx and Tx for the "Serial1" port. https://learn.adafruit.com/adafruit-fea ... logic-pins
Communicating via Serial1 is the same as Serial - except you prefix the calls with Serial1.
https://www.arduino.cc/en/Reference/Serial

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

ah thanks. I think I was using just serial as the prefix, that was probably my problem

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

On the 32U4, "Serial" is routed through the USB/Serial interface.

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

Ah OK might be best just to ask the best way to go about this, I remember having some trouble using the serial monitor before with the feather. I'm trying to get wireless ahrs data to the serial moniter initially and use it in a program after that. What would be the best way code/ port wise? Just using the adalogger and the 10dof breakout board and a pair of xbee pros

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

What kind of trouble did you have with the Serial Monitor?

For wireless communication via XBee, the simplest thing to do would be to connect the XBee to Pins 0 & 1 and send data via Serial1.

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

I can't get any info to show from the serial ports Wouldn't the monitor not be available while I'm using serial port 1? I was thinking there was an issue like that since this chip does serial/ USB differently than I'm used to with uno-like boards before
I'm trying a simple send/ receive sketch to check things are in order before moving from there.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

The serial interface is a little different - and does not have the auto-reset of the UNO. Adding this code to your setup can help:

Code: Select all

void setup() 
{ 
 //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) 
  {
    ; // wait for serial port to connect. Needed for native USB
  }
} 

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

That's what I'd use to be able to use the serial port? and I guess port 1 is still usable as well?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

That makes the sketch wait for the serial monitor to connect before proceeding. It has no effect on Serial1.

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

getting back to this since work got in the way- so do I need to use the SoftwareSerial library if I use the built in serial ports on the feather? and if not how would it change the code

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

You do not need to use SoftwareSerial for the 32U4 feather. Use Serial for the USB/Serial port and Serial1 for the hardware serial on pins Rx/0 and Tx/1.

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

ahh allright. so Serial when I'm reading from it when it's plugged into the computer (like displaying data on the serial monitor) and serial1 when I'm communicating with the xbee?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using hardware Serial ports on Adalogger 32u4

Post by adafruit_support_bill »

That is correct.

User avatar
jet_flyer
 
Posts: 36
Joined: Sat Jul 12, 2014 6:18 pm

Re: Using hardware Serial ports on Adalogger 32u4

Post by jet_flyer »

Ok I think the issue is me trying to modify the example sketches to work with this so I might just start from scratch

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”