I'm working with VirtualWire and I'm trying to get a string value out of the Serial.println in the loop. I've tried create a string and add the message[i] , but surprisingly message[i] becomes an int when added. Serial.println outputs the string correctly, but the string that I get from message[i] is just numbers...
#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
String sensorname;
void setup(){
Serial.begin(9600);
Serial.println("Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop(){
if (vw_get_message(message, &messageLength)){
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++){
Serial.write(message[i]);
sensorname += message[i];
}
Serial.println();
Serial.pintln("Name of sensor: " + sensorname);
sensorname=""; //Reestart the string
}
}
I'm quite new with VirtualWire so I don't know if there is command to get the message and pass it directly to string...Any help will be appreciated!
EDIT I think I dind't express myself well. In my original question I didn't add the String sensor name
The Response I get in the Serial is the following:
Device is ready
SensorA
Name of sensor: 8310111011511111465
My aim is to instead of having as sensorname=8310111011511111465, have sensorname=SensorA