Hello Arduino Forum,
we have near to zero experience with the Arduino platform, but want to read out data obtained from the stratoflights project. They have a sensor platform called STRAT04 which is connected to a board provided by the project. They do not give a lot of information about connection or how to exactly get data from the logger.
We only know that with the line "{to:'Log',from:'Mst',reci:'headerValsCsv',dir:'g',rc:''}" we can get data from the head of the logging file and with "{to:'Log',from:'Mst',reci:'dataValsCsv',dir:'g',rc:''}" we can get data from the body of the logger.
They communicated between the board and the Arduino works over the UART protocol.
The baud rate of the of the stratoflight board is 115200, 8N1 and the desired voltage is 3.3 V. During our endeavour, the startoflight board was powered by an Varta 9V battery.
We connected the ground, pin16, pin17 of the Arduino to the ground, Rx1, Tx1 of the stratoflights board, respectively.
This is the code we have come up so far:
String sendMessage;
String receivedMessage, receivedMessage2;
String input;
void setup() {
Serial.begin(9600); // Initialize the Serial monitor for debugging
Serial2.begin(115200); // Initialize Serial2 for sending data
Serial.println("Start");
delay(2000);
}
void loop() {
// print to monitor on computer, self check if data was received from computer
while (Serial.available() > 0) {
char receivedChar = Serial.read();
if (receivedChar == '\n') {
Serial.println(receivedMessage); // Print the received message in the Serial monitor
receivedMessage = ""; // Reset the received message
} else {
receivedMessage += receivedChar; // Append characters to the received message
}
}
const char* headerCommand = "{to:'Log',from:'Mst',reci:'headerValsCsv',dir:'g',rc:''}"; //get logger head
Serial2.write(headerCommand);
while (Serial2.available() >0) {
char receivedChar2 = Serial2.read();
if (receivedChar2 == 125) {
receivedMessage2 += receivedChar2;
Serial.println(receivedMessage2); // Print the received message in the Serial monitor
receivedMessage2 = ""; // Reset the received message
} else {
receivedMessage2 += receivedChar2; // Append characters to the received message
}
}
}
But instead of giving us the data/head from the logger, we just get the input line as output. Neither to we understand why this is the case, nor how to receive the data from the logger properly. Additionally, sometimes the output is rather cryptic, sometimes it yields the full input.
We do net need a complete solution, but concrete tipps should already be sufficient.
Thanks in advance!
Setup: