I am new here to the forum and to arduino.
I would like to learn more about communication between arduino and Siemens logo 8 via modbus tcp ip.
Does anyone have a simple example of this?
I would like to learn to switch a marker flag high or low.
@patj88, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem
I used a program fl prog to create arduino code. With this I was able to make a working sketch.
but lost this one. And searching a simple sketch as an example to learn from. Sending a coil high or low.
At eps8266modbus I found this example.
But it is not clear to me how I can indicate these with the addresses to my Siemend Logo.
/*
Modbus-Arduino Example - Test Led (Modbus IP ESP8266)
Control a Led on GPIO0 pin using Write Single Coil Modbus Function
Original library
Copyright by André Sarmento Barbosa
http://github.com/andresarmento/modbus-arduino
Current version
(c)2017 Alexander Emelianov (a.m.emelianov@gmail.com)
https://github.com/emelianov/modbus-esp8266
*/
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else //ESP32
#include <WiFi.h>
#endif
#include <ModbusIP_ESP8266.h>
//Modbus Registers Offsets
const int LED_COIL = 100;
//Used Pins
const int ledPin = 0; //GPIO0
//ModbusIP object
ModbusIP mb;
void setup() {
Serial.begin(115200);
WiFi.begin("your_ssid", "your_password");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
mb.server();
pinMode(ledPin, OUTPUT);
mb.addCoil(LED_COIL);
}
void loop() {
//Call once inside loop() - all magic here
mb.task();
//Attach ledPin to LED_COIL register
digitalWrite(ledPin, mb.Coil(LED_COIL));
delay(10);
}
I found how to make connection between my Logo and an ESP8266.
It serialprints a message and when i disconnect the ethernetcable of the Logo the message stops.