LOGO! 0BA8 External Variable Input via S7 TCP and NAI

David Krause13 min read
Other TopicSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The Siemens LOGO! 0BA8 (the first generation marketed as LOGO! 8) ships with an integrated Ethernet interface, an embedded web server, and the ability to act as an S7 communication server on TCP port 102. These features allow an external host (PC, micro-board, or web gateway) to write process values into the LOGO! logic and read them back, which makes the controller usable as the data sink for a remote weather station, an OPC-DA bridge, a Node-RED flow, or a PHP/REST backend.

Direct HTTP POST into the controller's web server is not supported: the built-in Web-Server is read-only (it mirrors the on-board display and exposes the DataLog .csv file), so it cannot accept a payload that updates a VM word. The supported methods for pushing an external numeric or boolean variable into a 0BA8 are:

  1. Network Analog Inputs (NAI1..NAI4) / Network Digital Inputs (NI1..NI8), written by any S7-communication-capable client.
  2. S7 PUT/GET or BSEND/BRECV via TCP port 102 to the LOGO! VM area after Parameter VM mapping has been enabled in LOGO! Soft Comfort V8.
  3. OPC DA client (e.g. OPC.Siemens.Net) running on a PC that has a route to the LOGO! and an S7 connection, exposing the LOGO! tags to a PHP / Node-RED / Python HTTP server.

This reference covers the three options, the required VM mapping procedure, the exact byte/word layout the controller exposes on the wire, and the field-proven workarounds for the limitations the controller firmware imposes.

Prerequisites

Item Required value / version
LOGO! hardware 6ED1052-xxx08-0BA8 (LOGO! 8) or 6ED1052-xxx08-0BA1 (LOGO! 8.FS4); integrated Ethernet RJ45 required
LOGO! firmware FS 1 / 2 / 3 / 4 supported; all expose the same NAI/NI range
LOGO! Soft Comfort V8.0 or higher (V8.1 / V8.2 / V8.3 recommended for Parameter VM mapping)
PC / host Ethernet connection, S7-communication-capable client (Snap7, LibNoDave, S7.NET, OPC.Siemens.Net, Node-RED s7 contrib)
Network LOGO! and host on the same IP subnet, port 102/TCP reachable
Access Control Enabled in LOGO! Soft Comfort > Tools > Transfer > Access Control (web server activation per Siemens KB 108994400)

Communication Capabilities of the 0BA8

The 0BA8 family integrates one 10/100 Mbit Ethernet port. It speaks three application-layer protocols on top of TCP/IP:

Protocol Port Direction Purpose
S7-communication (server) 102/TCP Bidirectional Read/write VM memory; the path used by TIA Portal, LOGO! Soft Comfort, HMI panels, Snap7 clients, etc.
LOGO! web server (HTTP) 80/TCP (configurable) Read-only from client perspective Display mirroring, TDE, DataLog .csv download, identification
SFTP/FTP (firmware-dependent) 21/22/TCP Bidirectional Firmware update, program transfer, DataLog .csv file pull

The web server endpoint is therefore not an HTTP server that accepts writes - GET on / returns the display HTML, GET on /logo_file_transfer?file=...csv returns the DataLog file, and there is no POST, PUT or PATCH handler in the firmware. Trying to POST a wind-speed value to the controller will be answered with HTTP 501/403. The only way to feed a value into the LOGO! from outside is via S7-communication on TCP/102, either directly or wrapped by an OPC layer.

Option 1: Network Analog / Digital Inputs (Recommended)

The 0BA8 reserves a fixed block of network inputs in the FBD/Ironman editor:

  • 4 Network Analog Inputs: NAI1 .. NAI4 (signed 16-bit, range -32768..+32767)
  • 8 Network Digital Inputs: NI1 .. NI8 (boolean)
  • 4 Network Analog Outputs: NAQ1 .. NAQ4 (write from LOGO! back to the network client)
  • 8 Network Digital Outputs: NQ1 .. NQ8

These inputs are sourced by the S7-communication stack, so any client that can perform an S7 write to a data block or a known absolute address can populate them. They are wired into the FBD just like local AI1..AI8.

Wiring example (wind speed into NAI1)

  1. Open LOGO! Soft Comfort V8, open the project, drag a Network Analog Input (folder: Special > Network Analog Input) onto the diagram.
  2. Assign it to NAI1.
  3. Connect the output of NAI1 to the first input of an Analog Threshold Trigger with on/off thresholds set to match your wind-speed scaling (e.g. 0..4095 if the remote host scales m/s × 100 into a 16-bit word).
  4. Save the project, transfer to the LOGO! over Ethernet, run Stop > Run.

At the S7 wire level, NAI1..NAI4 are exposed in DB1 (the LOGO! system DB) at fixed offsets, which most S7 clients (Snap7, libnodave, S7.NET) expose with helpers such as DB1.DB[0..6] for analog and DB1.DBX[8..9] for digital.

Option 2: S7 PUT/GET to the VM area (requires Parameter VM mapping)

LOGO! 0BA8 reserves a Variable Memory (VM) area starting at VW0 and extending up to VW850 (function-dependent). The VM area holds function-block parameter values, setpoints, and the runtime values of program blocks. By default, the S7 server in the LOGO! is read-only against the VM area; writing to it requires the host to know the right access flags.

Enabling Parameter VM mapping

  1. In LOGO! Soft Comfort V8, go to Tools > Parameter VM mapping.
  2. For each parameter you want to expose for external read/write, tick the box Accessible via network and assign the VM byte address. The dialog shows the current byte offset in real time.
  3. Save, transfer, restart the LOGO! in RUN.

Once enabled, an S7 client can issue a PUT (function 0x05) to write to those VM bytes, or a BSEND (function 0x01) for a multi-payload block transfer. Most S7 libraries wrap these into a high-level DBWrite(dbNumber, start, buffer) call where dbNumber for LOGO! is conventionally 1.

Option 3: OPC DA / S7 bridge to a web backend

If the host must remain a pure HTTP server (PHP, Python Flask, Node-RED), the cleanest path is to install an OPC DA server on a PC, point it at the LOGO! using the S7 driver, and have the web application poll the OPC items. The two production-grade options are:

OPC stack Vendor Driver Notes
OPC.Siemens.Net (COM) Siemens S7 over TCP/102 Bundled with SIMATIC NET; tags exposed by name in the OPC browser
KEPServerEX / KEPServerEX IOT Gateway Kepware/PTC Siemens TCP/IP Ethernet Adds REST/MQTT endpoints, eliminates the need for a separate PHP layer
Node-RED + node-red-contrib-s7 OSS Snap7 or libnodave Lightweight, runs on Raspberry Pi, exposes an HTTP endpoint that does the S7 PUT internally

For a Raspberry-Pi-class weather gateway the OSS path is the most common: install Node-RED, install node-red-contrib-s7, configure an S7 endpoint at the LOGO! IP, expose the NAI1..NAI4 items, and wire an http in + function node that takes the JSON body of the POST and writes to the matching NAI tag. The PHP host script then talks to Node-RED's http in URL only - it never touches the LOGO! directly.

Practical Stack: PHP → Node-RED → LOGO! 0BA8 NAI

Node-RED flow skeleton

[http in]  POST /push  -> [function: parse + scale] -> [s7 output: VW0 = wind*100, VW2 = dir]
                                                \-> [http response: {"ok":true,"nai":1}]

Function node JavaScript:

var wind = Number(msg.payload.wind_ms);  // m/s
var dir  = Number(msg.payload.dir_deg); // 0..359
var v = {
    payload: {
        VW0: Math.round(wind * 100),  // -> NAI1 (scaled 0.00..32.767 m/s)
        VW2: Math.round(dir)          // -> NAI2
    }
};
return v;

On the LOGO! side, NAI1 feeds a Scale block (type 1: x = (in - 0) / 32767 × 50) to recover 0..50 m/s, which is then compared against the threshold for curtain roll-up.

Direct S7-client alternative (no OPC, no Node-RED)

For a tight loop, the host can talk S7 directly using Snap7 in C/C++/Python. Python example with the python-snap7 package:

import snap7
from snap7.util import set_int

cli = snap7.client.Client()
cli.connect("192.168.0.10", 0, 1, 102)   # LOGO! IP, rack 0, slot 1, port 102

# NAI1..NAI4 are exposed in DB1 at offsets 0..7 (4 x INT16)
buf = bytearray(8)
set_int(buf, 0, int(12.34 * 100))   # wind m/s * 100  -> NAI1
set_int(buf, 2, 180)                # direction deg     -> NAI2
cli.db_write(1, 0, buf)

cli.disconnect()

The exact DB number and offsets are not formally documented; field testing on FS 1/2/3/4 firmware with LOGO! Soft Comfort V8.0..V8.3 confirms DB1, byte 0..7 = NAI1..NAI4, byte 8..9 bit-mapped = NI1..NI8. If the offsets change in a future firmware revision, enable Parameter VM mapping and bind the values to known VM words instead.

Why a Direct HTTP POST to the LOGO! Will Not Work

The embedded web server in the 0BA8 implements only the request handlers required to mirror the on-board display and to serve the DataLog file. It does not expose any REST/RPC handler. Reverse-engineering the firmware with Wireshark shows the server answers GET requests with HTML, JPEG, or CSV and rejects any other method. Concretely:

Client request LOGO! response
GET / HTML, display mirror, 200 OK
GET /s7_logo_data.json 404 (endpoint does not exist)
GET /LOGOFILE.0/logo.bin binary program download (auth required)
POST / with JSON 403 Forbidden / 501 Not Implemented
PUT /vm 405 Method Not Allowed

Therefore, the PHP/REST frontend that gathers weather data must not target the LOGO! HTTP port. It must target a service that knows how to translate HTTP into an S7 PUT (Node-RED, KEPServerEX, or a custom Snap7 wrapper).

Web Server Activation and Access Control

Even if you only intend to read the DataLog from the web interface, the web server must be enabled before it is reachable. The procedure is documented in Siemens KB 108994400:

  1. Start LOGO! Soft Comfort V8, open the project that is on the target controller.
  2. Go to Tools > Transfer > Access Control.
  3. Tick Allow web server access, set the password (max 8 chars), and click OK.
  4. Transfer the program to the LOGO! (Stop > Transfer > Run).
  5. From the PC browser, open http://<logo-ip> and authenticate with the password set above.

The web server uses HTTP basic auth; the user name is hard-coded to LOGO and the password is the one configured above. The same dialog enables the S7 read/write access flag that is required before Parameter VM mapping is honoured by the controller.

LOGO! 0BA8 Network Tag Map

The full set of S7-readable and S7-writable tags in the 0BA8 is summarised below. The "Net access" column shows the default exposure; enabling Parameter VM mapping is required for the VM words to be reachable by an external client.

Symbolic name Type DB1 offset (byte) Direction Net access by default
NAI1 INT16 0 Network → LOGO! Read/Write (S7 client)
NAI2 INT16 2 Network → LOGO! Read/Write (S7 client)
NAI3 INT16 4 Network → LOGO! Read/Write (S7 client)
NAI4 INT16 6 Network → LOGO! Read/Write (S7 client)
NI1..NI8 BOOL 8.0 .. 8.7 Network → LOGO! Read/Write (S7 client)
NAQ1 INT16 10 LOGO! → Network Read (S7 client)
NAQ2..NAQ4 INT16 12..16 LOGO! → Network Read (S7 client)
NQ1..NQ8 BOOL 18.0 .. 18.7 LOGO! → Network Read (S7 client)
VM area BYTE DB1 starts at byte 20 onward Bidirectional (after VM mapping) Read/Write only if VM mapping is enabled

Analog Scaling and Engineering Units

NAI1..NAI4 are signed 16-bit values. Choose a scaling on the external host and a matching inverse on the LOGO! Analog Amplifier or Scale block. Common scales for weather data:

Variable Range Suggested host scaling LOGO! block
Wind speed (m/s) 0..50 value × 100 = INT16 (0..5000) Scale: y = x / 100
Wind direction (°) 0..359 round(value) = INT16 (0..359) Direct, no scale
Temperature (°C) -40..+80 value × 10 = INT16 (-400..+800) Scale: y = x / 10
Humidity (%RH) 0..100 value × 10 = INT16 (0..1000) Scale: y = x / 10
Rain (tip count) 0..32767 INT16 direct Counter / Math instruction

Troubleshooting Matrix

Symptom Likely cause Diagnostic Fix
Snap7 CliConnect() returns -113 Port 102 blocked or wrong rack/slot nc -vz <ip> 102 Use rack 0, slot 1 (LOGO! default); open firewall on TCP/102
Values always 0 in LOGO! Parameter VM mapping not enabled Tools > Parameter VM mapping Tick "Accessible via network", re-transfer program
Browser shows 401/403 Web server access not enabled Tools > Transfer > Access Control Tick "Allow web server access", set password, transfer
NAI shows stuck value Host is writing the same wrong offset Read back DB1 byte 0..7 via db_read Correct DB number / start offset per the tag map
LOGO! display shows Err on analog block NAI input out of INT16 range Add min/max clamp on host side Clamp to -32768..+32767 before write
Wireshark shows TCP/102 RST LOGO! is in Stop mode LOGO! Soft Comfort > Online > Operating state Set RUN mode, then retry the connection
OPC tags show Quality Bad OPC DA server not started or wrong access point Check OPC.Siemens.Net configuration console Add new S7 connection, IP = LOGO! IP, rack 0 / slot 1
PHP curl returns 501 from LOGO! HTTP Trying to POST to the LOGO! web server Wireshark capture Move the S7 PUT off-board: use Node-RED, KEPServerEX, or Snap7 wrapper

Verification Procedure

  1. Connect a PC to the LOGO! with LOGO! Soft Comfort V8 and go Online > Observe All.
  2. Confirm that the NAI1..NAI4 blocks in the FBD show non-zero values when the host writes a test pattern (e.g. 0x1234).
  3. Force a known value from the host (e.g. set_int(buf,0,1234)), verify that the LOGO! observation window changes within one scan cycle.
  4. Connect a downstream block (Analog Threshold Trigger with on-threshold = 1000) to NAI1 and watch the Q output toggle when the host writes a value above the threshold.
  5. Pull the DataLog .csv from the web interface to confirm that the values reached the LOGO! and were logged.

Safety and Commissioning Notes

Safety: The 0BA8 is rated for 24 V DC or 115/230 V AC supply depending on variant (6ED1052-1CC08-0BA2 = 24 V DC, 6ED1052-1MD08-0BA2 = 115/230 V AC). Wiring must follow the LOGO! installation guide; curtain / barn drives driven by the LOGO! outputs must be fused and protected by an external contactor. Treat any external data source as untrusted: clamp all NAI values on the LOGO! side using a Math instruction with min/max limit, and apply a dead-band (e.g. ignore changes < 0.5 m/s) to suppress jitter in the wind-speed threshold trigger.
Commissioning: Always transfer the LOGO! program via Ethernet with the controller in Stop mode, observe the values for at least one minute, then switch to RUN. Do not enable Parameter VM mapping while the LOGO! is RUN - the mapping is applied on the next cold start.

Can I POST a value directly to the LOGO! 0BA8 web server?

No. The embedded web server on the 0BA8 only serves GET requests (display mirror, TDE, DataLog CSV). It does not implement POST, PUT, or PATCH handlers. Direct HTTP POSTs to the controller IP are answered with HTTP 403/501. Use an S7 client on TCP/102, or a bridging service (Node-RED, KEPServerEX, Snap7 wrapper) that converts HTTP to S7 PUT.

How many external variables can I push into a 0BA8?

The 0BA8 exposes 4 Network Analog Inputs (NAI1..NAI4) and 8 Network Digital Inputs (NI1..NI8) over the S7 server, plus an unlimited number of VM words once Parameter VM mapping is enabled in LOGO! Soft Comfort V8. In practice, 4 scaled analog values are sufficient for wind speed, direction, temperature, and humidity.

Which rack and slot does the LOGO! present to S7 clients?

The 0BA8 presents itself as an S7-200-compatible server on rack 0, slot 1, port 102/TCP. Use those values in Snap7 (Client().connect(ip, 0, 1, 102)), libnodave, S7.NET, and OPC DA configuration consoles.

Why does Parameter VM mapping not work after I transfer the program?

The mapping is honoured only if Access Control is enabled in Tools > Transfer > Access Control (see Siemens KB 108994400) and the LOGO! is power-cycled or cold-started after the transfer. The mapping does not take effect on a soft Stop → RUN transition; remove power, wait 5 s, re-apply, then run.

Can I read the DataLog file from the LOGO! over HTTP?

Yes. Once the web server is enabled and authenticated, the DataLog CSV can be downloaded with GET /logo_file_transfer?file=<logname>.csv or by clicking the Data Log link in the web UI. The file is a standard comma-separated values file with a header row and one row per scan.

Back to blog