Issue EThercar library and ModbusIP_ENC28J60

Hello, first of all sorry about my english.
I am in the middle of a project with arduino and a PLC 1200 siemens.
I want transfer some data FROM the PLC (data type, int) to my arduino UNO, after this, the data will be sending to my website, (hosted in WEB00).
I can split the code in two parts:
Comunication between PLC and Arduino.
Comunication Arduino Web Server.
I send the data to the website with a POST request.

The code below works when I want to make the POST request, but i need to use "ModbusIP mb;" and when I use this line in the code, the POST request doesn't work.

I don't have any idea where is the issue. The only thing I have realized is when I add ModbusIP mb;"

/ your variable
#include <EtherCard.h>
#include <Modbus.h>
#include <ModbusIP_ENC28J60.h>
const char website[] PROGMEM = "website";
#define PATH    "phpfile"
#define VARIABLE    "var"

// ethernet interface mac address, must be unique on the LAN
static byte session;
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };


byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
ModbusIP mb;
void setup () {
  Serial.begin(57600);
  Serial.println("\n[webClient]");


  if (ether.begin(Ethernet::buffer[700], mymac) == 0)  
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");

  ether.printIp("SRV: ", ether.hisip);



}


void loop () {
  
  //Serial.println("Envio de datos");
  ether.packetLoop(ether.packetReceive());

  if (millis() > timer) {
    timer = millis() + 10000;

    byte sd = stash.create();
    stash.print("serial=");
    stash.print(VARIABLE);
    stash.print("&temperature=");
    stash.print(VARIABLE);
    stash.print("&action=Submit");
    stash.save();

    // generate the header with payload - note that the stash size is used,
    // and that a "stash descriptor" is passed in as argument using "$H"
    Stash::prepare(PSTR("POST http://$F/$F HTTP/1.0" "\r\n"
                "Host: $F" "\r\n"
                "Content-Length: $D" "\r\n"
                "Content-Type: application/x-www-form-urlencoded" "\r\n"
                "\r\n"
                "$H"),
    website, PSTR(PATH), website, stash.size(), sd);

    // send the packet - this also releases all stash buffers once done
      
  }
  session = ether.tcpSend();

  ether.packetLoop(ether.packetReceive());
delay(1000);  
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.