PHGMS log

A first version is working. It uses a Feather ESP8266, which reads the reed switch and posts changes to a MQTT topic on the Sinology. A node app subscribes to that MQTT topic, and serves a webpage to which to re-sends the MQTT events over websockets. The webpage registers the websocket messages and uses them to update the knockout viewmodel. The viewmodel sets CSS classes to show the current state of the reed switch.

This works because I use technologies I previously learned. However, I’d like to change some things which require new skills:

First, I would like to change the wifi radio with a NRF24l01 radio, since these can be made less power-hungry. This could enable the garage sensor to be battery-powered. This means that the receiver would have to be a Raspberry Pi, since the NRF chip needs an SPI interface to be read. The RF24 library by ManicBug has a python-wrapper, so this should be feasible.

To get the RF24 lib working on Raspberry Pi:

To compile the python lib, the swap file needs to be increased (I did 1000mb)

When combining the rf24 lib with MQTT, a segmentation fault occurred. This was solved by running the python script as root.

Currently, communication over the RF24 is working, and a python script which converts radio messages to MQTT events is running. These are hacked together, and should be reworked.

Second, I’m trying to get MQTT working in the browser using webpack. This would simplify the overall design, since I would no longer need a node app, or websockets. I must admit, webpack seems very strange to me…

using require(‘mqtt’) did not seem to work

building mqtt according to the instructions on the npm page yielded several errors, which could be remedied manually.

as the URL, the format of ‘ws://<ip>:9001’ needed to be used. Websockets should be enabled in the mosquitto.conf file.

Currently, it works, but a built browserMqtt.js file is loaded using a script tag. I’d rather have mqtt as a module, which is included by webpack during a build.

Next steps: require(‘knockout’) and webpack that shit!

Update 08/05/2016: using knockout with webpack was easier than expected, and worked right out of the box.

Perhaps it is just the mqtt library which is a bit wonky with webpack, and not webpack itself? Let’s hope so… Currently, it does not seem worth it to focus on mqtt/webpack much longer, I’ll just leave it be and use the ugly way (first, load browserMqtt.js, then bundle.js in script tags).

Next step: porting the existing UI (which worked through websockets) to a webpacked version.

Update 08/05/2016: no surprises, the webpacked version works fine. Possibly, the Pluralsight course can be explored further to see if css and fonts can be included as well. Moreover, a server for the files should be created. Probably best to do on the Sinology, since it can already host node apps?