# automationhat-opcua

> This is an NPM package for building OPC-UA enabled applications with the Pimoroni Automation HAT.

Latest version **0.1.7** (published 2020-10-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install automationhat-opcua
pnpm add automationhat-opcua
yarn add automationhat-opcua
bun add automationhat-opcua
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2020-10-12 |
| First published | 2020-10-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 109.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Martin Petersen |
| Maintainers | martinpetersendev |
| Keywords | opc, automationhat, raspberrypi |

## Links

- npm: https://www.npmjs.com/package/automationhat-opcua
- Repository: https://gitlab.com/MartinPetersenDev/automationhat-opcua
- Homepage: https://gitlab.com/MartinPetersenDev/automationhat-opcua#readme
- Issues: https://gitlab.com/MartinPetersenDev/automationhat-opcua/issues
- npm.io page: https://npm.io/package/automationhat-opcua

## Dependencies (3)

- [onoff](https://npm.io/package/onoff.md) ^6.0.1
- [i2c-bus](https://npm.io/package/i2c-bus.md) ^5.2.0
- [node-opcua](https://npm.io/package/node-opcua.md) ^2.19.0

## Recent versions

- 0.1.7 (latest) — 2020-10-12
- 0.1.6 — 2020-10-12
- 0.1.5 — 2020-10-12
- 0.1.4 — 2020-10-12
- 0.1.3 — 2020-10-11
- 0.1.2 — 2020-10-11
- 0.1.1 — 2020-10-11
- 0.1.0 — 2020-10-11

## README

# Description

This is an NPM package for building OPC-UA enabled applications with the 
Pimoroni Automation HAT.

[![Donations][badge:donate:image]][badge:donate:link]
[![pipeline](https://gitlab.com/MartinPetersenDev/automationhat-opcua/badges/master/pipeline.svg)](https://gitlab.com/MartinPetersenDev/automationhat-opcua)
[![coverage](https://gitlab.com/MartinPetersenDev/automationhat-opcua/-/raw/master/coverage/badge.svg)](https://gitlab.com/MartinPetersenDev/automationhat-opcua)
[![npm version](https://badge.fury.io/js/automationhat-opcua.svg)](https://badge.fury.io/js/automationhat-opcua)

# Installation

```javascript
npm i --save automationhat-opcua
```

# Usage

The following example creates creates an OPC-UA server called
'AutomationHAT' and runs the myApp function every 500 milliseconds.

GPIO, ADC and the content of the 'variables' object is exposed to
OPC-UA.

```javascript
'use strict'
const hat = require('automationhat-opcua');

// My OPC variables
const variables = { resetCounter1: 0 };

// My application
const myApp = (app_var) => {
    // Local variables copy
    const app = { ...app_var };

    // Log message    
    console.log(`MyApp was called! App.resetCounter1 has value ${app.resetCounter1}`);

    // Reset counter1
    if (app.resetCounter1 === 1) {
        hat.gpio.resetCounter(hat.pins.gpio.input1);
        app.resetCounter1 = 0;
    }

    // Return updated application variables
    return app;
}

// Start OPC-UA server and run myApp
hat.run('AutomationHAT', myApp, variables, 500);
```

[badge:donate:image]: https://liberapay.com/assets/widgets/donate.svg
[badge:donate:link]: https://liberapay.com/MartinPetersenDev/donate

---
_Source: https://npm.io/package/automationhat-opcua · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
