-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modbus function 0x01 Read Coils is incorrect ? #160
Comments
Hi, coils are individual bits, the first 16 are retrieved in first word (2 bytes, uint16_t), |
Hi.....haidvams Thank you... Hope it's useful #include <ModbusMaster.h> #include <SoftwareSerial.h> #define EN D1 #define LED_Status D4 uint16_t DO1,DO2,DO3,DO4; void postTransmission() void setup() { MySerial.begin(57600); // baudrate pzem node.preTransmission(preTransmission); } void loop() { } void Read_Data1(byte addr){ node.begin(addr, MySerial); DO1 = node.readCoils(0, 1); DO2 = node.readCoils(1,1); DO3 = node.readCoils(2,1); DO4 = node.readCoils(3,1); delay(1000);// delay } void Read_Data2(byte addr){ |
#include <ModbusMaster.h>
ModbusMaster node;
#include <SoftwareSerial.h>
SoftwareSerial MySerial(10,11);
void setup()
{
}
void loop()
{
}
My bug
Coil 1 desire is 1 but response is 2
Coil 2 desire is 1 but response is 4
Coil 3 desire is 1 but response is 9
- All response now only show in
node.getResponseBuffer(0)
, someone can help me fix this?
- this is video my test
https://youtu.be/YTzsSAuBlP8
The text was updated successfully, but these errors were encountered: