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

ruuvi-mqtt-gateway

v1.0.0

Published

Raspberry service acting as ruuvi-mqtt gateway

Downloads

2

Readme


Tue, 18 Feb. 2020 12:13 PM

Ruuvi-mqtt-gateway Box (Raspberry Pi)

First you need a Raspberry Pi with a recent version of Raspbian or Raspbian Lite installed. You can buy a Raspberry Pi 3 Model B here, which is ideal for the job.

I generally use headless systems so everything I outline here will use the command line. Here’s a complete guide to setting up a headless installation of Raspbian Lite.

If you’re working on a GUI installation, just open Terminal and follow the instructions.

1. Install the mosquitto MQTT Broker

mosquitto is a popular MQTT broker that is well-supported on Debian-based Linux platforms such as Raspbian. It’s easy to install using apt:-

You’ll need to enter your password the first time you run sudo.

You don’t strictly need the mosquitto-clients package for running the broker, but installing it allows you to run the MQTT client code locally which is great for testing.

It also means you can use the Raspberry Pi as a proper MQTT client as well as a broker. This means you could, for example, add a user interface to control other MQTT clients around your home directly from the Raspberry Pi.

to set up mosquitto the manual is: https://mosquitto.org/man/mosquitto-conf-5.html

2. Enable MQTT over Websocket

edit the configuration /etc/mosquitto/conf.d/enablews.conf

file contains:

Using Websockets over TLS (SSL) (not used so far)

To use websockets over TLS you need to configure the broker to use TLS.

See this tutorial Mosquitto SSL Configuration -MQTT TLS Security.

Now we edit our** mosquitto.conf** file. It should look like this:websockets-ssl-config-mosquitto

3. Settings for Broker Bridging

The Mosquitto broker (server) can be configured to work as an MQTT bridge. A bridge lets you connect two MQTT brokers together. They are generally used for sharing messages between systems. A common usage is to connect edge MQTT brokers to a central or remote MQTT network.

Generally, the local edge bridge will only bridge a subset of the local MQTT traffic.

mqtt-bridge

again edit the configuration /etc/mosquitto/conf.d/enablews.conf

adding following lines:

The important additions are:

  • connection: defines the start of a bridged connection
  • address: configures the IP address of the MQTT broker to bridge to
  • topic: defines the topic patterns to be shared between the brokers. For this setup, we are subscribing to all topics on the external server, but we are not sharing our local messages with the external server. See the Mosquitto documentation for more information.
  • remote_username and remote_password:if you set up a username and password on your external broker put them here to authenticate

4. Enable the mosquitto broker

Enable the broker and allow it to auto-start after reboot using the following command:-

The broker should now be running. You can confirm by checking the systemd service status:-

This should produce an output similar to:-

5. MQTT Testing

5.1 Install the MQTT Client Package

Installing mosquitto MQTT Client on Linux

You can install the mosquitto client code using:-

If your installation doesn’t yet support apt, replace it with apt-get.

5.2 Subscribe

5.3 Subscribe Remotely

As before, you can now open another terminal in another workstation on the same network and type:-

5.4 Publish

you have to see on both Subscriber terminal Hello World!

6. May be usefull - Identify the Raspberry Pi on the Network

The MQTT client doesn’t need to know very much about the broker, but it does need to know where it is on the network. The MQTT client code needs a hostname or an IP address whenever you subscribe to or publish a message.

If your Raspberry Pi has a unique name on your network, it makes sense to use that. Find the host name on the Pi by typing:-

If yours is left at the default it will return:-

I have too many Raspberry Pis on my network so I called mine mqtt-server to make it unique. If you want to do the same, the easiest way is via sudo raspi-config, but it does require a reboot.

Alternatively, you can always use the Raspberry Pi’s IP address in place of the hostname. An easy way to get this is by running:-

7. Installing forever and forever-service

8. Clone nodejs module from github

9. Make ruuvi-mqtt-gateway.js auto-start at boot time