Siemens Simatic IOT2000|Using the ethernet port

For an University project I'm working with a Siemens Simatic IOT2040. I need to dake the information from a Gyro sensor and send it using the ethernet (I think tcp/ip).

In every guide or video they talk about using the Simatic IOT library, but the link they give does not work anymore, so I'm using my Simatic as an i586 board, so an Intel Galileo gen 2.

While working "offline" everything works just fine, from the simple Blink test to a code that get all the data from the sensor and visualize it on the Serial Screen, but when I try some code found on the internet for using it "online" it doesn't work.

Any advice? Thanks

could you upload a schematic of your system identifing the components and how they are connected and powered?

I'm using a Siemens Simatic IOT2040 and a GY-521 as Gyroscope.
This is the code I'm trying to upload as first try with the network (I found it on the internet):

//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.1"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

This is my network schematic:

Once all of this works, I'll modify the following code for sending via Ethernet the final string

#include<Wire.h>
const int MPU=0x68; 
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); 
  Wire.write(0);    
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,12,true);  
  AcX=Wire.read()<<8|Wire.read();    
  AcY=Wire.read()<<8|Wire.read();  
  AcZ=Wire.read()<<8|Wire.read();  
  GyX=Wire.read()<<8|Wire.read();  
  GyY=Wire.read()<<8|Wire.read();  
  GyZ=Wire.read()<<8|Wire.read(); 

  char text [40];
  sprintf (text, "%d, %d, %d, %d, %d, %d\n", AcX, AcY, AcZ, GyX, GyY, GyZ);
  Serial.println (text);
  delay(10);
}

The Gyro code works just fine on an arduino Uno, but when I try uploading it on the Siemens it gives me a bunch of errors probably due to drivers or usb cables; after many attemps it works.

The ethernet one is just broken.

At the end I'll visualize all the data on Telemetry viewer

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