No matching function for call to 'RH_RF95::send(uint16_t [3], unsigned int)'

hello team,

will be really great if anyone can help me to resolve my issue !!!!

Code am using:

#include <SPI.h>
#include <RH_RF95.h>
#include <String.h>
#include <dht.h>
#include <inttypes.h>
#include <stdint.h>

#define dht_apin A1

const PROGMEM uint16_t data[3];

dht DHT;

RH_RF95 rf95;

byte bGlobalErr;
String stringOne;
float frequency = 916.0;

void setup()
{
Serial.begin(9600);
if (!rf95.init())
Serial.println("init failed");
// Setup ISM frequency
rf95.setFrequency(frequency);
// Setup Power,dBm
rf95.setTxPower(13);

}

void loop()

{

DHT.read11(dht_apin);

Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.println("% ");

Serial.print("Current Temperature = ");
Serial.print(DHT.temperature);
Serial.println("c ");

delay(100);

int val;
val = analogRead(0); //connect sensor to Analog 0
Serial.print("Moisture Level: "); //print the value to serial port
Serial.println(val);

delay(100);

const int AirValue = 520; //you need to replace this value with Value_1
const int WaterValue = 260; //you need to replace this value with Value_2
int intervals = (AirValue - WaterValue) / 3;
int soilMoistureValue = 0;
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
if (soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
{
Serial.println("Very Wet");
}
else if (soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
{
Serial.println("Wet");
}
else if (soilMoistureValue < AirValue && soilMoistureValue > (AirValue - intervals))
{
Serial.println("Dry");
}
delay(100);

typedef uint16_t UINT16;

uint16_t data[3];
data[1] = (DHT.humidity);
data[2] = (DHT.temperature);
data[0] = (val);
Serial.println(data[0]);
Serial.println(data[1]);
Serial.println(data[2]);
rf95.send(data, sizeof(data));

rf95.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf95.waitAvailableTimeout(3000))
{
// Should be a reply message for us now
if (rf95.recv(buf, &len))
{
Serial.print("got a reply: ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf95.lastRssi(), DEC);
}
else
{
Serial.println("recv failed");
}
}
else
{
Serial.println("No reply, is LoRa server running?");
}
delay(30000);
}

Its throwing me an error

no matching function for call to 'RH_RF95::send(uint16_t [3], unsigned int)'

My understanding is I have to use 2 bytes of data for my soil sensor but when I declare as uint16_t its throwing this error

Start here. Pay particular attention to Item #6.

Post your complete error message.

error message for me is : no matching function for call to 'RH_RF95::send(uint16_t [3], unsigned int)'

Soil moisture reading is 259 but its only transmitting value as 3 as I am declaring my data in uint8_t but when i am changing it to uint16_t the above error is displaying

You didn't repost your code using Code Tags as advised in the link I provided.

You didn't post the complete error message as requested. The complete error message (in the black window at the bottom of the Arduino IDE) contains a lot more useful information than the snippet you provided. Either select and copy the complete error message in the window or use the button provided.

Following forum guidelines makes it easier for people to help you. Since they are volunteering to do this for free, making it easier is conducive to getting more and better help.

C:\Users\Shubhrika\Desktop\Project\Thing_Speak\Smart_Farming\DHT11_SEN0193_client\DHT11_SEN0193_client_main\DHT11_SEN0193_client_main.ino: In function 'void loop()':

DHT11_SEN0193_client_main:92:31: error: no matching function for call to 'RH_RF95::send(uint16_t [3], unsigned int)'

rf95.send(data, sizeof(data));

^
Am sorry,

I am new to Arduino and coding :frowning:

here is the entire snippet of my error message

In file included from C:\Users\Shubhrika\Desktop\Project\Thing_Speak\Smart_Farming\DHT11_SEN0193_client\DHT11_SEN0193_client_main\DHT11_SEN0193_client_main.ino:2:0:

C:\Program Files (x86)\Arduino\libraries\RadioHead/RH_RF95.h:677:21: note: candidate: virtual bool RH_RF95::send(const uint8_t*, uint8_t)

virtual bool send(const uint8_t* data, uint8_t len);

^

C:\Program Files (x86)\Arduino\libraries\RadioHead/RH_RF95.h:677:21: note: no known conversion for argument 1 from 'uint16_t [3] {aka unsigned int [3]}' to 'const uint8_t* {aka const unsigned char*}'

exit status 1
no matching function for call to 'RH_RF95::send(uint16_t [3], unsigned int)'

1 Like

Opened at the request of the OP so he/she can add comments.

Hey Sreebharan,

This error is thrown because the RH_RF95 package's send function accepts the type of uint8_t as first argument by default, not uint16_t as you use here. Refer here for potential fix.

Best,
ER