RF433mHz module VirtalWire how to send float data properly?

Status
Not open for further replies.

bigplik

Member
hi, I wanted to use code I used for arduino for wireless transmission for RF433mHz module
with VirtualWire and DataCoder library, I've put those library files in attachment,
there is also two example files (RFDataRxn433Mhz.ino, RFDataTxn433Mhz.ino) for transmission and receiving data,

I used DataCoder library because it is written to use easily float numbers,
it is working with arduino very well, but when I try to use this with teensy I've got wrong numbers on the
receiving side (not sure, maybe transmission side is also affected),
I used teensy3.2 on the transmission side and tendyLC on the receiving side,
code is complied, I can upload it to both boards but not getting right numbers at serial monitor,

I even try to use arduino to receive the data when sending them by teensy3.2 (also wrong numbers)
and sending data by uno and receiving them by tensyLC but without success.

I really appreciate help in this case, I need to send float numbers by this module, "char example" from teensy web is working,
I checked but for my purposed I need code to send float data.
Not sure is better to modify DataCoder library or there is some possibility to use VirtualWire code from teensy web, after some
modifications and then send float numbers?
 

Attachments

  • VirtualWire.cpp
    23.5 KB · Views: 138
  • VirtualWire.h
    20 KB · Views: 318
  • VirtualWire_Config.h
    4.5 KB · Views: 81
  • DataCoder.cpp
    1.5 KB · Views: 127
  • DataCoder.h
    2.1 KB · Views: 178
  • RFDataRxn433Mhz.ino
    1.3 KB · Views: 92
  • RFDataTxn433Mhz.ino
    731 bytes · Views: 101
  • libraries.zip
    31.4 KB · Views: 196
Last edited:
A zip can be uploaded rather than 7 downloads.

My guess is somewhere on 8 bit AVR a default data type is represented differently on 32 bit ARM. Perhaps check that 8 bit values use uint8_t, 16 bit uses uint16_t, 32 bit uses uint32_t - and drop the 'u' for signed as needed.
 
A zip can be uploaded rather than 7 downloads.

My guess is somewhere on 8 bit AVR a default data type is represented differently on 32 bit ARM. Perhaps check that 8 bit values use uint8_t, 16 bit uses uint16_t, 32 bit uses uint32_t - and drop the 'u' for signed as needed.

In addition to the integer types, be sure to use the type float everywhere and not double. On the AVR processors, double is implemented to have the same representation as float (which takes 4 bytes). On the ARM processors like the Teensy 3.x/LC, double uses the IEEE 754R specification for 8-byte floating point. If you transmit a double between an AVR and ARM, you will not get what you expect.

If you are transmitting structures, note that each compiler might align the sub-fields differently. So, if you transmit a structure as a binary blob, you may not get what you expect.
 
I changed code in library files of DataCoder for uint16_t instead of uint8_t, but it is still not working,
I even couldn't compile the code in IDE when changed those files, but ArduinoIDE
didn't give me feedback with an error, just that it can't compile it,

now I try to deal with the VirtualWire,
hope this will work
 
Status
Not open for further replies.
Back
Top