I tried building a simple wireless communication on arduino unos using 315mhz transmitter/ receiver modules with Radiohead library which I found online.
here is a code for transmitter
// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>
// Create Amplitude Shift Keying Object
RH_ASK rf_driver;
void setup()
{ Serial.begin(9600);
// Initialize ASK Object
rf_driver.init();
}
void loop()
{
const char *msg = "welcome";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
delay(10);
Serial.println(strlen(msg));
}
In the code for transmitter I dont understand what exactly this line does.
rf_driver.send((uint8_t *)msg, strlen(msg));
And here's code for receiver
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>
// Create Amplitude Shift Keying Object
RH_ASK rf_driver;
void setup()
{
// Initialize ASK Object
rf_driver.init();
// Setup Serial Monitor
Serial.begin(9600);
}
void loop()
{
// Set buffer to size of expected message
uint8_t buf[7];
uint8_t buflen = sizeof(buf);
// Check if received packet is correct size
if (rf_driver.recv(buf, &buflen))
{
// Message received with valid checksum
Serial.print("Message Received: ");
Serial.println((char*)buf);
delay(1000);
}
}
What function does the following line serve in this code especially : ((char*) buff ) what is it doing ??
Serial.println((char*)buf);
Can someone please explain this in detail.