Invalid conversion from char to char*(VirtualWire)

Well, it took a good mental struggle to understand some of the VirtualWire transmitter and receiver code for 433mhz RF kits.. and well
it's still an uphill battle! Slowly but surely I'm overcoming the battle!

But now I'm at a standstill as far as sending any other information than a message. ie "hello" will print out hello on the receiving end (in HEX in the example, remove the HEX part and you'll receive just the letters).

So I'm able to send a few messages depending on some key presses at the moment, but I would like to be able to send a message from my computer over Serial, to the receiver connected to an LCD(not coded in yet, so Serial.print works fine) but every time I try to use Serial.read to set up a variable, I get the error Invalid conversion from char to char* I'm sure I'm missing something.. just not sure what!

Here's what I have for my transmitter and receiver, hopefully it's not too messy! And PLEASE, any tips/info/hinters on better ways to code is appreciated.

Everything works great.. I'm able to send the 2 messages I have, but I'm confused on how to add in the ability to send information on the transmitting end via Serial.

And changing the *msg from const char to just a char on the Transmitting side works fine when it's not trying to use Serial.read(). So I'm pretty sure it's not the fact that I changed it to a variable, maybe?:smiley:

Transmitter

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round

#define buttonpin 7
#define buttonpin2 8

void setup()
{
    digitalWrite(buttonpin, HIGH);
    digitalWrite(buttonpin2, HIGH);
    pinMode(buttonpin, INPUT);
    pinMode(buttonpin2, INPUT);
    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()
{
    [glow]char message = Serial.read();[/glow]
    byte button = digitalRead(buttonpin);
    delay(20);
    byte button2 = digitalRead(buttonpin2);
    delay(20);
    const char *msg = "hello";
    const char *msg2 = "ooooo";
    [glow]char *msg3 = message;[/glow] // here's my error

if (button == LOW && button2 == HIGH) {
    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);
    delay(200);
}else{vw_wait_tx();}

if (button2 == LOW && button == HIGH){
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg2, strlen(msg2));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}else{vw_wait_tx();}

if (button2 == LOW && button == LOW){
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg3, strlen(msg3));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(200);
}else{vw_wait_tx();}
}

Receiver

// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
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

    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(buf[i], HEX);
          Serial.print(" ");
      }
      Serial.println("");
        digitalWrite(13, false);
    }
}

Hi,

the problem is as follows:

char *msg3 defines a pointer to a char character. Then you try to copy a character to a pointer. You should instead use the following code:

char msg3;
msg3
= &message;

This gives no compiler error! But you can leave this two lines out
and make the following changes to you code (please note 1. check if a character is received, 2. Serial.read() reads always 1 character):

if (Serial.available()) // otherwise you will get -1 in message
{
char message = Serial.Read();
...
vw_send((uint8_t *)&message, 1); // Serial.read() reads always 1 character
...

Good luck
Mike