Hello!
- I have a communication project between PLC (s7 1200), (Arduino + Ethernet shield) and Android.
- The type of communication between PLC and ( Arduino + Ethernet shield) is Modbus TCP.
The type of communication between (Arduino + Ethernet shield) and Android is Blynk.
But I can not match Blynk code and Modbus TCP code on an Arduino. Despite no error, but modbus TCP not run . Please help me. Thank you!
This is my code (arduino) :
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include “Mudbus.h”
Mudbus Mb;
char auth[] = “my token”;
#define W5100_CS 10
#define SDCARD_CS 4
BlynkTimer timer;
unsigned char val;
void sendSensor()
{
Blynk.virtualWrite(V6, int(analogRead(A0) * 0.48828125));
Blynk.virtualWrite(V7, int(analogRead(A1) * 0.48828125));
Blynk.virtualWrite(V8, int(analogRead(A1) * 0.48828125));
Blynk.virtualWrite(V9, int(analogRead(A2) * 0.48828125));
Blynk.virtualWrite(V10, int(analogRead(A3) * 0.48828125));
Blynk.virtualWrite(V11, int(analogRead(A4) * 0.48828125));
}
/*BLYNK_WRITE(V1)
{
Serial.print("V1 Slider value is: ");
Serial.println(int(param.asInt()));
}*/
void setup()
{
uint8_t mac[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x08 };
uint8_t ip[] = { 192, 168, 0, 63 };
Ethernet.begin(mac, ip);
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH);
Blynk.begin(auth);
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Mb.Run();
Mb.R[3] = analogRead(A0);
Blynk.run();
timer.run();
}