Gateway V9 Released

The Pi Gateway software is now at v9.0.0, this release is a major new feature and bug fix release. This blog entry serves as a change log and feature review. Below are the main highlights.

New Node button & sample metric generators (ex: Internet Speed polling event)

Clicking New Node you may add a numeric ID node. This could be a future RF or LAN node, or a dummy node to hold data such as your internet speed over time (add the Internet Speed event and enable it).

For RF nodes, any node that starts sending data through the serial port attached RF gateway, will automatically generate a new node. For RF nodes, node IDs up to 1023 are now possible thanks to 10bit addressing. Below you can also see a node with ID 999 that reports temperature.


A new Multigraph button on the node page allows generating a graph containing multiple metrics right on the node page. This enables you to easily compare the various metrics of a node chronologically. Clicking the far right remove button under the graph allows you to generate another graph with a different combination of metrics. There is a practical limit to how many metrics you can show since each metric can contain a lot of data and generates a separate vertical legend, so be reasonable and avoid pushing limits. Here’s such a graph showing the various metrics of an RF node:

Desktop graph scroll-zoom & double-click zoom

You may now scroll-zoom with your mouse wheel over a graph (works in all graphs) and it will zoom in and out. You can also double-click and it will zoom in. On mobile devices double tapping will zoom-in.

Edit and Delete metric data

Graphs now show lines between data points instead of bars by default. Still, sometimes it can be confusing looking at lines or bars, where the actual data points are. So you can now turn on data points. Additionally, you can edit and remove any single data point (click on specific data point to edit/remove) or range of data points (select range of data points to remove or change to a new value) if you wish by enabling the edit/delete mode using two buttons below the metric graph. Data points are automatically enabled when editing data.

Easy node image change

You can now change a node’s icon very easily to any existing icon (under the /www/images folder), or upload a new image of your choice (uploaded to /www/images/uploads). Icons should be 120x120px, if larger they are resized. Clicking the node icon:

This brings up the node icon change dialog (pick existing or upload new):

Other icon changes:

  • some default icons have changed (ex. CT-50 thermostat)
  • for consistency, all default icon nodes are now prefixed with icon_
  • rssi icons renamed to rssi_n with n=[1, 7]

New HTTPEndpoint for posting data from LAN

You may now submit data to the Gateway from any LAN device, thus enabling the use of WiFi (ESP anyone?) and network connected nodes, and also essentially removing the need of using only RF nodes. For instance:


will generate a new node (if non existent) with ID=1234, and generate two new metrics (MOTION, and temperature). If an ID is not provided, then the IP of that node becomes the ID. The generated node will always have a new _ip property which contains the IP of the sender. Other examples:

  • /httpendpoint/?MOTION&F=12 ->  ID=(valid IP)
  • /httpendpoint/ -> no update, just lastupdated timestamp

The response will be JSON of this form:
response: {"status":"success","message":"SUCCESS!","matchedMetrics":2}

Run in internet isolated LAN

All script files are now loaded locally and there is no longer a dependence on an internet connected RaspberryPi to fetch these scripts. So there is no concern running this completely disconnected or behind firewalls etc.

Title setting & Menu changes

You can set your own custom title from the settings page, don’t forget to click Save to apply changes. The menu now shows the Gateway app version, when the database was last compacted (done once daily automatically), and an option to compact the database on demand.

You can now quickly restart the app via Ctrl+Atl+Shift+R, or from the Menu as before.

Run it as a Mobile app

You can now run the application as a mobile app. A manifest.json definition that loads automatically with the web page allows you to create a shortcut via the Add To Home Screen option in your mobile device’s browser. Then clicking that icon on your home screen opens the web page like a mobile application without the extra browser bars.

New default metrics

  • It’s sometimes desirable to compare the RSSI of an RF node with the transmit level of an RF node. The new X:n metric with n=[0, 31] allows this to work nicely with the RFM69_ATC library extension and you can see the transmit level drop or rise based on the RSSI change.
  • A new TYPE:nodeType which matches the exports.motes definition of a mote in metrics.js allows to automatically pick that mote’s icon and other features like buttons. Example: when a SwitchMote is powered up, it can send a 1 time TYPE:SwitchMote token to indicate it’s a SwitchMote. You can always later override and pick the node type from the node type dropdown

Other misc changes

  • node name/title added on the metric page – this helps determine which node’s temperature metric you may be looking at (vs. just “Temperature”)
  • ordered Node/Event type dropDowns (A-Z)
  • reworded and simplified licensing terms

Installation and upgrade path

This being such a major change with many new/renamed/deleted files, it’s a good idea to reinstall the application from scratch on a new raspbian image rather than try to do an in-place manual upgrade. This also ensures you will be running the latest and best raspbian, nginx, PHP7, nodeJs & packages, etc.

To transition your data to V9, backup the content of the /home/pi/gateway/data/dbfolder, then make a complete image backup of your currently functional previous version and store that until you are sure V9 runs smoothly on your Pi and all your old data is picked up.

Then follow the Gateway software setup steps in the official guide to install V9 to the latest raspbian image.

Once the V9 is running, to load your old data, you will need to sudo systemctl stop gateway, copy/overwrite the saved data into the new /home/pi/gateway/data/db folder, and then sudo systemctl restart gateway, and you should see all your old nodes and their data.

For any issues and bugs, please use this forum or you may submit a PR to the Github repository. Note that this change log may be edited as any loose ends are tied and before an official release is created.

Gateway app Updated to v8.10

The Pi Gateway software is now at v8.10, this release is mainly a new feature release and also it fixes some issues. You can view a list of all the changes in the official release notes. Here are some quick highlights:

Node/overridable Settings

If you’d like a particular global setting (from settings.json5) to be overridable in a node (for instance minimum voltage for battery powered nodes) you can now do so in metrics.js by using the new settings section under exports.motes, note that the included settings must match the name in settings.json5 or they will be ignored. Example from exports.motes.MotionMote:

imageThen on nodes of that type, the setting can now be set a custom value:

Wifi RadioThermostat CT50 IP setting support

Specific code for the CT50 was updated to support a new IP setting in the UI. This allows the user to override and set the IP of a thermostat on the node page, thus enabling having multiple thermostats with different IPs in the app:

New Setting Types

This enables more user friendly settings. Supported types are jQuery mobile HTML5 defaults, and examples of how to use these are found in the settings.json5 file:

  • checkbox – for true/false settings
  • number
  • email
  • password – obsoletes setting.password:true/false
  • range – min, max
  • default (no type) is text

A few examples using new types:

Email attachments

The sendEmail function in gateway.js has a new parameter where you can pass the URL of an attachment to include in sent emails: global.sendEmail = function(SUBJECT, BODY, **ATTACHMENTS**). Example email with attachment:

Scheduled events time remaining & datetime

Scheduled events now show time remaining until they will run, and the datetime when that happens:

Sunset/sunrise API for events

Based on suncalc, this node API allows creating events that run at various times during the day based on calculation of the sun position. A few examples are:

  • sunrise
  • sunset
  • solarNoon
  • goldenHour
  • dusk
  • dawn

To calculate these events, the latitude/longitude coordinates can be provided on the general settings page:


New All-Events page which shows all scheduled and disabled events:


Modified main menu:

  • removed the Exit item (redundant)
  • added app version:

RSSI is now a metric and logged/graphed by default:


Low Battery Voltage

Warning icon now blinks in/out over the node icon:

As always, when you update:

Controlling AC outlets with SwitchMote

Sometimes you need to remote control an AC outlet that powers something (like a heater or a light or motor etc). There are different IoT solutions out there  like the PowerSwitch Tail which allows hooking up your arduino/IoT device of choice and control 1 outlet.

Naturally, having created the SwitchMote kit, and after being asked in the forums if this could be modded/used to control AC outlets, I made a quick video of how to implement an AC outlet switch-box using a SwitchMote 2x10A, allowing control of 2 independent outlets with local button control as well as visual feedback via the status LEDs of the SwitchMote.

Gateway app updates

There are some notable changes and some new features for the Gateway app – these are published in this Github release. Below is a video overview and a summary of changes:

New settings:

  • serial baud is now 19200 (old: 115200), this is to eliminate any serial corruption when lots of serial data is going in/out to Moteino/MightyHat
  • keepFilesOnDelete (default: false) ensures the binary log files are removed when node/metrics are removed
  • graphMaxPoints – graph data point resolution (total points graphed from raw data)


New features

  • List reordering (desktop only) – drag & drop nodes to reorder list & broadcast to all clients:
  • Graph legend div reformat + count of total raw data points that produced a graph are now displayed on top left.
  • Also there is a new Export-Raw-Data button that generates a CSV file from the selected time window. This was requested here.

Motorized blinds with Moteino

James from looked into automated blinds but when he saw the eye watering prices he decided to make his own wireless motorized blinds. He posted a great detailed tutorial to do just that. The result is motorized blinds automation device that is wireless, low power and costs just $40 for the DIYer. This is a blast considering commercial devices can cost upwards of 10x or more. Here are the highlights of his project:

  • after experimenting with Bluetooth, he decided to use Moteino a try for it’s ability to use ListenMode and make the project very low power
  • the chosen motor was the 28BYJ-48 stepper motor for its low cost ($2), quiet operation and fine control ability
  • he used Fritzing to design a simple yet very elegant shield to host his motor driver and Moteino and posted the schematic, layout and BOM then fabbed the PCBs at MakerStudio:
  • the whole assembly is pretty compact, it uses a 4xAA pack to yield a consumption of just 46µA while running the motor an average 12s/day, that comes to a theoretical 7 years life on a set of high quality 4xAAs. In real life that should last at least 2 years. Here’s what it looks like assembled and installed:

And a demo of it in operation:

John’s Gateway Deep Dive #2: Utility room node

I’m pleased to share another great video from John’s DIY Playground who has posted a detailed overview of his utility room node that can report the dryer status, detect water leaks and control his water heater. A nice example of not only surveillance but also control from a responsive interface he built on top of the Moteino Gateway stack. It’s quite a thrill to see other people innovate and build new truly useful things using some of the hardware and software building blocks I’ve created. He shares his project’s state diagram, explains his code, shows the KiCad design he made for integrating all the parts in a compact design, then moves along to install details and a demo of it in action. His adapted SMS-when-dryer-is-done event notifies him when the clothes are dry and the dryer ready for a new load, nice touch John.

Gateway software update (v8)

There is a new gateway release, “V8”. The sources are at Github. The download link to the latest image is posted here. It contains several updates and new features, bug fixes etc. Most notably:

  • there is a new settings page accessible from the main dashboard. This allows you to edit your settings directly from the GUI instead of manually in the settings.json5 file. I also added a button on the settings page that allows restarting the gateway app, for such cases where this is useful (ie some settings require this, like changing the serial port). There is not a lot of validation done on the settings page, so edit these mindfully of that. The assumption is that you are not trying to break your own server. Also some settings are not exposed, so they will not show up in the GUI, and some are not editable – these will show but you are not supposed to change them. if you still need to, you can manually change the settings.json5 file any way you want on disk, but keep the formatting/nesting of the objects since that format is assumed in the new gateway app release. Here’s a peek at the new UI:
  • I added a new setting called genNodeIfNoMatch (boolean) which can disable new node creation when data is received from a node but no metric is matched to the metrics definition in metrics.js. If you set it to true, a node is added even if no data can be matched to a meaningful metric (node would show in the UI).
  • some new metrics/events were added/improved
  • logs generated by the gateway app are now rotated and archived with logrotate in a new logs subdirectory (if you manually upgrade you need to mkdir /home/pi/gateway/logs). To facilitate this there is a new /etc/logrotate.d/gateway config file that controls this feature. This means the log is kept under a size and history limit to avoid it growing indefinitely.
  • avrdude is now installed on the image so it would support programming MightyHat with a new HEX sketch. Instructions for doing this are on the MightyHat page.

Essentially 4 files have changed: gateway.js, metrics.js, settings.json5, index.html; one file was added: /etc/logrotate.d/gateway. I also posted a MightyHat blueprint DXF case for 1/8″/3mm acrylic (the green areas need to be etched rather than cut).

As always, the image contains pi:raspberry default credentials (change it with passwd) for the main pi login and for the http authentication (make your own .httpasswd file). If you got an ATXRaspi or MightyHat you need to uncomment the line running the shutdowncheck script in /etc/rc.local, to enable power button control. You may also want to create your own secure certificate and setup your wifi. Please let me know if there are any issues or bugs with this release.

John’s Gateway Deep Dive #1: Configuration

John’s DIY Playground has posted a new video where he goes into more detail about how the gateway main code files work and how to start extending the interface and in specific the nodes/metrics that you see on the dashboard. Great video and definitely worth checking out especially for those who want to better understand the inner workings of the gateway code, thanks John and keep it up, looking forward to see more of your setup and hardware!

Another Gateway overview and example implementation

Check out this video from John (his youtube channel here) who implemented a custom home automation system of his own, based on my gateway solution. He has done a little script editing to augment and add to the functionality (new metrics and events) already given via metrics.js. I am looking forward to see more of the details of his implementation and especially the hardware. He mentioned something cool which I initially envisioned as a use case when I designed the hardware but never implemented this feature on my own SwitchMotes: using the unused status LEDs (and button?) of a SwitchMote to display the status of his GarageMote. He also added a sonar sensor to his garage mote to detect whether there is a car parked or not, this could be a really cool addition to a GarageMote. The video also gives an overview of how the gateway and end nodes interact. If John will create more follow up content I will post it wherever appropriate. Thanks John for sharing this!

Gateway software update (v7)

The Moteino Framework Gateway software stack was updated to V7 and new sources are available at their Github repo, and also a new debian-wheezy image with the changes is released (for the image link see the Gateway image page). This release addresses some bugs and adds some significant refactoring and moving of directories. Most importantly the gateway application is now residing in /home/pi/gateway along with the public www directory for ease and more consistency (previously in /home/pi/moteino). Here are the other changes that go with this:

  • the www directory is moved from /var/www/default to /home/pi/gateway/www
  • the .htpasswd file and ssl certificate files are now in /home/pi/gateway/data/secure
  • the database files and log data are now kept in /home/pi/gateway/data/db
  • nconf is used to manage the settings file (previously known as settings.js, it was using straight nodejs exports to import the settings) which is now named settings.json5 and is a JSON5 based (via json5 package) settings file which can be manually edited as well as maintained through the app (in a future release)
  • there is a new package.json file which includes all the node dependencies. If you’re inclined to manually install the software stack, now all you have to do is cd /home/pi/gateway and npm install to get all these dependencies installed
  • the nedb power-loss database purging bug is fixed with a new nedb 1.5 upgrade
  • all server configuration files are updated to reflect the new paths
  • other misc minor changes and optimizations

As usual, if you detect any bugs in this release please let me know asap. Enjoy!