hi
i have a arduino code he is working i want to read one more temprature any one tell me the how to write the code
hi
i have a arduino code he is working i want to read one more temprature any one tell me the how to write the code
// FOR MEGA2560 with Modbus device #4 on Serial #1 @ 38400 baud.
#include <ModbusMaster.h> //Library for using ModbusMaster
//#define MAX485_REDE_PIN 5
#define MAX485_DE 2
#define MAX485_RE_NEG 3
ModbusMaster node; //object node for class ModbusMaster
unsigned int DATA[2];
unsigned long lastTime;
float f_2uint_float(unsigned int uint1, unsigned int uint2) { // reconstruct the float from 2 unsigned integers
union f_2uint {
float f;
uint16_t i[2];
};
union f_2uint f_number;
f_number.i[0] = uint1;
f_number.i[1] = uint2;
return f_number.f;
}
void preTransmission() //Function for setting stste of Pins DE & RE of RS-485
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
// digitalWrite(MAX485_REDE_PIN, 1);
}
void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
// digitalWrite(MAX485_REDE_PIN, 0);
}
void setup()
{
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
// pinMode(MAX485_REDE_PIN, OUTPUT);
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
// digitalWrite(MAX485_REDE_PIN, 0);
Serial.begin(38400); //Baud Rate as 38400
// Serial.println( MAX485_REDE_PIN );
// Serial1.begin(38400); //Baud Rate as 38400
node.begin(4, Serial); //Slave ID as 4 on Serial #1
node.preTransmission(preTransmission); //Callback for configuring RS-485 Transreceiver correctly
node.postTransmission(postTransmission);
}
void loop()
{
DATA[0] = node.getResponseBuffer(0);
DATA[1] = node.getResponseBuffer(1);
uint8_t result = node.readHoldingRegisters( 250, 2 ); // Read 2x 16-bit words
Serial.print("result = ");
Serial.println( result );
if (result == node.ku8MBSuccess)
{
Serial.print("data : ");
Serial.print(node.getResponseBuffer(0));
Serial.print(" ");
Serial.println(node.getResponseBuffer(1));
Serial.print("Temperature: ");
Serial.print(f_2uint_float(DATA[0],DATA[1]));
Serial.println(" C");
}
Serial.print("\n");
delay(1000);
}
i want to see the 2 more Floating-point register pairs how to write the code
you write code in tags, so it embedded proper. then we look.
he is work fine this is a corlios flow meter i see the serial monitor only temprature i want to see the ther 2 more things like flow rate and total kges so what i do
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.