/**
* Modbus slave example 2:
* Thepurpose of this example is to link the Arduino digital and analog
* pins to an external device.
*
* Recommended Modbus Master: QModbus
*
* Editado al español por LuxARTS由LuxARTS编辑为西班牙语
*/
//-------------------------------------------------------------------------
unsigned long previousMillis = 0; // will store last temp was read
unsigned long currentMillis = 0;
const long interval = 7000; // interval at which to readsensor
#include
#define DHTPIN 12
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);
//-----------------------------------------------------------------------------
//Incluye la librería del protocolo Modbus
#include
#define ID 1
//Crear instancia创建实例
Modbus slave(ID, 0, 0); //ID del nodo. 0para el master, 1-247 para esclavo
//节点的ID。 0表示主站,1-247表示从站
//Puerto serie (0 = TX:1 - RX: 0)
//串口(0 = TX:1 - RX:0)
//Protocolo serie. 0para RS-232 + USB (default), cualquier pin mayor a 1 para RS-485
//串行协议。 0表示RS-232 + USB(默认),任何大于1的引脚用于RS-485
boolean led;
int8_t state = 0;
unsigned long tempus;
ui