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.

MultiGraphs

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:

https://raspberrypi/httpendpoint/?id=1234&MOTION&F=77.77

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 IP Camera snapshots

Wouldn’t it be cool to take a snapshot of your driveway when the garage is opening, or a snapshot of the mailbox when someone opens it, or a front door image when someone rings your door bell?

If you have an IP Camera on your home network, it most likely has an HTTP endpoint which can serve a static snapshot on demand.

There is now support for a variety of such events in the Gateway app. I’ve added some examples for the doorbell when it RINGs, mailbox and motion motes when they report MOTION, and garage mote when it OPENs. The snapshots get attached to an email that is sent to yourself, so you instantly get an image of the event. Here is a sample email received when my mailbox (essentially a MotionMote) reports motion:

It’s the mail delivery so no issues:

In my case this camera mainly monitors the driveway, so I can have my GarageMote also send me an email when the garage is opened, here’s a sample:

This changeset includes a new setting called ipcam_snapURL that is overriden in the nodes which have such snapshot events. That way different nodes can request snapshots from different IP cameras. Otherwise the value is inherited from the general settings. If you merge this changeset locally, don’t forget to change the IP camera URL in the general settings, which should correspond to your IP camera’s snapshot URL – this should return an image, not a webpage or text/html page, or the attachment will be corrupted. Then, all nodes that override (ie inherit) this setting will display it in the node settings, where you can customize it for that node.

Here is a look at a sample mailbox node which includes the new event and URL setting:

And here’s the event and setting for the garage node:

You can mix and match to create other events based on the given samples. If you create your own variants, I recommend using the userMetrics folder to add new custom code, so the main app files remain unchanged and thus upgrading to new releases is easier in the future. Enjoy!

WeatherShield + supercapacitor + tiny solar cell

There were some interesting discussions in the Low Power Techniques forum about solar power, running motes on super capacitors, and running motes without batteries. I had some tiny solar cells I got long ago from ebay, and I wondered if these could run a low power stock Moteino+WeatherShield node, without any assistance.

Update: the shop now has an offering for a 7.5F SuperCap and a 1W mini Solar Cell which can be used in a similar project as this shown here.

For the experiment I added this 7.5F low-ESR supercap to charge from the solar cell during the day, and keep the mote going at night. To avoid discharge I added a shottky diode from the cell to the cap. The solar cell is actually composed of three tiny cells wired in parallel, the combined capacity is around 0.7W. Here’s the “schematic”:

I initially charged the cap from a 5V source to get it going, and then I attached the cell to a basement blurred glass block window which hardly gets a ton of light:

Note that the shottky does drop 0.2V from the actual capacitor voltage. Even so this worked surprisingly well. Here is the new node in my Gateway UI:

The node transmits temp/hum/pressure/voltage data every minute. Below is a look at a few weeks of the voltage readings. The solar cell charges every day to about 4.25v (actual voltage is ~4.45V b/c of the diode) and discharges to just below 4V.

Quite encouraging, I was pretty sure this would work since the WeatherShield and Moteino sleep at under 7uA, I just wasn’t sure how these old small cells would behave with the supercap. I recon if this node would be placed outside and facing direct sunlight, the charge voltage and overnight dips would be even higher values.

This would also work with a LiPo battery instead of the super cap. Of course, if this was placed outside in the freezing cold, those cheap LiPos from china can die in the cold. But at just $6.50, the supercap is a cheap alternative, much safer and resilient to the cold, and shows how low power is not that complicated.

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:
image

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:
image

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:
image

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:
image

Scheduled events time remaining & datetime

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

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:

image

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

image

Modified main menu:

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

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

imageimage

Low Battery Voltage

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

As always, when you update:

Using PowerShield with Moteino & WeatherShield

John from John’s DIY Playground put together a nice video of setting up a Weather Node powered by a PowerShield from a LiPo battery, watch his assembly vide and demo below.

Although you could directly power the Moteino + WeatherShield from a LiPo battery, this is a good example of how you might assemble & use the PowerShield to get 5V from any lower voltage and power Moteino and other sensors for low power operation.

He also shows how to program it and configure it in his IoT Gateway software.

John mentions he made another video of a similar setup, this shows mating only the WeatherShield and a Moteino  with integrated antenna. Here it is:

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)

image

New features

  • List reordering (desktop only) – drag & drop nodes to reorder list & broadcast to all clients:
    image
  • 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.
    image

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!