Skip to main content
Visitor II
September 19, 2024
Solved

Printing values

  • September 19, 2024
  • 1 reply
  • 1107 views

I am using 16 sensors for my project and I need to print the sensor number and the corresponding signal strength for a ML model, but I am missing a lot of values. Is there an efficient way to do this?

    This topic has been closed for replies.
    Best answer by Karl Yamashita

    Serial.Print looks to be Arduino code so you should be asking in Arduino forum.

     

    Anyways, test return value when you print to see if the amount of bytes have been sent correctly. Then continue with the next print.

    1 reply

    Technical Moderator
    September 19, 2024

    Hello @slodh and welcome to the community.

    You need to provide more than that as information to let community memebers to help you efficiently.

    Please refer to our recommendations on how to post a thread.

    Thank you for your understanding.

    slodhAuthor
    Visitor II
    September 20, 2024

    I am using stmcube 32 Ide to code and VS code to get the output. I want to print the values of my 16 sensors and its corresponding data such as signal strength , distance on Y axis and distance on x axis

    for (int i = 0; i < TOF_NUM; i++)
    
    {
    
    Serial.print("SN%i",i); // Sensor number from si array
    
    Serial.print("|");
    
    Serial.print("%f",sensorSignal[i]); // Signal strength with 2 decimal places
    
    Serial.print("|");
    
    Serial.print("%f",distI[i]); // Distance with 2 decimal places
    
    Serial.print("\n");
    
    }
    
    Serial.print("DX:%.2f",minDistX); // Distance with 2 decimal places
    
    Serial.print("\n--");

    This is the code that I am using. But when I print the values I get a lot of missing values which might be because my loop time is very small (9 - 11 ms , but this it the ideal loop time for my project and I don't want to change it). I want to print the values in a proper format and without any missing values to export the values to an excel file which I can then use for my machine learning model. Could you please provide me a solution where I can print the values in the proper format with no missing values?

    Graduate II
    September 20, 2024

    Serial.Print looks to be Arduino code so you should be asking in Arduino forum.

     

    Anyways, test return value when you print to see if the amount of bytes have been sent correctly. Then continue with the next print.