RS 485 Multi sensor for Temperature, moisture, Conductivity and Ph

Hello, please I need your help with RS 485 Multi sensor for Temperature, moisture, Conductivity and Ph.
i have tried some codes but I recieved zero as a response.
This is the Sensor's datasheet
五插针土壤变送器(485型).pdf (2.7 MB)

Please, what other detail do I need to provide?
Below is the code I used

[code]
#include <SoftwareSerial.h>

#define RE 7
#define DE 6

const uint32_t TIMEOUT = 500UL;

//const byte code[]= {0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x44, 0x09};
const byte moist[] = {0x01, 0x03, 0x08, 0x02, 0x92, 0x57, 0xB6};
const byte temp[] = {0x01, 0x03, 0x08, 0xFF, 0x9B, 0x57, 0xB6};
const byte EC[] = {0x01, 0x03, 0x08, 0x03, 0xE8, 0x57, 0xB6};
const byte PH[] = {0x01, 0x03, 0x08, 0x00, 0x38, 0x57, 0xB6};


byte values[11];
SoftwareSerial mod(8, 9); // Rx pin, Tx pin

void setup() {
  Serial.begin(9600);
  mod.begin(9600);
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);

  delay(500);
}

void loop() {
  byte val1, val2, val3, val4;

  Serial.print("Soil moisture: ");
  val1 = moist[];
  Serial.print(val1);
  Serial.print(" %");
  delay(1000);

  Serial.print("Temperature: ");
  val2 = temp();
  Serial.print(val2);
  Serial.print(" *C");
  delay(1000);

  Serial.print("EC: ");
  val3 = EC();
  Serial.print(val3);
  Serial.print(" us/cm");
  delay(1000);

  Serial.print("PH: ");
  val4 = PH();
  delay(1000);
  Serial.print(val4);
  Serial.print(" ph");

  delay(5000);
}

byte moist[] {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(moisture, sizeof(moisture));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte temp[] {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(temp, sizeof(temp));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte EC[] {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(EC, sizeof(EC));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte PH[] {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(PH, sizeof(PH));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

void printHexByte(byte b)
{
  Serial.print((b >> 4) & 0xF, HEX);
  Serial.print(b & 0xF, HEX);
  Serial.print(' ');
}
[/code]

Interesting question that cannot be answered properly. I will take a SWAG and say it is termination on the RS485 links, try this link for help: https://www.ti.com/lit/an/snla049b/snla049b.pdf?ts=1678985130261&ref_url=https%253A%252F%252Fwww.google.com%252F. You say you get zero as a response is that a 0x00 or does that mean you received nothing?

@ogom is this a continuation (or repeat) of your previous question at:

In response to your PM, here is a simple bit of code you can try. I've not used it in a while but it may help you out:

// This attempt uses the SoftwareSerial & raw Modbus packets.
//
// RS485 module wired up as:
// RS485 DI signal to pin 3
// RS485 RO signal to pin 2
// RS485 RE signal to pin 7
// RS485 DE signal to pin 6
// RS485 VCC to 5V
// RS485 GND to GND
//
#include <SoftwareSerial.h>

#define RE 7
#define DE 6

const uint32_t TIMEOUT = 500UL;

// canned message to your RS485 device
// change this for any other canned modbus message you like
// remember to make sure that the checksum is correct!
uint8_t msg[] = {0x01, 0x03, 0x00, 0x05, 0x00, 0x01, 0x94, 0x0B};
uint8_t rxByte;

SoftwareSerial swSerial(2, 3); // Receive (data in) pin, Transmit (data out) pin

void setup() {
  Serial.begin(9600);
  swSerial.begin(9600);
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);
  delay(1000);
}

void loop() {
  uint32_t startTime = 0;

  Serial.print("TX: ");
  printHexMessage( msg, sizeof(msg) );

  // send the command
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay( 10 );
  swSerial.write( msg, sizeof(msg) );
  swSerial.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  Serial.print("RX: ");
  
  // read any data received and print it out
  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (swSerial.available()) {
      printHexByte(swSerial.read());
    }
  }
  Serial.println();
  delay(2000);
}

void printHexMessage( uint8_t values[], uint8_t sz ) {
  for (uint8_t i = 0; i < sz; i++) {
    printHexByte( values[i] );
  }
  Serial.println();
}

void printHexByte(byte b)
{
  Serial.print((b >> 4) & 0xF, HEX);
  Serial.print(b & 0xF, HEX);
  Serial.print(' ');
}

All it does is send a single canned modbus message out as defined in the msg array and waits for up to 0.5s for any response. Any bytes it receives are printed out. If you have your wiring correct, then you should see a response from the sensor - assuming that the sensor address is 1 and the canned message relates to a valid address.

I've hopefully tweaked the canned message for your sensor so you should get a response.

Also, I don't think that those canned modbus messages you are using have the right addresses in them for the sensor you are using.

1 Like

You define the enable pins for the RS485 link, but I don't see them passed to anything. That may be a hint. Is there perhaps a missing library?
Never mind, I see them now. Time for new glasses...

1 Like

Yes, A zero like 0.00

@markd833
Yes, it is a continuation.
This is a screen shot of the page of the addresses from the datasheet

I got the addresses from here

This is a description of my connection

Ah. You are likely to incur the wrath of the moderators if you start a second discussion on the same topic. By having 2 discussions, you can get conflicting/confusing advice as those trying to help you may not be aware of what has already been suggested.

This is definitely WRONG. Have a look at page 12 of your PDF at the host query frame structure. There are 8 bytes in the query frame, and you have only 7!

In addition, the last 2 bytes should be a CRC16 checksum, so can't be the same in all 4 messages.

1 Like

Good day Sir, I think my obstacle now is the addresses.
I have read and understood that I need
Address code- I have gotten this, 0x01.

Function code- I have gotten this, 0x03.

Register start address-I have gotten this, depending on the parameter you want to read.

Register length- 2byte =0x00, 0x02

Check code low- none

Check code high- none

From the datasheet, I can't find the Check code low and check code high values, I have during the course of the day, gone through different materials on how to go about it but I couldn't make a headway.
Please could you help see if you could direct me?

When taking code from the Internet, please reference the source as it helps with context.
In-Depth: Interfacing Soil NPK Sensor with Arduino (lastminuteengineers.com)

1 Like

How are the crc 16 checksum gotten? Randomly?

No. They are specific to the contents of the message you are trying to send.

To calculate the CRC16 value, see my post here:

1 Like

Thank you sooooo Much!

Finally, I got the addresses as you directed and the sensor is responding now. The readings are in Hexadecimal, i am looking for a way to convert them to decimal, please can you help me with it.

Below is the code I used:

#include <SoftwareSerial.h>

#define RE 7
#define DE 6

const uint32_t TIMEOUT = 500UL;

const byte moist[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
const byte temp[] = {0x01, 0x03, 0x00, 0x01, 0x00, 0x01, 0xD5, 0xCA};
const byte EC[] = {0x01, 0x03, 0x00, 0x02, 0x00, 0x01, 0x25, 0xCA};
const byte PH[] = {0x01, 0x03, 0x00, 0x03, 0x00, 0x01, 0x74, 0x0A};

byte values[11];
SoftwareSerial mod(8, 9); // Rx pin, Tx pin

void setup() {
  Serial.begin(9600);
  //  Serial.begin(4800);
  mod.begin(4800);
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);

  delay(500);
}

void loop() {
  byte val1, val2, val3, val4;

  Serial.println("Moisture: ");
  val1 = moisture();
  Serial.println(val1);
  Serial.println(" %");
  delay(1000);

  Serial.println("Temperature: ");
  val2 = temperature();
  Serial.println(val2);
  Serial.println(" *C");
  delay(1000);

  Serial.println("Conductivity: ");
  val3 = conductivity();
  delay(1000);
  Serial.println(val3);
  Serial.println(" us/cm");

  Serial.println("Ph: ");
  val4 = ph();
  delay(1000);
  Serial.println(val4);
  Serial.println(" ph");

  delay(5000);
}

byte moisture() {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(moist, sizeof(moist));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte temperature() {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(temp, sizeof(temp));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte conductivity() {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(EC, sizeof(EC));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

byte ph() {
  uint32_t startTime = 0;
  uint8_t  byteCount = 0;

  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  mod.write(PH, sizeof(PH));
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  startTime = millis();
  while ( millis() - startTime <= TIMEOUT ) {
    if (mod.available() && byteCount < sizeof(values) ) {
      values[byteCount++] = mod.read();
      printHexByte(values[byteCount - 1]);
    }
  }
  Serial.println();
  return values[4];
}

void printHexByte(byte b)
{
  Serial.print((b >> 4) & 0xF, HEX);
  Serial.print(b & 0xF, HEX);
  Serial.print(' ');
}

This is the response I got from the serial monitor

That's ok. The hexadecimal output is for debugging purposes and is a result of the call to printHexByte inside the while loop.

Luckily that debugging hex data is showing a problem. The debug output is showing an additional leading 0x00 and trailing 0x00. These are not part of the modbus response message.

You could try emptying the receive buffer before sending the request message. That may/should account for the leading 0x00.

Looking at pH, the response ignoring the leading 0x00 is:

01 03 02 00 3C B8 55 00

The actual pH reading is in the pair of bytes 00 3C which equates to 60 decimal. If your sensor is providing pH to 1 decimal place, then the reading is 6.0 which looks more realistic than 0.

You have several options:

  1. Assume the leading 0 is always present and adjust the code accordingly.
  2. Wait for the 1 to be received - that's the sensor address and is always the 1st byte of the response message
  3. Investigate the source of the spurious zeros.

There may be other options too, depending on how much time you wish to spend investigating.

I feel my head whirling :no_mouth:, I have gone through videos and websites, I haven't been able to tune the readings to decimal, please could you help me

Ok, so take a look at your screenshot in post #15.

You will see from your code that in each function that requests a parameter from the sensor, that there is the line:

return values[4];

This returns the 4th element from the array - i.e. the 5th byte (remember arrays start from 0) from the array of bytes received. If you look at the hexadecimal values printed for each parameter, you can see that the 5th byte is the value that is printed on it's own on the next line down. Look at moisture at the top of your screenshot. The 5th byte is 03 and the number 3 is returned by the moisture function. That is the number in decimal.

Now, if you go with my option (1) in post #16, and do nothing about the leading and trailing 00's, then the actual value you want for each parameter is held in bytes 4 and 5 as the value is a 16-bit number.

A 16-bit value can't be returned in a byte, so you need to change all your function calls to return an int16_t type:

int16_t moisture() { ...
int16_t temperature() { ...
etc

And at the end of each function, change the return to:

return (int16_t)(values[4]<<8 | values[5]);

Once you have the right decimal numbers being printed out, you can disable the hexadecimal output - remember that was just for debugging purposes. Simply comment out the call to printHexByte in each function.

1 Like

Thank you so much :pray:t6:

when i changed the function calls, it gave this error message

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

WARNING: Category 'other' in library DarkSkySevenDay is not valid. Setting to 'Uncategorized'
WARNING: Category 'Data processing' in library string_asukiaaa is not valid. Setting to 'Uncategorized'
C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'int16_t moist()':

max458_correction:14:64: error: expected ';' before '}' token

 int16_t moist() {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};

                                                                ^

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'int16_t temp()':

max458_correction:15:63: error: expected ';' before '}' token

 int16_t temp() {0x01, 0x03, 0x00, 0x01, 0x00, 0x01, 0xD5, 0xCA};

                                                               ^

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'int16_t EC()':

max458_correction:16:61: error: expected ';' before '}' token

 int16_t EC() {0x01, 0x03, 0x00, 0x02, 0x00, 0x01, 0x25, 0xCA};

                                                             ^

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'int16_t PH()':

max458_correction:17:61: error: expected ';' before '}' token

 int16_t PH() {0x01, 0x03, 0x00, 0x03, 0x00, 0x01, 0x74, 0x0A};

                                                             ^

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'byte moisture()':

max458_correction:71:33: error: no matching function for call to 'SoftwareSerial::write(int16_t (&)(), unsigned int)'

   mod.write(moist, sizeof(moist));

                                 ^

In file included from C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: candidate: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   candidate expects 1 argument, 2 provided

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\max458_correction.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note: candidate: size_t Print::write(const char*, size_t)

     size_t write(const char *buffer, size_t size) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const char*'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note: candidate: virtual size_t Print::write(const uint8_t*, size_t)

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const uint8_t* {aka const unsigned char*}'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note: candidate: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note:   candidate expects 1 argument, 2 provided

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'byte temperature()':

max458_correction:95:31: error: no matching function for call to 'SoftwareSerial::write(int16_t (&)(), unsigned int)'

   mod.write(temp, sizeof(temp));

                               ^

In file included from C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: candidate: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   candidate expects 1 argument, 2 provided

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\max458_correction.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note: candidate: size_t Print::write(const char*, size_t)

     size_t write(const char *buffer, size_t size) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const char*'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note: candidate: virtual size_t Print::write(const uint8_t*, size_t)

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const uint8_t* {aka const unsigned char*}'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note: candidate: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note:   candidate expects 1 argument, 2 provided

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'byte conductivity()':

max458_correction:119:27: error: no matching function for call to 'SoftwareSerial::write(int16_t (&)(), unsigned int)'

   mod.write(EC, sizeof(EC));

                           ^

In file included from C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: candidate: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   candidate expects 1 argument, 2 provided

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\max458_correction.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note: candidate: size_t Print::write(const char*, size_t)

     size_t write(const char *buffer, size_t size) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const char*'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note: candidate: virtual size_t Print::write(const uint8_t*, size_t)

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const uint8_t* {aka const unsigned char*}'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note: candidate: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note:   candidate expects 1 argument, 2 provided

C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino: In function 'byte ph()':

max458_correction:143:27: error: no matching function for call to 'SoftwareSerial::write(int16_t (&)(), unsigned int)'

   mod.write(PH, sizeof(PH));

                           ^

In file included from C:\Users\hp\Documents\Arduino\max458_correction\max458_correction.ino:2:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note: candidate: virtual size_t SoftwareSerial::write(uint8_t)

   virtual size_t write(uint8_t byte);

                  ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   candidate expects 1 argument, 2 provided

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\max458_correction.ino.cpp:1:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note: candidate: size_t Print::write(const char*, size_t)

     size_t write(const char *buffer, size_t size) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:57:12: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const char*'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note: candidate: virtual size_t Print::write(const uint8_t*, size_t)

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:56:20: note:   no known conversion for argument 1 from 'int16_t() {aka int()}' to 'const uint8_t* {aka const unsigned char*}'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note: candidate: size_t Print::write(const char*)

     size_t write(const char *str) {

            ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:52:12: note:   candidate expects 1 argument, 2 provided

exit status 1
expected ';' before '}' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.