Hi, I'm working with a custom board using the Atmega328PB with a RFM69HCW 915 MHz radio module.
I have two boards, one is TX, the other RX.
They send data back and forth using the example code given by the Radiohead Packet Library, and I have verified the hardware.
The examples show how to send known data, I am having trouble sending variables.
This works (from the TX example), and the LED blinks on the RX to show that it works:
void loop() {
char radiopacket[20] = "Hello World #";
itoa(packetnum++, radiopacket+13, 10);
Serial.print("Sending "); Serial.println(radiopacket);
rf69.send((uint8_t *)radiopacket, strlen(radiopacket)); // Send a message!
// \param[in] data Array of data to be sent
// \param[in] len Number of bytes of data to send (> 0)
// \return true if the message length was valid and it was correctly queued for transmit
This does not send the variable sensorValue:
void loop() {
int sensorValue = analogRead(A2);
char radiopacket[10];
snprintf(radiopacket, sizeof(radiopacket), "ADC:%d", int(sensorValue));
rf69.send((uint8_t *)radiopacket, strlen(radiopacket)); // original code byte, strlen (returns long int)
// \param[in] data Array of data to be sent
// \param[in] len Number of bytes of data to send (> 0)
// \return true if the message length was valid and it was correctly queued for transmit
It seems that rf69.send is needed to send the data, but I don't know how to get it into the correct format.
Thanks in advance!