- wemos d1 mini
- modul relay
- supply 220 to 5v
- switch hotel
modbusTCPslave
taruh library di folder libraries
sketch:
#include <ESP8266WiFi.h>
#include <ModbusTCPSlave.h>
#include <Ticker.h>
//Settings IP Nodemcu
byte ip[] = { 192, 168, 1, 10};
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
ModbusTCPSlave Mb;
Ticker Stop;
const int ledPin = 5; //D1
void monitoring() {
///Digital Outputs
digitalWrite(ledPin,Mb.MBHoldingRegister[2] );
}
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(115200);
Mb.begin("SIMOR", "SIMOR2017", ip, gateway, subnet);
delay(100);
}
void loop()
{
Mb.Run();
Stop.attach_ms(35,monitoring);
}
setelah sukses upload,
instal aplikasi iPLC d hp android anda.
masukkan ip wemos tadi
masukkan addres kontrol (2) holding register, bit 0
Klo pke wemos d1 r2 & relay 4chanel gmna Om?
BalasHapusCoba2 cari google gg bisa2
Sambungkan aja ke pin d1 d2 d3 d4
Hapus