system
1
Hi,
I'm trying to send a message over a wireless module,
I need to send a string of text but i'm getting a error:
How do i fix this problem?
sketch_apr28a.ino: In function 'void loop()':
sketch_apr28a:14: error: cannot convert 'String' to 'const char*' in initialization
#include <VirtualWire.h>
void setup()
{
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_tx_pin(3); // Arduino pin to connect the receiver data pin
}
void loop()
{
String message = "Test";
const char *msg = message;
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // We wait to finish sending the message
delay(200); // We wait to send the message again
}
system
3
How do i solve this?
ZenderWeer.ino: In function 'void loop()':
ZenderWeer:19: error: invalid conversion from 'int' to 'char*'
#include <VirtualWire.h>
#include <dht.h>
#define dht_dpin A0
dht DHT;
void setup()
{
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_tx_pin(3); // Arduino pin to connect the receiver data pin
}
void loop()
{
DHT.read11(dht_dpin);
int temp = (DHT.humidity);
char* temperature = temp;
const char *msg = temperature;
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // We wait to finish sending the message
delay(200); // We wait to send the message again
}
system
4
Don't have two variables in the same scope with the same name
system
5
Sorry, didn't see i updated the message.
ZenderWeer.ino: In function 'void loop()':
ZenderWeer:19: error: invalid conversion from 'int' to 'char*'
system
7
Yes.... But how? can you give me a fix?
system
8
Yes.... But how? can you give me a fix?
You got a hint. Now, pretend that you really want to learn, and google those two functions.