Using hardware Serial ports on Adalogger 32u4
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Using hardware Serial ports on Adalogger 32u4
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
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
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
Communicating via Serial1 is the same as Serial - except you prefix the calls with Serial1.
https://www.arduino.cc/en/Reference/Serial
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
ah thanks. I think I was using just serial as the prefix, that was probably my problem
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
On the 32U4, "Serial" is routed through the USB/Serial interface.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
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
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
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.
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.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
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.
I'm trying a simple send/ receive sketch to check things are in order before moving from there.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
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
}
}
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
That's what I'd use to be able to use the serial port? and I guess port 1 is still usable as well?
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
That makes the sketch wait for the serial monitor to connect before proceeding. It has no effect on Serial1.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
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
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
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.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
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?
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Using hardware Serial ports on Adalogger 32u4
That is correct.
- jet_flyer
- Posts: 36
- Joined: Sat Jul 12, 2014 6:18 pm
Re: Using hardware Serial ports on Adalogger 32u4
Ok I think the issue is me trying to modify the example sketches to work with this so I might just start from scratch
Please be positive and constructive with your questions and comments.