Hi. I´m new to Arduino and my skills are very basics. This is for a school project and my teacher didn't want to tell me to much, I have tried to do the things that he told me, but I´m not understanding what to do!
Here I have posted just a little part of my transmitter code, but this part of the code is used to convert from a float to a string and then send it with the RF transmitter(the code on the receiver side is working fine).
This code on the transmitter is working great, I get the string on the receiver side which then prints the temperature values and the pressure values on a LCD, so far everything is good. But the code is not perfect, instead of sending "vw_send((uint8_t *)tempconvert, strlen(temconvert);", I´m sending it as "vw_send((uint8_t *)tempconvert, 10);"(for some reasons that i have not explained here) and my teacher didn´t like that I send it like that. He said that it would be a risk that the readings would come in an random order, but this is not the case, because I have been "looking" at it over a significant period of time and the values are always received in the same order. So it prints f.ex. 22.13 for the temperature and 14.78 for pressure. But I´m actually sending "tempconvert" and "pressconvert" all together as "vw_send((uint8_t *)tempconvert, 10);", but it still includes the whole string when transmitting(not perfect code, right?).
So, my teacher said to make an array of 10 char, since I want to send float's(f.ex: 22.13 for temp and 14.78 for pressure) and still use the "dtostrf". But I need help in writing this as an array that can be transmitted to the receiver.
Thank's!
void loop()
{
float temperature = getTemp();
float pressure = getPress();
char tempconvert[5];
dtostrf(temperature, 5, 2, tempconvert);
char pressconvert [5];
dtostrf(pressure, 5, 2, pressconvert);
vw_send((uint8_t *)tempconvert, 10);
vw_wait_tx(); // Wait to finish sending
}