RF message to LCD

Hi guys; i’m trying a simple thing actually but I’ve been testing and on here looking for answers for hours.

I want to display the message sent by RF module on the LCD.

Got the RF working, message is sent and received.
Got the display working, first line is filled with a value.
I can also display the received message in de debugging serial monitor.
but how can I display this value on the second line on the LCD?

Transmitter code which is working fine:

// Transmitter setup
// WRL-10534 PIN1=GND PIN2=DATA PIN3=5V PIN4=ANT
// ARDUINO UNO PIN12=DATA PIN13=LED
// Sends plain text message to 434MHz

  #include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);	  // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
    const char *msg = "hello";

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    Serial.println(msg);
    delay(2000);
}

Receiver code which has RF receiving and LCD working

// Receiver setup
// WRL-10532 PIN1=GND PIN2=DATA PIN4=5V PIN8=ANT
// ARDUINO UNO PIN2=DATA PIN13=LED
// Receives plain text message from 434MHz

#include <VirtualWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 10);

int Sensor1Data;
char Sensor1CharMsg[24];

void setup()
{
    pinMode(13,OUTPUT);
    digitalWrite(13,LOW);
  
    lcd.begin(16, 2);
    lcd.print("line1");

    Serial.begin(9600);	// Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       // Start the receiver PLL running
}

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

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
           Serial.print((char) buf[i]);
     	}
	Serial.println("");
        digitalWrite(13, false);
    }
}

Please show me how to display the message on the LCD.

Thanks in advance!

Not a coder, but try this.

lcd.setCursor(0, 1); // first character, second row
lcd.print((char) buf[i]);

Tried it: but where do I locate it?
The void loop is a reocurring program running frequently and doesn't even have time to display the value at a condition.
Delay is also no possible imo
and locate that part in the setup then you don't have that message content available.

Do you want to replace Serial.print with this, or have both.
Leo..

Wawa:
Do you want to replace Serial.print with this, or have both.
Leo..

Serial print is for debugging only

Put it w

paradoxlnx:
Tried it: but where do I locate it?
The void loop is a reocurring program running frequently and doesn’t even have time to display the value at a condition.
Delay is also no possible imo
and locate that part in the setup then you don’t have that message content available.

Put it in here - if that code is running, then the condition is true and there’s a new message. And if it’s not true, the code won’t run.

if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
           Serial.print((char) buf[i]);
     	}
	Serial.println("");
        digitalWrite(13, false);
    }

Also - I think you can use delay() with VW - delay() doesn’t prevent interrupts. Not that I think this is an appropriate time to use it. The delay() at the end of loop is usually not a good thing.

 lcd.begin(16, 2);
    lcd.print("line1");

the second for the second line of the display should go here:

for (i = 0; i < buflen; i++)
 {
           Serial.print((char) buf[i]);
            [LCD SECOND LINE CODE]
     }
 Serial.println("");
        digitalWrite(13, false);