I am trying to get diferent readings from a NPK_sensor. To do this I build a function that uses the bytes to comunicate with the sensor. Using SoftwareSerial I need to send three diferent chains of bytes. The code compiles but shows warnings and notes. I have not been able to test the code because Im waiting for a 12V power suply to use the sensor. Anyway I would like to know if what imtrying to do is posible.
The warnings are the following
warning: invalid conversion from 'const byte* {aka const unsigned char*}' to 'byte* {aka unsigned char*}' [-fpermissive]
N = npk_read(NREQUEST,sizeof(NREQUEST));
note: initializing argument 1 of 'int npk_read(byte*, int)' int npk_read(byte request[8],int request_size){
This are the relevant parts of my code:
#include <SoftwareSerial.h>
SoftwareSerial npk_serial(RO,DI);
const byte NREQUEST[] = {0x01,0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
byte soil_values[8];
void setup() {
npk_serial.begin(9600);
}
void loop(){
N = npk_read(NREQUEST,sizeof(NREQUEST));
}
int npk_read(byte request[8],int request_size){
int reading;
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(npk_serial.write(request,request_size)==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<request_size;i++){
soil_values[i] = npk_serial.read();
}
if(CHECKRESPONSE[0] == soil_values[0] && CHECKRESPONSE[1]== soil_values[1] && CHECKRESPONSE[2]== soil_values[2] ){
reading= int(soil_values[3])+int(soil_values[4]);
}
else{
reading = 9999;
}
}
return reading;
}