1

I'm trying to send and receive some data from arduino to another arduino and I'm using arduino UNO and FS1000A / XY-MK-5V 433Mhz TX/RX Modules. For transmitting I use the library VirtualWire and It works very well for this code:

#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','!'};
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  delay(1000);
}

I was wondering if I want to send some string or int data how I can do that. I tried to use it for string data but I couldn't because the Input of function vw_send(...) is char and I couldn't use int or string. finally I run this code:

#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
void loop()
{
  char msg[11]="Hello there";
  vw_send((uint8_t *)msg, 11);
  vw_wait_tx(); // Wait until the whole message is gone
delay(1000);
}

and I could send Hello there !, but I'm looking for the correct way for sending string and int.

1

Have a look at the Easy Transfer library. I haven't used the particular modules you have, however I did successfully use the EasyTransfer library with Ciseco wireless modules. In essence the EasyTransfer library transmits the data as a structure with the same format on each module. The structure can contain any data type.

  • Would you please give me the link of this library? – ReD Feb 27 '17 at 0:59
  • How can I choose the library? there is a lot of library about one subject! – ReD Feb 27 '17 at 0:59
  • Hi, just Google Arduino EasyTransfer library that will provide links to the actual library and other various questions / comments / answers. There is only one EasyTransfer library. Study the available on line information and I am certain you will achieve your objectives. – Bob Croft Mar 1 '17 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.