Need help regarding Simple RF 433MHz

Hello everyone,

I am currently doing a school project on train station. I will need to apply Transmitter on a station and Receiver on a train. When the train goes pass a station, my e-paper display should show the corresponding station name.

However, I have face a difficulty whereby my e-paper display does not show the station name. It might be due to my code configuration in Receiver unit. Please help me in solving my coding.

All relevant codes and samples are extracted from the seed-studio wiki library. The e-paper and simple RF 433MHz have been tested to work properly.

Transmitter Code:

#include <VirtualWire.h>

    int RF_TX_PIN = 7;

    void setup()
    {
      vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
      vw_setup(2000); // Transmission speed in bits per second.
    }

    void loop()
    {
      const char *msg = "Buona Vista";
      vw_send((uint8_t *)msg, strlen(msg)+1); //edited to add +1 for solution
      delay(1000);
    }

Receiver Code:

#include <ePaper.h>
#include <SPI.h>
#include <SD.h>
#include "GT20L16_drive.h"
#include <VirtualWire.h>

#define SCREEN_SIZE 270
#define EPD_SIZE EPD_2_7

int RF_RX_PIN = 8;
    
void setup()
{
    EPAPER.begin(EPD_SIZE);                             // setup epaper, size 
    EPAPER.setDirection(DIRNORMAL);                     // set display direction
    
    eSD.begin(EPD_SIZE);                                   
    GT20L16.begin();

    Serial.begin(9600);
    Serial.println("Start Receiving");
    vw_set_rx_pin(RF_RX_PIN);  // Setup receive pin.
    vw_setup(2000); // Transmission speed in bits per second.
    vw_rx_start();
}

void loop()
{
      uint8_t buf[VW_MAX_MESSAGE_LEN];
      uint8_t buflen = VW_MAX_MESSAGE_LEN;
      int i;
      
      if(vw_get_message(buf, &buflen))
      {
        Serial.print("Received Data");
        Serial.println("");
        for(i = 0; i < buflen; i++)
        {
        Serial.print((char)buf[i]);
        }
        Serial.println("");
        
        EPAPER.drawStringBig((char)buf[i], 40, 60);  //Error lies here for not displaying
        EPAPER.drawStringBig("Station", 70, 95);
        EPAPER.display();
      }
}

Using the serial monitor, I am able to properly display “Buona Vista”. However, this does not happen for my e-paper display. When running, the e-paper have a rough display of “i :” followed by “Station”. As I will be having multiple stations, multiple transmitters of the same type will be used. An ideal case of successful coding for me will be to simply change “Buona Vista” in Transmitter Code to other names.

I have a LCD RGB Backlight display as an alternative should the e-paper is unsolvable.
I’ll greatly appreciate all helps and suggestions. Thank you!

Solved (Refer to code below):

EPAPER.drawStringBig(buf, 40, 60); //instead of using buf[i]
EPAPER.drawStringBig("Station", 70, 95);
EPAPER.display()

Does drawStringBig expect a char pointer as a parameter, or a String class object?

aarg:
Does drawStringBig expect a char pointer as a parameter, or a String class object?

I’m not sure about this as I am relatively new to coding. The guide for e-paper display recommended to use “Message”, just like how i input “Station”. I am trying to explore a way to read and display message sent from Transmitter.

chinx:
I'm not sure about this as I am relatively new to coding. The guide for e-paper display recommended to use "Message", just like how i input "Station". I am trying to explore a way to read and display message sent from Transmitter.

What does the library documentation say? "Message" can't be right, it's just another string like "Station".

aarg:
What does the library documentation say? “Message” can’t be right, it’s just another string like “Station”.

Hello aarg,

I went to the arduino library under ePaper.h and manage to search for it.

int drawStringBig(char *string, int poX, int poY);

Alternatively, I also came upon drawCharBig. I tried to input both (char)buf and buf to it but the display return blank, followed by the word “Station”.
* int drawCharBig(char c, int x, int y);*
I also tried using if as another alternative. Although it display “Buona Vista” at first, it changes to “BOne-Northa”. I am guessing that both if were fulfilled, and that is why the code runs. I have input the code below should there be of any help or easier solution.
```
*      if(vw_get_message(buf, &buflen))
      {
        Serial.print(“Received Data”);
        Serial.println("");
        for(i = 0; i < buflen; i++)
        {
        Serial.print((char)buf[i]);
        }
        Serial.println("");

if(buf[i] = “Buona Vista”)
        {
        EPAPER.drawStringBig(“Buona Vista”, 40, 60);
        EPAPER.drawStringBig(“Station”, 70, 95);
        EPAPER.display();       
        }

if(buf[i] = “One-North”)
        {
        EPAPER.drawStringBig(“One-North”, 55, 60);
        EPAPER.drawStringBig(“Station”, 70, 95);
        EPAPER.display();
        }

}
_
```*_

Does your C string have the proper '\0' to end it?
You don't include it in the TX:

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

You need to either send it:

      vw_send((uint8_t *)msg, strlen(msg)+1);

or find a way to append it on the receiving end, before you print it. The length of a character string given by strlen() does not include the delimiting null (zero).

At least, that's how it looks to me without spending hours on it.

I have added:

vw_send((uint8_t *)msg, strlen(msg)+1);

as instructed by you. I also looked at the receiver end of the code. I have done certain tries and finally came up with a solution:

EPAPER.drawStringBig(buf, 40, 60); //instead of using buf[i]
EPAPER.drawStringBig("Station", 70, 95);
EPAPER.display();

Previously, I used 'buf i' on my c string, which cause the display to go wrong. Perhaps it has something to do with array. Nevertheless, I use 'buf' as an alternative and got it working. Thank you so much for helping me! Hope this post will help the rest who is facing the same problem as me in the future! :slight_smile: