Thank you Guix and Jurs for your help. And I am sorry for a delay with my answer. I do this for a hobby when I have time.
Yes, I got through few examples and I figured it out how to change the code that works for me. There is a lot of things that are just too complicated for me so I don't understand everything yet. But I have a feeling that there are probably simpler methods to achieve the same thing - parsing the data.
Jurs, the example I took uses chars, not strings. As I understand with strings you can do even more operations?
So my program looks now like this:
// Example 5 - Receive with start- and end-markers combined with parsing. To je prva uporabna verzija programa za prikaz podatkov s senzorjem DHT11.
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const byte numChars = 52;
char receivedChars[numChars];
char tempChars[numChars];// temporary array for use when parsing
// variables to hold the parsed data
char messageFromPC[numChars] = {0};
int integerFromPC = 0;
int integerFromPC1 = 0;
float floatFromPC = 0.0;
float floatFromPC1= 0.0;
boolean newData = false;
//============
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
lcd.clear();
lcd.print(" Meteo display ");
lcd.setCursor(2,1);
lcd.print("WX by S52ID V1.0");
delay(4000);
lcd.clear();
Serial.begin(9600);
//Serial.println("This demo expects 3 pieces of data - text, an integer and a floating point value");
//Serial.println("Enter data in this style <HelloWorld, 12, 24.7> ");
Serial.println();
}
//============
void loop() {
recvWithStartEndMarkers();
if (newData == true) {
strcpy(tempChars, receivedChars);
// this temporary copy is necessary to protect the original data
//because strtok() used in parseData() replaces the commas with \0
parseData();
showParsedData();
newData = false;
}
}
//============
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = ' '; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
//============
void parseData() {// split the data into its parts
char * strtokIndx; // this is used by strtok() as an index
strtokIndx = strtok(tempChars,",");// get the first part - the string
strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC
strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
integerFromPC = atoi(strtokIndx);// convert this part to an integer
strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
integerFromPC1 = atoi(strtokIndx);// convert this part to an integer
strtokIndx = strtok(NULL, ",");
floatFromPC = atof(strtokIndx);// convert this part to a float
strtokIndx = strtok(NULL, ",");
floatFromPC1 = atof(strtokIndx);// convert this part to a float
}
//============
void showParsedData() {
Serial.print("Message ");
Serial.println(messageFromPC);
//delay(50);
Serial.print("Temperatura zunaj: ");
Serial.print(integerFromPC);Serial.println("C ");
Serial.print("Vlaga zunaj: ");
Serial.print(integerFromPC1);Serial.println("% ");
Serial.print("Napetost baterije: ");
Serial.print(floatFromPC);Serial.println("V ");
Serial.print("Tok baterije: ");
Serial.print(floatFromPC1);Serial.println("mA ");
Serial.println();
delay(70);
lcd.setCursor(0,0);
lcd.print("Tout:");lcd.print(integerFromPC);lcd.print("C ");
lcd.print("Vl: ");lcd.print(integerFromPC1);lcd.print("% ");
lcd.setCursor(0,1);
lcd.print("Ub=");lcd.print(floatFromPC);lcd.print("V");
lcd.print("Ib=");lcd.print(floatFromPC1);lcd.print("mA");
}