0

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()
plc.connect("192.168.12.73",0,1)

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)
plc.disconnect()
ZF007
  • 3,708
  • 8
  • 29
  • 48

0 Answers0