Virtual Wire sending floats

2 replies [Last post]
Providence, United States
Joined: 9 Jan 2010


I don't know what you did with that post as its disappear from the forums as I was replying - Please don't change the title once you have submitted otherwise the post will get lost.

Anyway to answer your question.

Why do you need to convert to a string?

float temp_c;
vw_send((uint8_t *)&temp_c, sizeof(float));

I've not tried that but I can't see why you need to even bother converting you are just making life hard for yourself.  Send the binary reprentation of the float object directly and then cast back on the other side.

char buf[sizeof(float)];
int len = sizeof(float);
float temp_c;

if (vw_get_message(buf, &len)) {
   temp_c = (float)buf;

I've not tried this btw.

Ayr, United Kingdom
Joined: 25 Sep 2011
I'll check it out.


Thanks for your reply. I'll check it out and see if works.

Sorry about deleting the post while you were working on it.
I'm afraid that I'm trying to do everything on a mobile phone
at the moment and I double posted and then it would appear
that I double deleted as well! Doh!


Ayr, United Kingdom
Joined: 25 Sep 2011
I've remembered

I've remembered why I didn't just use the float to transmit, it's because I'm a complete novice when it comes to C programming. I have a sketch which will sucessfully transmit and receive string data using virtualwire and whilst I'm very grateful for your suggestion it led me into an hour of head scratching because it doesn't seem to be using the right data types or something.

I think that the vw_get_message call requires uint8_t data types and it is being called with char and int data types which causes the compiler to fail.

Anyway, suffice to say, I can now sucessfully transmit the integer part of the temperature as a string so I should be able to pick it up with the livebox.

Thanks for your input.



Hardware Info