How do I print different values through rf433 on receiver side? (Solved)

//Transmitter
#include <DHT.h>
#include <Adafruit_BMP085.h>
#include <Wire.h>  
#include <VirtualWire.h> 
 
// Definimos el pin digital donde se conecta el sensor
#define DHTPIN 8
// Dependiendo del tipo de sensor
#define DHTTYPE DHT11
 
// Inicializamos el sensor DHT11
DHT dht(DHTPIN, DHTTYPE);

Adafruit_BMP085 bmp;

const int LDRPin = A0; 
const int umbral = 100;
char msg0[3];
char msg1[3];
char msg2[3];
char msg3[3];
char msg4[3];
char msg5[3];
 
void setup() {
  // Inicializamos comunicación serie
  Serial.begin(9600);

  pinMode(LDRPin, INPUT);
  
  vw_set_tx_pin(12); 
  vw_setup(2000); // velocidad: Bits per segundo
  
  // Comenzamos el sensor DHT
  dht.begin();
  if (!bmp.begin()) {
  Serial.println("Could not find a valid BMP085 sensor, check wiring!");
  while (1) {}
  }
 
}
 
void loop() {
    // Esperamos 1 segundos entre medidas
  delay(1000);
  
  // Leemos la humedad relativa
  float h = dht.readHumidity();
  // Leemos la temperatura en grados centígrados (por defecto)
  float t = dht.readTemperature();
  // Leemos la temperatura en grados Fahreheit
  float f = dht.readTemperature(true);

  
 
  // Comprobamos si ha habido algún error en la lectura
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Error obteniendo los datos del sensor DHT11");
    return;
  }
 
  // Calcular el índice de calor en Fahreheit
  float hif = dht.computeHeatIndex(f, h);
  // Calcular el índice de calor en grados centígrados
  float hic = dht.computeHeatIndex(t, h, false);

   // Leemos la cantidad de luz
  int input = analogRead(LDRPin);

 itoa(h, msg1, 10);                  // Converting humidity to an array of chars
 itoa(t, msg0, 10);                   // Converting the temperature to an array of chars  
 itoa(f, msg2, 10);
 itoa(hif, msg3, 10);
 itoa(hic, msg4, 10);
 itoa(input, msg5, 10);
 strcat(msg0, msg1);                    // Adding/joining the two arrays
 strcat(msg3, msg4); 
 strcat(msg2, msg5); 
 vw_send((uint8_t *)msg0, strlen(msg0)); // Sending the msg
 vw_send((uint8_t *)msg3, strlen(msg3));
 vw_send((uint8_t *)msg2, strlen(msg2));
 vw_wait_tx();                         // Wait for tx to finish
 
  
  Serial.print("Humedad: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.println(" *F");
  
  Serial.print("Temperatura: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.println(" *F");
  
  Serial.print("Indice de calor: ");
  Serial.print(hic);
  Serial.print(" *C ");
  Serial.print(hif);
  Serial.println(" *F");
  
  Serial.print("Presion = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pa"); 
  // Calculate altitude assuming 'standard' barometric
  // pressure of 1013.25 millibar = 101325 Pascal
  Serial.print("Altura = ");
  Serial.print(bmp.readAltitude());
  Serial.println(" metros");
  // you can get a more precise measurement of altitude
  Serial.print("Altura Real = ");
  Serial.print(bmp.readAltitude(101500));
  Serial.println(" metros");
 
  Serial.print("El valor de luz es: ");
  Serial.print(input);
  Serial.println();
  delay(500);
 
}
//Receiver
#include <Wire.h>                 
#include <LiquidCrystal.h> 
#include <VirtualWire.h> 

int tem = 0;
int i;
 
const int rs=13, en=8, d4=5, d5=4, d6=3, d7=2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
      
void setup() {
  
  Serial.begin(9600);
  Serial.println("Iniciando...");
  lcd.begin(16,2);
  lcd.clear();

  // Se inicializa el RF
  vw_set_rx_pin(11);
  vw_setup(2000);  // velocidad: Bits per segundo
  vw_rx_start();   // Se inicia como receptor   
}

void loop() {
 
 uint8_t buf[VW_MAX_MESSAGE_LEN];      // Variable to hold the received data
 uint8_t buflen = VW_MAX_MESSAGE_LEN;  // Variable to hold the length of the received data
 delay(1000);
 lcd.setCursor(0,0);  
 lcd.print("Temp: ");
 if (vw_get_message(buf, &buflen))    // If data is received
 {
   for (i=0;i<2;i++)               // Get the two first bytes
 {
 Serial.write(buf[i]);                // Debugging purpose
 lcd.write(buf[i]);                   // Write the first bytes on the LCD
 }  
 Serial.println();                    // Debugging purpose
 lcd.write(1);                        // Write the degree symbol on the LCD
 lcd.print(" C"); 
 lcd.setCursor(0,1);
 lcd.print("Hum:  "); 
   for (i=2;i<4;i++)              // Get the two last bytes
   {
     Serial.write(buf[i]);                // Debugging
     lcd.write(buf[i]);                    // Write the last bytes on the LCD
   }
 Serial.println();   
 lcd.print("% RH");      
 }
}

It only prints the last array sent by the transmitter, any help will be appreciate it!

If you send them as concatenated strings, how will you tell where each starts and stops is which at the other end?

Tx:

typedef struct 
 {
     float h;
     float t;
     float f;
 } PACKET;

PACKET packet;
packet.h = ....;
packet.t =....;
packet.f = ....;
vw_send((uint8_t *)packet, sizeof(packet));

Rx:

 typedef struct 
 {
     float h;
     float t;
     float f;
 } PACKET;

PACKET packet;
if (vw_get_message(packet, &buflen))
{
  Serial.println(packet.h);
  Serial.println(packet.t);
  Serial.println(packet.f);
}

Sorry, im still a bit lost this string/arrays subject is new to me. Where on my code should I add the typedef struct? Also I want to send hic, hif and input(from LDR sensor) to the receiver, since Im already receiving t and h.

Thank you!

caliael:
Sorry, im still a bit lost this string/arrays subject is new to me. Where on my code should I add the typedef struct? Also I want to send hic, hif and input(from LDR sensor) to the receiver, since Im already receiving t and h.

typedef struct usually goes at the top, like a global.
You can add extra fields to the struct if you want. It should be obvious how to do that.

Thank you

PACKET packet;
packet.f = f;
packet.input = input;
packet.hic = hic;
packet.hif = hif;
vw_send((uint8_t *)packet, sizeof(packet));

invalid cast from type 'PACKET' to type 'uint8_t* {aka unsigned char*}'

I get this error when I compile.

This line in the receiver code guarantees that you will miss messages, and otherwise serves no useful purpose:

delay(1000);

Instead of

vw_send((uint8_t *)msg2, strlen(msg2));

I suggest

vw_send((uint8_t *)msg2, sizeof(msg2));

because that way, you preserve the zero terminating byte of the C-string, and can use C-string handling routines to decode the messages.

Even easier, send all the data in one message, created in one line of code, using snprintf().

My bad. Sorry. Try...

 vw_send((uint8_t *)&packet, sizeof(packet));

Thank you guys, I could solve the problem.