Siemens S7 Read
This function block reads values from a Siemens S7 PLC data block (DB). Use it to fetch numeric values, booleans, strings or other PLC data types and bring them into your scenario for monitoring, logging or decision logic.
π₯ Inputs
Enable (Boolean) β When FALSE the block will skip reading and produce no output. Use this to control when reads occur.
S7 Client (Generic) β PLC connection object provided by a connection block. Connect the client created by a PLC connection block here.
π€ Outputs
Data (Generic) β The value read from the PLC. The data type depends on the selection in the controls (number, list of booleans, text, etc.).
πΉοΈ Controls
DB Number - Database (DB) number to read from on the PLC.
DB Byte Address - Starting byte offset inside the selected DB.
DB Data Type - Dropdown to select the expected PLC data type (examples: Boolean, Int, Real, String).
Connection Type - Select Sync or Async. Sync keeps a shared connection mode suitable when multiple blocks use the same PLC bytes; Async gives the block its own connection behavior.
βοΈ How it works
When active, the block uses the connected
S7 Clientto read bytes from the specifiedDB NumberandDB Byte Address.The block interprets the raw PLC bytes according to the selected
DB Data Typeand returns a Python-friendly value via theDataoutput. For example, selectingBooleanmay return a list of bit states, whileStringreturns the decoded text.The
Enableinput allows you to stop reads without removing the configuration.The
Connection Typeinfluences sharing behavior: chooseSyncwhen you want consistent, shared access across multiple blocks; chooseAsyncfor independent or isolated access.
β¨ Features
Simple UI to specify DB number, byte address and expected PLC data type.
Supports many PLC types (booleans, signed/unsigned integers, reals, strings, time types, words/dwords, etc.).
Configurable connection mode to match your deployment (shared vs independent).
Error reporting in the UI when reads fail or if the provided parameters are out of range.
π Usage Instructions
Provide a valid PLC connection to the
S7 Clientinput (from a PLC connection block).Enable the block by providing TRUE to the
Enableinput or leaving it enabled.Set the target
DB NumberandDB Byte Address.Choose the appropriate
DB Data Typefor the value you want to read.Read values will appear on the
Dataoutput; connect downstream blocks to consume or log them.
π‘ Tips and Tricks
Trigger reads on demand: combine with
Logic Inputor a single-shot trigger likeRising Edgeto perform reads only when needed (reduces bus load).Log and store values: send the
Dataoutput toCSV ExportorSQL-DB Operationsto build historical logs.Publish readings to external systems: connect
DatatoMQTT Publishto stream PLC values to a cloud or broker.Visualize trends: feed numeric outputs into
Scopeto monitor live values over time.Keep recent values available: use
Data Memoryto hold the last-read value and release updates only when desired.Handle missing values: use
Is NoneandReplace Noneblocks to create safe fallback behavior if a read fails.Compose JSON payloads: feed values into
Data to JSONbefore publishing or saving to simplify downstream parsing.Use
Connection Typewisely:Syncis convenient when several blocks must read/write the same bytes; chooseAsyncwhen you need isolated access or independent retries.
(hint) If you need a UI block that displays current values for operators, combine with display/output blocks like Show Image (for image-like data) or Led Output and simple text widgets for numeric indicators.
π οΈ Troubleshooting
No output appears: confirm the
Enableinput is TRUE and that a validS7 Clientis connected.Connection errors or timeouts: verify PLC network settings, check the connection block providing the
S7 Client, and try switchingConnection Typemodes.Unexpected data format: ensure
DB Number,DB Byte AddressandDB Data Typematch the PLC program layout. For strings, confirm the DB layout uses the same length/encoding.High bus load: reduce read frequency, use triggered reads (
Rising Edge) or share a connection withSyncmode where appropriate.
Last updated