Hello everyone,
Please I need help. I am using two board Arduino. On the first stage, I use Arduino Uno Wifi Rev2 and on the top of it, I plugged the Arduino Ethernet Shield Rev2. The MAC address of Arduino Wifi Rev2 is : 0xA8, 0x61, 0x0A, 0xAF, 0x16, 0xC1.
In order to operate the Ethernet communication, I upload the application below inside the kit Arduino Wifi Rev2 by using Usb connection cable.
#include <ModbusIP.h>
#include <Modbus.h>
#include <Ethernet.h>
#include <SPI.h>
#include <ArduinoRS485.h>
int tanklevel;
int tanklevel_old;
const int tanklevel_ir = 100;
//Modbus IP Object
ModbusIP mb;
void setup() {
Serial.begin(9600);
// The media access control (ethernet hardware) address for the shield
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAF, 0x16, 0xC1 };
// The IP address for the shield
byte ip[] = { 192, 168, 1, 124 };
//Config Modbus IP
mb.config(mac, ip);
mb.addIreg(tanklevel_ir);
tanklevel = 12;
tanklevel_old = 12;
mb.Ireg (tanklevel_ir, tanklevel);
DisplayCurrentValues();
}
void loop() {
mb.task();
// send updated values
CheckForDataChange();
}
void CheckForDataChange() {
boolean data_has_changed = false;
if (tanklevel_old != tanklevel) {
data_has_changed = true;
tanklevel_old = tanklevel;
}
if (data_has_changed == true) {
DisplayCurrentValues();
}
}
void DisplayCurrentValues() {
String tmpstr;
tmpstr = "Tank Level: " + String(tanklevel) + " ft";
Serial.println(tmpstr);
}
Please can someone help me.
Aristide Yannic.


