Skip to content

Hi level API for node-snap7 to communication with Siemens S7 PLCs

License

Notifications You must be signed in to change notification settings

ChrisDoernen/s7client

 
 

Repository files navigation

S7Client

npm Dependencies Known Vulnerabilities Greenkeeper badge Maintainability Test Coverage Donate

Hi-Level API for node-snap7 to communicate with Siemens S7 PCLs (See compatibility).

  • Promise based, async/await support
  • Returns javascript objects with parsed var objects
  • EventEmitter: (connect, disconnect, connect_error, value)
  • Optional auto reconnect

API Documentation

Blog post about my SIMATIC S7 Web HMI project.

Usage

npm install s7client
const {S7Client} = require('s7client');

// PLC Connection Settings
const plcSettings = {
  name: "LocalPLC",
  host: 'localhost',
  port: 9102,
  rack: 0,
  slot: 2
};

// DBA to read
let dbNr = 1;
let dbVars = [
  { type: "CHAR", start: 0 },
  { type: "BOOL", start: 2, bit: 0 },
  { type: 'INT', start: 3 }
];

let client = new S7Client(plcSettings);
client.on('error', console.error);

(async function() {
  await client.connect();

  // Read DB
  const res = await client.readDB(dbNr, dbVars);
  console.log(res);

  // Write multiple Vars
  await client.writeVars([{
    area: 'db', dbnr: 1, type: 'BOOL',
    start: 5, bit: 2,
    value: true
  }]);

  client.disconnect();
})();

Special thanks to

  • Davide Nardella for creating snap7
  • Mathias Küsel for creating node-snap7

License & copyright

About

Hi level API for node-snap7 to communication with Siemens S7 PLCs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%