Skip to content

Commit 9dcb66c

Browse files
committed
Modified the examples to show the new API
1 parent 0b698ce commit 9dcb66c

File tree

7 files changed

+146
-441
lines changed

7 files changed

+146
-441
lines changed

examples/RTU/ModbusRTUClientMD02TemperatureHumiditySensor/ModbusRTUClientMD02TemperatureHumiditySensor.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void loop()
5656
if (ModbusRTUClient.available())
5757
{
5858
int16_t const temperature_raw = ModbusRTUClient.read();
59-
float const temperature_deg = temperature_raw / 100.f;
59+
float const temperature_deg = temperature_raw / 10.f;
6060
Serial.println(temperature_deg);
6161
}
6262

@@ -68,7 +68,7 @@ void loop()
6868
if (ModbusRTUClient.available())
6969
{
7070
int16_t const humidity_raw = ModbusRTUClient.read();
71-
float const humidity_per_cent = humidity_raw / 100.f;
71+
float const humidity_per_cent = humidity_raw / 10.f;
7272
Serial.println(humidity_per_cent);
7373
}
7474

examples/T1S/ModbusT1SClient/ModbusT1SClient.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static uint16_t const UDP_CLIENT_PORT = 8888;
2121
void setup() {
2222
Serial.begin(115200);
2323

24-
ModbusT1SClient.setT1SClient(&udp_client);
24+
ModbusT1SClient.setT1SClient(udp_client);
2525
ModbusT1SClient.setT1SPort(UDP_CLIENT_PORT);
2626
ModbusT1SClient.setServerPort(UDP_SERVER_PORT);
2727
ModbusT1SClient.setModbusId(MODBUS_ID);
@@ -34,7 +34,7 @@ void setup() {
3434
}
3535

3636
void loop() {
37-
ModbusT1SClient.checkPLCAStatus();
37+
ModbusT1SClient.update();
3838

3939
int res = ModbusT1SClient.coilRead(0x00);
4040
if (res == -1) {

examples/T1S/ModbusT1SClientTemperatureHumiditySensor/ModbusT1SClientTemperatureHumiditySensor.ino

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Arduino_10BASE_T1S_UDP udp_client;
2121
void setup() {
2222
Serial.begin(115200);
2323

24-
ModbusT1SClient.setT1SClient(&udp_client);
24+
ModbusT1SClient.setT1SClient(udp_client);
2525
ModbusT1SClient.setT1SPort(UDP_CLIENT_PORT);
2626
ModbusT1SClient.setServerPort(UDP_SERVER_PORT);
2727
ModbusT1SClient.setCallback(OnPlcaStatus);
@@ -30,11 +30,12 @@ void setup() {
3030
Serial.println("Failed to start Modbus T1S Client!");
3131
while (1);
3232
}
33+
ModbusT1SClient.disablePOE();
3334
}
3435

3536
unsigned long start = 0;
3637
void loop() {
37-
ModbusT1SClient.checkPLCAStatus();
38+
ModbusT1SClient.update();
3839

3940
if ((millis() - start) > 1000)
4041
{

examples/T1S/ModbusT1SServer/ModbusT1SServer.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <ArduinoRS485.h>
1414
#include <ArduinoModbus.h>
1515

16+
RS485Class serial485(RS485_SERIAL, RS485_TX_PIN, RS485_DE_PIN, RS485_RE_PIN);
17+
1618
static uint8_t const T1S_PLCA_NODE_ID = 0;
1719
static uint16_t const UDP_SERVER_PORT = 8889;
1820

@@ -21,15 +23,15 @@ Arduino_10BASE_T1S_UDP udp_server;
2123
void setup() {
2224
Serial.begin(115200);
2325

24-
ModbusT1SServer.setT1SServer(&udp_server);
26+
ModbusT1SServer.setT1SServer(udp_server);
2527
ModbusT1SServer.setT1SPort(UDP_SERVER_PORT);
26-
ModbusT1SServer.setBadrate(9600);
2728
ModbusT1SServer.setCallback(OnPlcaStatus);
2829

29-
if (!ModbusT1SServer.begin(T1S_PLCA_NODE_ID)) {
30+
if (!ModbusT1SServer.begin(T1S_PLCA_NODE_ID, 9600, SERIAL_8N1, serial485)) {
3031
Serial.println("Failed to start Modbus T1S Server!");
3132
while (1);
3233
}
34+
ModbusT1SServer.disablePOE();
3335
}
3436

3537
void loop() {

examples/T1S/ModbusT1SServerTemperatureHumiditySensor/ModbusT1SServerTemperatureHumiditySensor.ino

-57
This file was deleted.

0 commit comments

Comments
 (0)