[{"data":1,"prerenderedAt":765},["ShallowReactive",2],{"blog-\u002Fblog\u002F2025\u002F12\u002Fread-s7-optimized-datablocks-flowfuse":3},{"id":4,"title":5,"body":6,"description":12,"extension":754,"meta":755,"navigation":760,"path":761,"seo":762,"stem":763,"__hash__":764},"blog\u002Fblog\u002F2025\u002F12\u002Fread-s7-optimized-datablocks-flowfuse.md","How to Access Optimized Data Blocks in TIA Portal (S7-1200\u002F1500)",{"type":7,"value":8,"toc":740},"minimark",[9,13,16,24,27,32,38,49,52,57,60,63,68,75,91,94,98,101,104,107,111,114,134,138,141,163,174,204,212,216,219,224,231,236,239,260,268,277,280,284,287,292,327,335,340,343,348,351,379,387,392,403,406,410,413,448,451,455,458,531,534,538,541,607,611,614,709,712,719,723,726,729,732],[10,11,12],"p",{},"When working with Siemens S7-1200 and S7-1500 PLCs, you’ll notice that TIA Portal creates optimized data blocks by default. Unlike the classic S7-300\u002F400 controllers, optimized blocks do not use fixed memory offsets. Instead, the PLC compiler reorganizes the data internally for better performance and memory efficiency. This architectural change often creates confusion when trying to read PLC data from external systems.",[10,14,15],{},"FlowFuse simplifies this challenge by providing a modern way to connect OT and IT systems and build industrial applications using a low-code, drag-and-drop approach. However, reading optimized data blocks still requires a different access method than traditional S7 communication.",[10,17,18,19,23],{},"You can disable optimization in TIA Portal by unchecking the \"Optimized block access\" option in your data block properties. This gives you the old-style addressing where you can read data using fixed offsets like ",[20,21,22],"code",{},"DB1.DBW0",". However, this approach has several drawbacks. Optimized blocks run faster, use less memory, and follow Siemens' current best practices. If you're working on existing projects with thousands of tags, converting everything to standard blocks isn't practical. Many companies also require optimized blocks as part of their coding standards.",[10,25,26],{},"This guide shows you how to read optimized data blocks directly without disabling optimization. You'll learn to use symbolic addressing, which is the proper way to access data from modern Siemens PLCs.",[28,29,31],"h2",{"id":30},"why-reading-optimized-data-blocks-is-challenging","Why Reading Optimized Data Blocks Is Challenging",[10,33,34],{},[35,36,37],"strong",{},"The S7 Protocol Problem",[10,39,40,41,44,45,48],{},"Traditional S7 communication, which most Node-RED S7 nodes use, relies on absolute memory addresses. You read data by specifying exact locations like ",[20,42,43],{},"DB1,INT0"," (read integer at byte 0) or ",[20,46,47],{},"DB5,REAL10"," (read real at byte 10).",[10,50,51],{},"This worked fine with classic S7-300\u002F400 controllers where memory layout was predictable. If you declared an integer first in your data block, it always started at byte 0. Simple and reliable.",[10,53,54],{},[35,55,56],{},"What Optimization Breaks",[10,58,59],{},"Optimized data blocks rearrange variables for better performance and memory efficiency. The compiler groups variables by type, adds alignment padding, and reorders declarations. Your variable positions become unpredictable and can change with each recompile.",[10,61,62],{},"Example: You create variables Temperature (Real), Status (Bool), Pressure (Real), Alarm (Bool). Instead of sequential storage, the optimizer might group the two Real values together and pack Bools elsewhere. The Status boolean isn't at byte 4 anymore—it could be anywhere.",[10,64,65],{},[35,66,67],{},"Why S7 Nodes Fail",[10,69,70,71,74],{},"Node-RED packages like ",[20,72,73],{},"node-red-contrib-s7"," need exact memory addresses. With optimized blocks:",[76,77,78,82,85,88],"ul",{},[79,80,81],"li",{},"TIA Portal doesn't show you the actual memory layout",[79,83,84],{},"Offsets can't be reliably determined",[79,86,87],{},"Recompiling your PLC program silently breaks all your addresses",[79,89,90],{},"The S7 protocol has no way to read variables by name",[10,92,93],{},"You're stuck guessing at memory locations that keep changing.",[28,95,97],{"id":96},"the-solution-opc-ua","The Solution: OPC UA",[10,99,100],{},"OPC UA reads variables by name, not memory address. Instead of asking \"what's at byte 10?\" it asks \"what's the value of Temperature_Sensor_01?\"",[10,102,103],{},"Siemens S7-1200 and S7-1500 PLCs have built-in OPC UA server. Activate it in TIA Portal, mark which variables to expose, and the PLC handles all memory mapping internally. FlowFuse connects and reads data by variable name, regardless of how the PLC organizes memory.",[10,105,106],{},"When you modify your data block or recompile, your flows keep working because they reference variable names, not memory locations that might shift.",[28,108,110],{"id":109},"prerequisites","Prerequisites",[10,112,113],{},"Before you begin, make sure you have:",[76,115,116,119,122,131],{},[79,117,118],{},"TIA Portal V13 or later, and you know how to download a program to your PLC",[79,120,121],{},"A Siemens S7-1200 or S7-1500 PLC with OPC UA server support",[79,123,124,125,130],{},"A ",[126,127,129],"a",{"href":128},"\u002Fblog\u002F2025\u002F09\u002Finstalling-node-red\u002F","FlowFuse Agent"," running on your edge device",[79,132,133],{},"The PLC and edge device connected to the same network",[28,135,137],{"id":136},"step-1-activate-opc-ua-server-on-your-plc","Step 1: Activate OPC UA Server on Your PLC",[10,139,140],{},"First, you need to activate the OPC UA server that's built into your S7-1200\u002F1500 PLC.",[142,143,144,147,150,157],"ol",{},[79,145,146],{},"Launch TIA Portal and open your project",[79,148,149],{},"In the project tree on the left, select your PLC and double-click it",[79,151,152,153,156],{},"Find ",[35,154,155],{},"OPC UA"," in the device properties (usually under General or Properties section)",[79,158,159,160],{},"Check ",[35,161,162],{},"Activate OPC UA Server",[10,164,165,171],{},[166,167],"img",{"alt":168,"dataZoomable":169,"src":170},"Activate OPC UA server option in TIA Portal","","\u002Fblog\u002F2025\u002F12\u002Fimages\u002Fenable-opcua-server.png",[172,173,168],"em",{},[142,175,177,188,197],{"start":176},5,[79,178,179,180,183,184,187],{},"Set ",[35,181,182],{},"Port"," to ",[20,185,186],{},"4840"," (the standard OPC UA port)",[79,189,179,190,183,193,196],{},[35,191,192],{},"Security Policy",[35,194,195],{},"None"," (for testing only)",[79,198,199,200,203],{},"Enable ",[35,201,202],{},"Guest authentication",".",[205,206,207],"blockquote",{},[10,208,209],{},[172,210,211],{},"Note that we've disabled security entirely in steps 6-7 to get you up and running quickly. This is fine for learning and testing, but don't leave it this way. Before moving to production, configure proper authentication with certificates and user credentials. Get the communication working first, then secure it.",[28,213,215],{"id":214},"step-2-add-opc-ua-server-interface","Step 2: Add OPC UA Server Interface",[10,217,218],{},"Before exposing variables, you need to create an OPC UA server interface in your PLC configuration.",[10,220,221],{},[35,222,223],{},"For S7-1500 PLCs (firmware V2.5 or higher):",[10,225,226,227,230],{},"If you're using an S7-1500 PLC with firmware version 2.5 or higher, you have the option to enable the standard SIMATIC server interface. Simply check ",[35,228,229],{},"Enable standard SIMATIC server interface"," in the OPC UA settings. This automatically makes all PLC tags that are marked as accessible available through OPC UA.",[10,232,233],{},[35,234,235],{},"For S7-1200 PLCs (or manual configuration for S7-1500):",[10,237,238],{},"For S7-1200 PLCs, you must manually create a server interface and add the tags you want to expose:",[142,240,241,248,254],{},[79,242,243,244,247],{},"In TIA Portal, navigate to ",[35,245,246],{},"OPC UA communication"," in the project tree",[79,249,250,251],{},"Right-click on ",[35,252,253],{},"Server interfaces",[79,255,256,257],{},"Select ",[35,258,259],{},"Add new server interface",[10,261,262,266],{},[166,263],{"alt":264,"dataZoomable":169,"src":265},"Adding OPC UA server interface in TIA Portal","\u002Fblog\u002F2025\u002F12\u002Fimages\u002Fadd-server-interface.png",[172,267,264],{},[142,269,271,274],{"start":270},4,[79,272,273],{},"Leave the default settings and click OK",[79,275,276],{},"The server interface will be created (you can rename it if needed)",[10,278,279],{},"Now this interface needs to know which data blocks to expose.",[28,281,283],{"id":282},"step-3-expose-your-data-block-variables","Step 3: Expose Your Data Block Variables",[10,285,286],{},"For OPC UA to access your data blocks, you need to mark them as accessible.",[10,288,289],{},[35,290,291],{},"First, enable OPC UA access on your data blocks (required for all methods):",[142,293,294,297,300,305,312,321],{},[79,295,296],{},"Open your data block in TIA Portal",[79,298,299],{},"Right-click on the data block name in the project tree",[79,301,256,302],{},[35,303,304],{},"Properties",[79,306,307,308,311],{},"Go to the ",[35,309,310],{},"Attributes"," tab",[79,313,159,314,317,318],{},[35,315,316],{},"Accessible from HMI\u002FOPC UA"," and ",[35,319,320],{},"Optimized Block Access",[79,322,323,324],{},"Click ",[35,325,326],{},"OK",[10,328,329,333],{},[166,330],{"alt":331,"dataZoomable":169,"src":332},"Attribute settings for optimized and OPC UA accessible data blocks","\u002Fblog\u002F2025\u002F12\u002Fimages\u002Foptimized-db-and-accessbile-via-opcua-option.png",[172,334,331],{},[10,336,337],{},[35,338,339],{},"If using S7-1500 with standard SIMATIC server interface:",[10,341,342],{},"You're done. All variables in data blocks marked as accessible are now automatically available through OPC UA.",[10,344,345],{},[35,346,347],{},"If using manual server interface (S7-1200 or S7-1500):",[10,349,350],{},"You need one more step to add specific variables to your server interface:",[142,352,353,358,361,368],{},[79,354,355,356],{},"In the project tree, expand ",[35,357,246],{},[79,359,360],{},"Expand your server interface",[79,362,363,364,367],{},"Drag and drop variables from the ",[35,365,366],{},"OPC UA elements"," panel (on the right) into your server interface table",[79,369,370,371,374,375,378],{},"Alternatively, right-click ",[35,372,373],{},"Variables"," and select ",[35,376,377],{},"Add new variable",", then browse to select them",[10,380,381,385],{},[166,382],{"alt":383,"dataZoomable":169,"src":384},"Tags added inside OPC UA server interface","\u002Fblog\u002F2025\u002F12\u002Fimages\u002Ftags-added-in-the-server-interface.png",[172,386,383],{},[10,388,389],{},[35,390,391],{},"Compile and download:",[142,393,394,400],{"start":176},[79,395,323,396,399],{},[35,397,398],{},"Compile"," in TIA Portal",[79,401,402],{},"Download the program to your PLC",[10,404,405],{},"Your OPC UA server is now running with the exposed variables ready for access.",[28,407,409],{"id":408},"step-4-install-opc-ua-client-in-flowfuse","Step 4: Install OPC UA Client in FlowFuse",[10,411,412],{},"Now switch to your FlowFuse instance to set up the connection to your PLC.",[142,414,415,418,421,426,431,437,442,445],{},[79,416,417],{},"Open your FlowFuse editor",[79,419,420],{},"Click the menu icon (three horizontal lines, top right)",[79,422,256,423],{},[35,424,425],{},"Manage palette",[79,427,307,428,311],{},[35,429,430],{},"Install",[79,432,433,434],{},"In the search box, type ",[20,435,436],{},"node-red-contrib-opcua",[79,438,439,440],{},"Find the package in the results and click ",[35,441,430],{},[79,443,444],{},"Confirm the installation when prompted",[79,446,447],{},"Close the palette manager",[10,449,450],{},"The OPC UA nodes will now appear in your node palette on the left side under the \"opcua\" category.",[28,452,454],{"id":453},"step-5-configure-opc-ua-connection","Step 5: Configure OPC UA Connection",[10,456,457],{},"Create a new flow to connect to your PLC and read data.",[142,459,460,467,470,477,496,502,509,519,525],{},[79,461,462,463,466],{},"Drag an ",[35,464,465],{},"OpcUa-Client"," node onto your canvas",[79,468,469],{},"Double-click it to open the configuration",[79,471,472,473,476],{},"Click the pencil icon next to ",[35,474,475],{},"Endpoint"," to add a new connection",[79,478,479,480,483],{},"Enter the endpoint URL: ",[20,481,482],{},"opc.tcp:\u002F\u002F[YOUR_PLC_IP]:4840",[76,484,485],{},[79,486,487,488,491,492,495],{},"Replace ",[20,489,490],{},"[YOUR_PLC_IP]"," with your actual PLC IP address (e.g., ",[20,493,494],{},"opc.tcp:\u002F\u002F192.168.1.10:4840",")",[79,497,179,498,183,500],{},[35,499,192],{},[35,501,195],{},[79,503,179,504,183,507],{},[35,505,506],{},"Security Mode",[35,508,195],{},[79,510,511,512,515,516],{},"Under ",[35,513,514],{},"Authentication",", select ",[35,517,518],{},"Anonymous",[79,520,323,521,524],{},[35,522,523],{},"Add"," to save the endpoint",[79,526,323,527,530],{},[35,528,529],{},"Done"," to close the node configuration",[10,532,533],{},"Your OPC UA client is now configured to connect to your PLC.",[28,535,537],{"id":536},"step-6-browse-available-variables","Step 6: Browse Available Variables",[10,539,540],{},"Now it's time to discover what's actually available on your PLC. Think of this like opening a file explorer to see what's inside.",[142,542,543,548,554,560,563,569,575,585,589,595,598,604],{},[79,544,462,545,466],{},[35,546,547],{},"Inject",[79,549,462,550,553],{},[35,551,552],{},"OpcUa-Browser"," node onto the canvas",[79,555,556,557,553],{},"Drag a ",[35,558,559],{},"Debug",[79,561,562],{},"Connect the Inject node to the OpcUa-Browser node, then connect the OpcUa-Browser node to the Debug node",[79,564,565,566,568],{},"Double-click the ",[35,567,552],{}," node to open its configuration",[79,570,571,572,574],{},"In the ",[35,573,475],{}," dropdown, select the connection you created in Step 5",[79,576,577,578,581,582],{},"Leave the ",[35,579,580],{},"Action"," field set to ",[35,583,584],{},"browse",[79,586,323,587],{},[35,588,529],{},[79,590,323,591,594],{},[35,592,593],{},"Deploy"," in the top-right corner",[79,596,597],{},"Click the inject node button",[79,599,600,601,603],{},"Open the ",[35,602,559],{}," panel on the right side",[79,605,606],{},"You'll see a structured tree showing everything your PLC is sharing",[28,608,610],{"id":609},"step-7-read-your-first-variable","Step 7: Read Your First Variable",[10,612,613],{},"Let's prove this actually works by reading real data from your PLC.",[142,615,616,620,623,633,639,648,652,656,659,665,672,676,680,683,689,693,696,700,703],{},[79,617,462,618,466],{},[35,619,547],{},[79,621,622],{},"Double-click the Inject node to configure it",[79,624,625,626,629,630],{},"Change ",[35,627,628],{},"Repeat"," from \"none\" to ",[35,631,632],{},"interval",[79,634,635,636],{},"Set it to repeat ",[35,637,638],{},"every 5 seconds",[79,640,571,641,644,645,495],{},[35,642,643],{},"Topic"," field, enter the NodeId you copied (e.g., ",[20,646,647],{},"ns=3;s=\"Demo_Datablock\".\"Temperature\"",[79,649,323,650],{},[35,651,529],{},[79,653,462,654,553],{},[35,655,465],{},[79,657,658],{},"Double-click the OpcUa-Client node to open its configuration",[79,660,661,662,664],{},"Select your endpoint from the ",[35,663,475],{}," dropdown",[79,666,625,667,183,669],{},[35,668,580],{},[35,670,671],{},"read",[79,673,323,674],{},[35,675,529],{},[79,677,556,678,553],{},[35,679,559],{},[79,681,682],{},"Double-click the Debug node",[79,684,685,686],{},"Change the output to ",[35,687,688],{},"complete msg object",[79,690,323,691],{},[35,692,529],{},[79,694,695],{},"Connect the Inject node to the OpcUa-Client node, then connect the OpcUa-Client node to the Debug node",[79,697,323,698],{},[35,699,593],{},[79,701,702],{},"Open the Debug panel on the right side",[79,704,705,706],{},"You'll see messages appearing every 5 seconds with your variable's value in ",[20,707,708],{},"msg.payload",[10,710,711],{},"Try changing the value in your PLC through TIA Portal and watch the updates appear in FlowFuse. No memory addresses, no offset calculations, just the variable name.",[10,713,714,715,203],{},"To explore more OPC UA capabilities like subscribing to value changes, writing data back to your PLC, and working with complex data types, check out our ",[126,716,718],{"href":717},"\u002Fblog\u002F2025\u002F07\u002Freading-and-writing-plc-data-using-opc-ua\u002F","article",[28,720,722],{"id":721},"scale-your-industrial-applications-with-flowfuse","Scale Your Industrial Applications with FlowFuse",[10,724,725],{},"You've successfully read data from your Siemens PLC, but FlowFuse does much more than connect to a single device. The platform helps you build complete industrial applications that connect to any equipment, collect and transform data from across your factory floor, visualize it in real-time dashboards, and take automated actions based on what's happening in your operation.",[10,727,728],{},"FlowFuse makes deployment and management simple, even at scale. Develop your application once, then deploy it to thousands of edge devices across multiple facilities. Manage all your instances from one central platform—push updates, monitor performance, and troubleshoot remotely without visiting each site. Built-in security features protect your industrial data, while horizontal and vertical scaling ensures your applications grow with your business needs.",[10,730,731],{},"Whether you're building a predictive maintenance system, a production monitoring dashboard, or a complete MES solution, FlowFuse provides the unified platform to connect, collect, transform, visualize, and act on your industrial data.",[10,733,734,735,739],{},"Ready to scale beyond a single PLC? ",[126,736,738],{"href":737},"\u002Fbook-demo\u002F","Book a demo"," to see how FlowFuse can transform your industrial operations.",{"title":169,"searchDepth":741,"depth":741,"links":742},2,[743,744,745,746,747,748,749,750,751,752,753],{"id":30,"depth":741,"text":31},{"id":96,"depth":741,"text":97},{"id":109,"depth":741,"text":110},{"id":136,"depth":741,"text":137},{"id":214,"depth":741,"text":215},{"id":282,"depth":741,"text":283},{"id":408,"depth":741,"text":409},{"id":453,"depth":741,"text":454},{"id":536,"depth":741,"text":537},{"id":609,"depth":741,"text":610},{"id":721,"depth":741,"text":722},"md",{"navTitle":5,"excerpt":756},{"type":7,"value":757},[758],[10,759,12],{},true,"\u002Fblog\u002F2025\u002F12\u002Fread-s7-optimized-datablocks-flowfuse",{"title":5,"description":12},"blog\u002F2025\u002F12\u002Fread-s7-optimized-datablocks-flowfuse","F_GB2hRLzN_tFtd6bjJLOAbGgp6eqUZTS96Ht6h54fo",1780070553910]