how can binary data show
Closed this issue · 3 comments
mubasharhanif17 commented
need a help
show serial monitor binary data
#include <SimpleModbusMaster.h>
#define baud 9600 //baudrate modbus slave
#define timeout 1000
#define polling 100 // the scan rate
#define retry_count 1000
#define TxEnablePin 2
enum
{
PACKET3,
TOTAL_NO_OF_PACKETS
};
Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer packet3 = &packets[PACKET3];//
BIN readmodul[125];// read 32016-32040
void setup()
{
Serial.begin(9600);
packet3->id = 1;
packet3->function = READ_HOLDING_REGISTERS;
packet3->address = 0077;
packet3->no_of_registers = 35;
packet3->register_array = readmodul;
modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);
}
void loop()
{
modbus_update(packets);
//int read33 = readmodul[33];
Serial.println (readmodul[33]);
Serial.print ("DATA ");
// Serial.println (read33);
delay(2000);
}
mubasharhanif17 commented
mubasharhanif17 commented
angeloc commented
BIN readmodul[125];// read 32016-32040
sould be unsigned int readmodul[35];
packet3->address = 0077;
packet3->no_of_registers = 35;
should be
packet3->address = 0;
packet3->no_of_registers = 35;
now you can access readmodul[33]