split serial data from radiation monitor and display on lcd

Hi, as I am new to this forum and quite new to arduino please forgive me if doing something wrong writing my question!!!

To begin: I am using a radiation monitor which gives me a serial string once per second. To achive this I have to send a command to the detector. I am transmitting this via zigbee.

What I need: In the moment I am using as display a I2C 16x2 LCD and an arduino fio. Working fine so far. But There is more data then the display can show in one line. So I thought on splitting the stream in three parts to put the last one in the second line.

My problem(s): I have to send a complex command to the detector. The only way for me so far was in the loop with a one time function I´ve found. Works.
But now I had to give up splitting the stream. Found a lot here and elsewhere like strtok() but nothing worked. I think because I have to change the serial stream to a readable format in the loop mode via my command.

What I have: The string I get now looks like 0001 0,012 uSievert/h
It is space seperated. The first row is gowing up per second till 9999 and then restarts with 0000. Depending on the measurement, between first and second row there can be one or two spaces.

I would like to have is first one digit going up from 0 to 9, then the second row with the third row in the second line starting under the second row:

1 0,012
uSievert/h

The code:
Importing the I2C lcd
in Setup Serial.begin(9600) and lcd.begin(16,2)

In the loop mode I first send my commands via Serial.print inside executes==false / true. Then:
if (Serial.avaliable()) {
delay(100);
lcd.clear();
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}

Anyone any idea?

I am working as radiation protection officer and ths would easy up my life because I can work farther away from my surces which reduces my personal dose and arduino is much smaller than my raspi solution and needs less power so the device I´ve built is much smaller and lighter :wink:
Thanks

An integer number, a float number and some text ?
Some would advice to use sscanf to read those numbers into variables. But you have to know the exact format. Do you know for example if there is a CarriageReturn or LineFeed at the end ?

Or you can do Serial.parseInt() and Serial.parseFloat() and retrieve those values while they are being read from the incoming data.

For the sscanf, you need to read it first into a buffer with Serial.readBytes().

Maybe you can start with the most simple solution. Read the data into a buffer, and don't convert them to integer and float, but just copy the substrings to the lcd. You can make substrings by dropping a few zero-terminators in the string. But again, you have to know the exact format.

Maybe someday later, you want to check the value if it exceeds a certain maximum. For that you have to convert them into variables. But for now you can copy the substrings.

Hi and tnx for the answer.
When I view the string in a terminal prog on a pc each line comes in a new line.
Would it help if I have the data sent like 1234-1? The numbers before number means the measurement's, the number behind starts with uSievert, then I think 100 uSievert, then mSievert and so on. This should then be displayed as mentioned.
Your other solutions I've read about but I'd need help :wink:
Regards, Oskar

It looks pretty simple to parse. Given what you're measuring though, I'd want to be very very sure that you know all possible variation in the strings the device can send to the arduino.

I'd also want to test very extensively - I'd be inclined to get another arduino and have it simulate the measuring device - I assume you won't see the whole possible range from the device itself.

Thanks, your help is much appreciated! Cheers