Hallo everybody,
i am working on a home automation solution using several pro minis, that (in the first step) send data from sensors via 433 RF (VirtualWire) to a transmitter. Everything works perfectly, but I don't want to send too much obvious data through the network ('window is open', 'window is closed'). Instead I want to use little 4-digit-codes, which the transmitter should 'decode' and write a status in the console.
Something like
1234 = Bathroom window is open
9876 = Living room window is closed
The Challenge: I am able to send variables through VirtualWire, but only as char and I don't know how to convert the char-data back into a variable that can be used to print a status into the console.
I am sending the data as followed:
int windowClosed = 1043;
int windowOpen = 7293;
char msg[24];
sprintf(msg, "%i.%i", windowClosed);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
At the moment the transmitter reads the data like this:
for (i=0;i< buflen;i++) {
Serial.print((char)buf[i]);
But I want to do something like that:
if ((char *)buf == 1043) {
Serial.println("The bathroom window is closed");
}
Of course the '1043' can not be used like that at the moment, because it is still text. Does anyone know how I can convert the digits into a variable again, so that I can use it like in my example?
Thanks for help!