Serial monitor data shifting

After being able to receive accurate data from the Fsr sensor, Iadded a DHT11 sensor and tried making them work together but noticed the values are shifting around. What am i doing wrong here?

Transmitter

#include <RH_ASK.h> //transmitter
#include <SPI.h>
#include <dht.h>
#define dht_apin A6
float fsrAnalogPin = 2;
float force1;
dht DHT;

char stri1[]="    ";

char stri2[]="    ";

char stri3[]="    ";

char buf[sizeof(stri1)+ sizeof(stri2) + sizeof(stri3) + 2];

RH_ASK driver(2000, 4, 3, 10);

void setup() {

  Serial.begin(9600);
  if(!driver.init())
    Serial.println("init failed");
    
}

void loop()
{
char stri1[]="   ";

  DHT.read11(dht_apin);
  
  force1 = analogRead(fsrAnalogPin);
  dtostrf(force1,0,0,stri1);

  dtostrf(DHT.humidity, 0,0,stri2);
  dtostrf(DHT.temperature, 0,0,stri3);
  
  
  
  Serial.print("Force 1:  ");
  Serial.println(stri1);
  Serial.print("Humidity: ");
  Serial.print(DHT.humidity);
  Serial.print("% ");
  Serial.print("Temperature: ");
  Serial.print(DHT.temperature);
  Serial.println("C  ");
  

  
  sprintf(buf, "%s %s %s ", stri1, stri2, stri3);

  driver.send((uint8_t*)buf,strlen(buf));
  driver.waitPacketSent();
  delay(2000);
}

Receiver

#include <RH_ASK.h>
char buff[]="                                                                             ";


RH_ASK driver(2000, 4, 3, 10);

void setup()
{
  Serial.begin(9600);
  if(!driver.init())
    Serial.println("no radio");
    
}


void loop()
{
    uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
    uint8_t buflen = sizeof(buf);
    

    if (driver.recv(buf,&buflen))
    {
      buf[buflen-1]=0;
      char buff[]="                      ";
      char pressure1[]="  ";//force sensor 1
      char humi[]="  ";//Humidity sensor data
      char temp[]="  ";//temperature 0
      int posi=0;
      
      for (int b=0; b<buflen; b++)
      buff[b]=char(buf[b]);
      pressure1[0]=buff[posi];
      pressure1[1]=buff[posi+1];
      pressure1[2]=buff[posi+2];
      pressure1[3]=buff[posi+3];
      int pres1 = atoi(pressure1);
      
      if((pres1>=0)&&(pres1<=9)){
        posi=posi+2;
      }
      else{
        posi=posi+3;
      }
      humi[0]=buff[posi];
      humi[1]=buff[posi+1];
      int humidity = atoi(humi);
      
      if((humidity>=0)&&(humidity<=9)){
        posi=posi+2;
      }
      else{
        posi=posi+3;
      }
      
      temp[0]=buff[posi];
      temp[1]=buff[posi+1];
      int tempera0= atoi(temp); 
      if((tempera0>=0)&&(tempera0<=9)){
        posi=posi+2;
      }
      else{
        posi=posi+3;
      }

      Serial.print("Force 1: ");
      Serial.println(pres1);
      Serial.print("Humidity: ");
      Serial.print(humidity);
      Serial.print("% ");
      Serial.print("temperature: ");
      Serial.print(tempera0);
      Serial.println("C ");

    }
}

Serial Monitor

Not sure... but (although not clear in the quotes below)

In the transmitter you declare this variable twice (as a global, and in loop)... with different lengths.

Declaring char arrays with no explicit size is always dangerous. You also need to remember that an implied 0x00 gets added to the end when initialising this way.

I'd add some Serial.print statements to figure out where it's going wrong. Print out buf before you send it for example... in hex so you can see exactly what's being sent.

Have checked the buf, its fine. Main issue is when im retrieving the data from the receiver. I feel that its due to the buff[posi] thing but im not sure how to solve it.

How have you checked it exactly? When you print out buf in HEX after received what does it look like? Can you rerun your code with that and show the output?

Your receiving code is not particularly robust and relies on your assumptions about the data you expect to get. One extra character here or there and it will break.

oh sry i didnt really know what u meant, i just printed buf out

Try this...

      for (int b=0; b<buflen; b++)
      {
        buff[b]=char(buf[b]);
        Serial.print(buf[b], HEX);
        Serial.print(" ");
      }
      Serial.println();

So we can see exactly what is arriving...

this is what i receive

  if((pres1>=0)&&(pres1<=9)){
    posi=posi+2;
  }
  else{
    posi=posi+3;
  }

What happens if pressure is 3 digits? or 4 digits? ... your logic treats anything greater than 9 as 2 digits. That's why it isn't working as expected.

My suggestion is to build up the char array by reading until you reach a space (Hex 20) or null (Hex 00)... then convert to an integer... then keep reading for the next value.