Hello all, I'm working on a new module, Radio Lora Grove to send data between 2 arduino nano.
Indeed i wand to send some float value from a censor by this module.
I currently use 2 NRF and it works really good but i want to try and test new technologies such as LoRa.
Grove - Long Range 868MHz | Seeed Studio Wiki Here is module i use combined with an INA219 (current sensor).
So it works fine with the example given by the library Radio Lora Grove 433MHz.
But it has work only for a String. And when i want to send a float, the arduino IDE shows me some errors because the send function use to send a message take 2 parameters : uint8_t*, len uint8_t
Here is a part from the code of the Transmitter:
void loop()
{
ShowSerial.println("Sending to rf95_server");
// Send a message to rf95_server
uint8_t data[] = "Hello World";
rf95.send(data, sizeof(data));
What i want to do is to replace this "hello world" by a float. I have been trying for many hours now, Unions, cast, reinterpret_cast etc but maybe i just can't simply send a float by this module.
I thought i could transform a float type to an uint8_t but it is not that easy.
And here is the Receiver code:
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if(rf95.recv(buf, &len))
{
ShowSerial.print("got reply: ");
ShowSerial.println((char*)buf);
}
I have been looking where is this send function on headerfiles to understand how it works, i put it there.
template <typename T>
bool RH_RF95<T>::send(uint8_t* data, uint8_t len)
{
if (len > RH_RF95_MAX_MESSAGE_LEN)
return false;
this->waitPacketSent(); // Make sure we dont interrupt an outgoing message
setModeIdle();
// Position at the beginning of the FIFO
this->write(RH_RF95_REG_0D_FIFO_ADDR_PTR, 0);
// The headers
this->write(RH_RF95_REG_00_FIFO, this->_txHeaderTo);
this->write(RH_RF95_REG_00_FIFO, this->_txHeaderFrom);
this->write(RH_RF95_REG_00_FIFO, this->_txHeaderId);
this->write(RH_RF95_REG_00_FIFO, this->_txHeaderFlags);
// The message data
this->burstWrite(RH_RF95_REG_00_FIFO, data, len);
this->write(RH_RF95_REG_22_PAYLOAD_LENGTH, len + RH_RF95_HEADER_LEN);
setModeTx(); // Start the transmitter
// when Tx is done, interruptHandler will fire and radio mode will return to STANDBY
//this->write(RH_RF95_REG_12_IRQ_FLAGS, 0xff); // Clear all IRQ flags
return true;
}
and his prototype:
/// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
/// Then loads a message into the transmitter and starts the transmitter. Note that a message length
/// of 0 is permitted.
/// \param[in] data Array of data to be sent
/// \param[in] len Number of bytes of data to send
/// \return true if the message length was valid and it was correctly queued for transmit
virtual bool send(uint8_t* data, uint8_t len);
Link of the githbug module : GitHub - Seeed-Studio/Grove_LoRa_433MHz_and_915MHz_RF
Any idea?
Thanks