Problem - show values in window, read from Arduino.

Hi.

I have a problem to show the values of Temperature in a window on Processing.

In Arduino i'm printing the code:

 Serial.print(tempC, 1);
          Serial.print("\t");
          Serial.print(tempK, 1);
          Serial.print("\t");
          Serial.print(tempF, 1);

In Processing i'm saving the temperature to a notepad in this format:

    2013/8/28    16:31:52    25.6    298.7    78.1
    2013/8/28    16:31:53    25.9    299.1    78.7
    2013/8/28    16:31:54    25.9    299.1    78.6

But when i show the sensorReading in a Window, it's show like this:
    25.9299.178.6

it's printing the temperature in Celsius, Kelvin and Fahrenheit bonded.

I'm using this code:

    import processing.serial.*;
    Serial myPort;
    String sensorReading="";
    PFont font;
    PrintWriter output;

    void setup()
    {
      size(600, 300);
      myPort = new Serial(this, "COM4", 9600);
      myPort.bufferUntil('\n');
      font = createFont(PFont.list()[4], 36);
      textFont(font);
      output = createWriter( "C:/Users/alunosdefi/Desktop/data.txt" );
    }


    void draw()
      {
      } 

    void serialEvent (Serial myPort)
    {
     sensorReading= myPort.readStringUntil('\n');
     
      if(sensorReading != null) 
      { 
       sensorReading=trim(sensorReading);
      }

      output.println(year() + "/" + month() + "/" + day() + "\t" + hour() + ":" + minute() + ":" + second() + "\t" + sensorReading);
      output.flush();
     
     writeText("Temperatura:  " + sensorReading + " ºC");
    }
     
    void writeText(String textToWrite)
     {
      background(180);  
      fill(127,0,0);
      text(textToWrite, width/20, height/2);  
     }

Can someone tell me how I can only display temperature in ºC in the window?

thank you

     sensorReading= myPort.readStringUntil('\n');

So, sensorReading is ALL the data read from the serial port.

Fortunately, Processing has a split() method in the String class that can split the String into an array of Strings. Then, you can use just the one you want.

I change some code: this is my new variables:

tring sensorReading="";
String imprimir="";
String sensorReadingT="";
float tempK=0;
float tempF=0;

and the code that i change:

void serialEvent (Serial myPort)
{ 

imprimir =myPort.readStringUntil('\t'); because i do Serial.print(tempC) and after ("\t)
   if(imprimir != null) 
  {  
   imprimir=trim(imprimir); //imprimir is the value of temperature in ºC
 }
  
 tempK= Float.parseFloat(imprimir) + 275.15; //Converter to Kelvin

tempF= 1.8 * Float.parseFloat(imprimir) + 32; // Converter to ºF

String tempF1= nfc(tempF, 1); // i find this code in Processing Forum to print with only one decimal

String tempK1= String.format("%.1f", tempK); // i find this code too in other site
  
sensorReading= myPort.readStringUntil('\n'); //Read the ºC, "/t" and the word Alarme! (if temp>X or temp<Y)
 if(sensorReading != null)
  {  
   sensorReading=trim(sensorReading);
  }

It's printing to notepad and show only the temperature in ºC because in Arduino i only do the Serial.print of Temperature in ºC, and in Processing i'm converted to Kelvin and Fahrenheit.

( imprimir + "\t" + sensorReading + "\t" + tempK1 + "\t" + tempF1)

There is only a problem!!

it's printing the Temperature K and ºF with a "," and i pretend a dot "."
here's a example:

2013/8/29	18:39:30	25.7		300,9	78,3
2013/8/29	18:39:31	25.6		300,8	78,1
2013/8/29	18:39:32	25.6		300,8	78,1
2013/8/29	18:39:33	25.6		300,8	78,1
2013/8/29	18:39:34	25.6		300,8	78,1
2013/8/29	18:39:35	25.6		300,8	78,1

with the two codes that i found no one prints the value of K and ºF temperature with dot decimal separation..

Can someone HELP????

thanks!!

PS: i 'm converted the temperature ºC to K and ºF, because i read if less more prints in Arduino, better to processing read the Serial..
Do you agree????

with the two codes that i found no one prints the value of K and ºF temperature with dot decimal separation..

That looks like a localization issue. When I ask Processing, using English as the local language, to print floats, it uses a decimal point, not a comma, as the separator.

You could use String methods to replace the ',' that nfc() and String.format() added to tempF1 and tempK1 with a '.', instead.