Arduino Micro Pro RXTX Serial Data to Adafruit Huzzah Feather

I am pretty new to Arduino programming and this forum and am hoping someone can help...

I have an Arduino Pro Micro (ATmega32U4) running a complex code for a HAM radio satellite antenna rotator. The design of the hardware and code was kindly provided by a HAM club in Australia (THANKS! Check it out here: https://sarcnet.org/projects/project_rotator.html). The Pro Micro receives azimuth and elevation setpoints from an app on a Raspberry Pi over the USB serial port. The Pro Micro uses an azimuth and elevation sensor (LSM303DLHC) to know its position and uses two servo motors to turn the antenna toward the setpoint targets. This part all works great!

What I want is to add a TFT display for 4 float variables (actual azimuth & elevation and setpoint azimuth & elevation). I tried dumping the Pro Micro code into an Adafruit Huzzah Feather but then the code does not work. I tried to connect a different TFT display to the Pro Micro but I could not get that to work either, not enough pins. So I need to get the Pro Micro talking to the Huzzah Feather.

The easiest way I think to do this is to use the Huzzah Feather to receive serial data from the Pro Micro over the RX-TX pins and feed this data to the attached TFT display. I actually had some success using the I2C for serial communication but then my sensor (which is also on I2C) did not work. I have tried to send data over Serial1 (RX-TX) without success and tried SoftwareSerial but I get nothing coming in.

My wiring connections are as follows:
Connect Pro Micro RX to Huzzah TX
Connect Pro Micro TX to Huzzah RX
Connect Pro Micro VCC&GND to Huzzah VCC&GND
Connect Huzzah USB to PC, Pro Micro USB not connected after program upload for this testing

Here is the code for the Sender (Arduino Pro Micro) using Serial1:
// For Sending Serial Data over TxRx pins
// For use with Arduino Leonardo

// Variables as declared in Antenna Rotator code, values used just for demo/testing purposes
float az = 120.01; // Antenna azimuth
float el = 45.02; // Antenna elevation
float azSet = 125.03; // Antenna azimuth set point
float elSet = 50.04; // Antenna elevation set point

void setup(){
Serial.begin(9600); // This pipes to the USB serial monitor (later connected to Rasp Pi)
while(!Serial);
Serial1.begin(9600); // This pipes to TX RX pins (connected to Huzzah RX TX pins)
}

void loop(){
char azStr[4]; // 4 character place holder for the az string
char elStr[4]; // 4 character place holder for the el string
char azSetStr[4]; // 4 character place holder for the azSet string
char elSetStr[4]; // 4 character place holder for the elSet string

// The following should output like this " 120, 45, 125, 50/n"
Serial1.print(dtostrf(az, 4, 0, azStr)); // formats a float to a string using 4 characters with nothing after decimal point
Serial1.print(",");
Serial1.print(dtostrf(el, 4, 0, elStr));
Serial1.print(",");
Serial1.print(dtostrf(azSet, 4, 0, azSetStr));
Serial1.print(",");
Serial1.println(dtostrf(elSet, 4, 0, elSetStr));

Serial.print(dtostrf(az, 4, 0, azStr));
Serial.print(",");
Serial.print(dtostrf(el, 4, 0, elStr));
Serial.print(",");
Serial.print(dtostrf(azSet, 4, 0, azSetStr));
Serial.print(",");
Serial.println(dtostrf(elSet, 4, 0, elSetStr));
delay(250);
}

Here is the code for the Receiver (Adafruit Huzzah Feather) using Serial1:
// For Receiving Serial Data over TxRx pins
// For use with Adafruit Huzzah Feather with TFT Display
// Incoming Serial Data will be "az,el,azSet,elSet" and look something like " 120, 45, 125, 50/n"
// Final Serial Monitor output should be integers with no spaces and look like "120,45,125,50"

int az = 0; //Antenna azimuth
int el = 0; //Antenna elevation
int azSet = 0; //Antenna azimuth set point
int elSet = 0; //Antenna elevation set point

String inString = ""; // string to hold input

void setup(){
Serial.begin(9600); //This pipes to the serial monitor (connected to PC)
while(!Serial);
Serial1.begin(9600); // This pipes to TX RX pins (connected to Pro Micro RX TX pins)
// send an intro:
Serial.println("Testing TxRx Serial Data");
Serial.println();
}

void loop(){
// Read serial input:
Serial.println("Checking for Serial1...");
while (Serial1.available() > 0) {
Serial.println("Serial1 is available...");
int inChar = Serial1.read();
if (isDigit(inChar)) {
// convert the incoming byte to a char and add it to the string:
inString += (char)inChar;
}
// if you get a comma, convert the string to integer and increment the counter:
if (inChar == ',') {
if (counter = 1) az = inString.toInt();
if (counter = 2) el = inString.toInt();
if (counter = 3) azSet = inString.toInt();
if (counter = 4) elSet = inString.toInt(); counter = 0;
counter = counter + 1;
// clear the string for new input:
inString = "";
}
// if you get a carriage return then print four integers and wait for next data set
if (inChar == '\n') {
Serial.print(az); Serial.print(",");
Serial.print(el); Serial.print(",");
Serial.print(azSet); Serial.print(",");
Serial.println(elSet);
}
}
delay(250);
}

I will have to make a second post for the code using SoftwareSerial (too long otherwise)

It seems you have the second serial port free, so for just to display some values I would add a Nextion display.

Here is the code for the Sender (Arduino Pro Micro) using SoftwareSerial:
// For use with Arduino Pro Micro (Leonardo)
// For Sending Serial Data over TX RX pins

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,1); // Pro Micro RX and TX pins respectively

// Variables as declared in Antenna Rotator code, values used just for demo/testing purposes
float az = 120.01; // Antenna azimuth
float el = 45.02; // Antenna elevation
float azSet = 125.03; // Antenna azimuth set point
float elSet = 50.04; // Antenna elevation set point

void setup(){
Serial.begin(9600); //This pipes to the USB serial monitor (later connected to Rasp Pi)
while(!Serial);
mySerial.begin(9600); //This pipes to TX RX pins (connected to Huzzah RX TX pins)
}

void loop(){
char azStr[4]; // 4 character place holder for the az string
char elStr[4]; // 4 character place holder for the el string
char azSetStr[4]; // 4 character place holder for the azSet string
char elSetStr[4]; // 4 character place holder for the elSet string
// The following should output a string like this " 120, 45, 125, 50/n"
mySerial.print(dtostrf(az, 4, 0, azStr));
// formats float to a string using 4 characters with nothing after decimal point
mySerial.print(",");
mySerial.print(dtostrf(el, 4, 0, elStr));
mySerial.print(",");
mySerial.print(dtostrf(azSet, 4, 0, azSetStr));
mySerial.print(",");
mySerial.println(dtostrf(elSet, 4, 0, elSetStr));
delay(250);
}

Here is the code for the Receiver (Adafruit Huzzah Feather) using SoftwareSerial:
// For use with Adafruit Huzzah Feather with TFT Display
// For Receiving Serial Data over TX RX pins
// Incoming Serial Data will be "az,el,azSet,elSet" and look something like " 120, 45, 125, 50/n"
// Final Serial Monitor output should be integers with no spaces and look like "120,45,125,50"

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0,0); // Huzzah RX and TX pins respectively, PinOut shows RXD0 and TXD0

int az = 0; // Antenna azimuth
int el = 0; // Antenna elevation
int azSet = 0; // Antenna azimuth set point
int elSet = 0; // Antenna elevation set point

int counter = 1; // Counter to parse the four numbers received

String inString = ""; // string to hold input

void setup(){
Serial.begin(9600); // This pipes to the USB serial monitor (connected to PC)
while(!Serial);
mySerial.begin(9600); // This pipes to TX RX pins (connected to Pro Micro RX TX pins)

Serial.println("Testing TX RX Serial Data...");
Serial.println();
}

void loop(){
// Read serial input:
Serial.println("Checking for mySerial...");
while (Serial1.available() > 0) { // I tried “if (mySerial.available()) {“ here but no difference
Serial.println("mySerial is available...");
int inChar = mySerial.read();
if (isDigit(inChar)) {
// convert the incoming byte to a char and add it to the string:
inString += (char)inChar;
}
// if you get a comma, convert the string to integer and increment the counter:
if (inChar == ',') {
if (counter = 1) az = inString.toInt();
if (counter = 2) el = inString.toInt();
if (counter = 3) azSet = inString.toInt();
if (counter = 4) elSet = inString.toInt(); counter = 0;
counter = counter + 1;
// clear the string for new input:
inString = "";
}
// if you get a carriage return then print four integers and wait for next data set
if (inChar == '\n') {
Serial.print(az); Serial.print(",");
Serial.print(el); Serial.print(",");
Serial.print(azSet); Serial.print(",");
Serial.println(elSet);
}
}
delay(250);
}

Neither of these methods gets me anything available in the receiver's buffer…

Thank you Whandall, I will check out that display. I am kinda invested (time & $) in the Huzzah Feather and have done the code to create my display. Any idea why either of these two are not working though? I suppose I will try to test whether I am getting anything out of the Pro Micro using a TTL/USB board I have and connect that to TX RX pins...

Software serial on hardware serial ports for the micro is a bad idea.
Serial.print() handles floats.

I don't have a Huzzah so can not comment on that, but it seems you need to read Robin2's serial tutorial.

OK, I plugged in a TTL/USB board to my Pro Micro and I can confirm that I am able send data using Serial1 !! So my sender now works :wink: and I don't have to use SoftwareSerial ;):wink:

Now I just need to figure out how to read it with my Huzzah...