Serial Communication Between Siemens PLC and Arduino


Thread Starter


Hello everyone,

I want to make 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.

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 <CR><LR>.

I have a filter on the PLC which only accepts the serial data starting with '$AOPT_', so far its good. I am receiving the serial data using RCV_PTP block and sending data using SEND_PTP. I can send signal from PLC to turn ON or OFF the led. but what I want to do is evaluate the received temperature value from two temperature sensor TEMP1 & TEMP2 and then decide to control the Led. For instance if (TEMP1>TEMP2 ) then turn ON the Led else turn OFF.

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.

Thanks in advance