title: Serial communication between Siemens PLC and Arduino
body: <p>I want to have a serial communication using Siemens S7-1200 with CM 1241 (RS-232) and communicate with my Arduino.
  Here is the setup of the communication. I have 2 temperature sensor and one Led connected to my Arduino, and on the PLC side I have S7-1200 from Siemens and CM-1241. Arduino and my PLC are connected just by using Tx and Rx pin no handshake is done.</p>
  
  <p>I am sending the temperature data from both the sensor to the PLC. on the PLC side i decide when to turn on the Led connected to my arduino depending on the different temperature values. I have assigning a ID to both the sensors before sending out the data. This is how the transmitted data from Arduino looks like $AOPT_TEMP1_20_TEMP2_21 .</p>
  
  <p>So far its good, I am receiving serial data on my PLC using RCV_PTP (received data are placed on the buffer) and sending data using SEND_PTP. I have also implement a filter on the PLC which will only accepts the serial data starting with '$AOPT_'. Now, I want to receive the temperature value from two temperature sensor TEMP1 &amp; TEMP2 and then control the Led. For instance if (TEMP1>TEMP2 ) then turn ON the Led else turn OFF.</p>
  
  <p>I am able to receive the data on the PLC from Arduino but now I don't know how to proceed with comparing the received information. How do i extract the only required data from the received buffer? Any suggestions will be highly appreciated.</p>
  
  <p>Thanks in advance....</p>