I'm learning Arduino's world, but knowing very little about C and C++.
I'm trying to achieve a little RF transmitter which should send the temperature and humidity from a DHT-11 sensor to a Raspberry Pi.
I'm using the RCSwitch
library to send information with the Arduino, and the 433Utils
library to receive it on the RPI.
Using those 2 libraries demos, I was able to send an integer, holding temperature or humidity information (mySwitch.send("00001010");
), and read it on the RPI.
But how can I send both informations so that the RPI will know which one is the temperature and the humidity ?
I know I could just send both and assume the lowest is the temperature, but this would be very messy and not very rewarding.
EDIT :
Following Edgar's answer in https://arduino.stackexchange.com/a/52992/11604, I know write:
void send_string(const char *str){
int i = 0;
for (char *p = str; *p; p++ ) {
mySwitch.send((i<<8) + *p, 16);
i++;
}
}
void loop() {
delay(1000);
h=40.650;
t=32.0078;
hic=33.586;
String x = "$H" + String(h) + "T" + String(t) + "HI" + String(hic);
send_string(x.c_str());
}
Works perfectly ! (see his complete answer for the RPI-side code)
mySwitch.send("T45H50");
,mySwitch.send("[45;50]");
,mySwitch.send("T45"); mySwitch.send("H50");
...send()
method take either an integer, a string byte representation or a tri-state code, I cannot send a string directly