I have a very simple sketch that reads an string received from an Xbee device.
#include <SoftwareSerial.h>
SoftwareSerial XbeePort(2,3);
String XbeeString = "";// a string to hold incoming data
void setup() {
// initialize serial:
Serial.begin(9600);
XbeePort.begin(9600);
// reserve 200 bytes for the inputString:
XbeeString.reserve(100);
}
void loop() {
while (XbeePort.available()) {
// get the new byte:
byte inChar = ((byte)XbeePort.read());
XbeeString += inChar;
if (XbeeString.length() == 108){
Serial.print(XbeeString);
}
}
}
What I receive is:
126013161019162064109115123220600183126032145019162064109115123220623223201719351001801280006734228351310203
What I am actually looking for is the HEX string:
7E 00 0D A1..................
How would I convert the DEC bytes received and convert them to HEX and write them to the String array.