I'm trying to build a communication between a plc s7 1200 and an rpi 3, I have installed snap7 but when executing this code I get the following error:

no module named snap7

This is my code:

from time import sleep
import snap7
from snap7.util import *
import struct

plc = snap7.client.Client()

area = 0x82    # area for Q memory
start = 0      # location we are going to start the read
length = 1     # length in bytes of the read
bit = 0        # which bit in the Q memory byte we are reading

byte = plc.read_area(area,0,start,length)
print "Q0.0:",get_bool(mbyte,0,bit)

0 Answers