npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sigfox-aws

v2.0.168

Published

Framework for building a Sigfox server, based on Amazon Web Services and Lambda Functions

Downloads

219

Readme

sigfox-aws is a software framework for building a Sigfox server with Amazon Web Service Lambda Functions and AWS IoT MQTT message queues:

  • Modular: Process Sigfox messages in modular steps using simple Node.js (JavaScript) functions and AWS IoT Rules.

  • Extensible: Allows new Sigfox message processing modules and rules to be added on the fly without disrupting or restarting all modules.

  • Robust: The processing modules are implemented as separate AWS Lambda Functions, so one module crashing will not affect others. AWS IoT MQTT message queues are used to pass the Sigfox messages reliably between processing modules.

Read about the sigfox-gcloud architecture here, which is very similar to sigfox-aws: How To Build Your Sigfox Server

We have aligned the Google Cloud (sigfox-gcloud) and AWS (sigfox-aws) frameworks so that any sigfox-gcloud module will work on sigfox-aws and vice versa. The common code for both frameworks has been refactored into sigfox-iot-cloud

Other sigfox-aws modules available:

  1. sigfox-iot-ubidots: Adapter for integrating Sigfox devices with the easy and friendly Ubidots IoT platform

  2. sigfox-iot-data: Adapter for writing Sigfox messages into SQL databases like MySQL, Postgres, MSSQL, MariaDB and Oracle

Integration with AWS IoT

sigfox-aws is seamlessly integrated with AWS IoT and AWS Lambda Functions. Sigfox devices are represented as AWS IoT Things and can be used with AWS IoT Rules.

AWS IoT Things

The sigfox-aws framework automatically creates an AWS IoT Thing for each Sigfox device ID that it discovers through the received Sigfox messages.

AWS IoT Thing Shadow

The Thing Shadow contains the last received Sigfox message and any decoded values from that message.

AWS IoT MQTT Queues

Messages received from Sigfox are added to the AWS IoT MQTT queue sigfox/received before processing.

After decoding the message, it is delivered to the MQTT queue sigfox/devices/<deviceID>. In the example below, the values tmp, hmd and alt were decoded from the data field in the Sigfox message (by the Lambda Function decodeStructuredMessage).

AWS IoT Rules

AWS IoT Rules may listen to the MQTT queue sigfox/devices/<deviceID> to process decoded Sigfox messages by device ID. To send a notification when the temperature sensor value (tmp) exceeds 30, write a rule like this:

The action for the rule could trigger an AWS SNS Email/SMS notification, or a Lambda Function, etc.

Installing the sigfox-aws server

Instructions for installing the sigfox-aws Lambda Functions and AWS IoT Rules may be found here:

https://github.com/UnaBiz/sigfox-aws/blob/master/sigfoxCallback/index.js

https://github.com/UnaBiz/sigfox-aws/blob/master/routeMessage/index.js

https://github.com/UnaBiz/sigfox-aws/blob/master/decodeStructuredMessage/index.js

https://github.com/UnaBiz/sigfox-aws/blob/master/processIoTLogs/index.js

Installing AWS Lambda dependencies automatically with AutoInstall

sigfox-aws uses a script called AutoInstall that allows you to use require(...) for NPM modules in AWS Lambda Functions, without preinstalling or bundling the dependencies in advance. This is meant to replicate the auto NPM install feature in Google Cloud Functions.

The AWS Lambda Function only needs to call AutoInstall with a list NPM modules to be installed.
Upon starting the AWS Lambda Function, AutoInstall will install the NPM modules into /tmp/node_modules. After installing the modules, AutoInstall launches a copy of the current Lambda Function script, by copying it to /tmp/index.js. The Lambda Function may then use the installed modules.

This is not as fast as preinstalling and bundling the dependencies, but it's easier to maintain and faster to prototype. The first call to the AWS Lambda Function is slower (about 20 seconds for sigfoxCallback) because AutoInstall needs to load the dependencies. But subsequent calls will be faster (generally under 1 second) because the dependencies will be reused from /tmp/node_modules until AWS spawns another instance of the Lambda Function.

The AutoInstall script is located at:

https://github.com/UnaBiz/sigfox-iot-cloud/blob/master/autoinstall.js

Standard AutoInstall template with sample usage:

https://github.com/UnaBiz/sigfox-iot-cloud/blob/master/test/test-autoinstall.js

Monitoring the sigfox-aws server

AWS CloudWatch may be used to view the log messages from the Lambda Functions.

AWS X-Ray is supported for tracing Sigfox messages as they are processed via AWS IoT Rules, MQTT Queues and Lambda Functions.

The X-Ray Service Map visualises the flow of Sigfox messages from/to AWS IoT Rules, MQTT Queues and Lambda Functions:

The X-Ray Trace shows the detailed processing of Sigfox messages by AWS IoT Rules, MQTT Queues and Lambda Functions (to filter by devce ID, select User from the filter box):

Clicking a row in the X-Ray Trace shows the Sigfox message in the Annotations Tab. More details are available in the Metadata Tab.

Creating a Sigfox message processing module

Look at aggregateSensorData for a sample Sigfox message processing module that was created with the sigfox-aws framework. This AWS Lambda Function adds up the last 10 values of the tmp (temperature) sensor and injects a new sensor value named tmpsum

https://github.com/UnaBiz/sigfox-aws/blob/master/aggregateSensorData/index.js

sigfox-iot-ubidots adapter for Ubidots

The sigfox-iot-ubidots adapter is an AWS Lambda Function (developed with the sigfox-aws framework) that integrates with Ubidots to provide a comprehensive IoT platform for Sigfox.

With Ubidots and sigfox-iot-ubidots, you may easily visualise sensor data from your Sigfox devices and monitor for alerts. To perform custom processing of your Sigfox device messages before passing to Ubidots, you may write a Google Cloud Function with the sigfox-aws framework.

sigfox-iot-ubidots also lets you to visualise in real-time the Sigfox Geolocation data from your Sigfox devices, or other kinds of GPS tracking data. For details, check out:

https://www.npmjs.com/package/sigfox-iot-ubidots

https://unabiz.github.io/unashield/ubidots

(Note: sigfox-gcloud-ubidots has been merged and renamed as sigfox-iot-ubidots)

sigfox-iot-data adapter for databases

The sigfox-iot-data adapter is an AWS Lambda Function (developed with the sigfox-aws framework) that writes decoded Sigfox messages into many types of SQL databases including MySQL, Postgres, MSSQL, MariaDB and Oracle. For details, check out:

https://www.npmjs.com/package/sigfox-iot-data

(Note: sigfox-gcloud-data has been merged and renamed as sigfox-iot-data)

Other implementations of AWS IoT integration with Sigfox

Sigfox provides an official connector for AWS IoT:

https://aws.amazon.com/fr/blogs/iot/connect-your-devices-to-aws-iot-using-the-sigfox-network/

The official connector for AWS IoT is suitable for simple integration scenarios with fixed Sigfox message formats. The message will be decoded by Sigfox before executing any AWS IoT Rules.

sigfox-aws allows for complex integration scenarios with multiple message formats per device type. AWS Lambda Functions may be built with the sigfox-aws framework to perform custom processing of Sigfox messages. The sigfox-aws adapters for Ubidots and SQL Databases were built with sigfox-aws.

sigfox-aws also supports AWS X-Ray for easier tracing and troubleshooting of Sigfox message processing.