Raspberry Pi 2 Simple HTTP Server using nodejs

Pretty similar to the other python-based project, this time only implemented in JavaScript. And naturally this may be run in any environment, I’m only running it on a RPi2 myself. (and for forum topic naming consistency, had to include it in the title :slight_smile: )

Currently it reads ruuvitags every two minutes (didn’t find it necessary to have real-time data) and persists temperature history in memory to draw the graph. The UI is built with mobile usage in mind, though it scales nicely for bigger screens too. The ruuvitag selection tabs in the bottom of the screen do not scale that nicely if you have more than three ruuvitags.

And yes, it would be pretty easy to map the ruuvitag id’s to some more human-readable (maybe user editable) names but I didn’t find it necessary for my own use.


If you’re using a Raspberry Pi, first make sure that you have bluetooth support installed;

sudo apt-get install bluetooth bluez blueman bluez-hcidump

Install nodejs; either with apt-get or with nvm, I prefer the latter.

Grant the node binary cap_net_raw privileges so it can start/stop BLE advertising without root/sudo;

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

Clone the repo and install the dependencies

git clone https://github.com/kyyhkynen/node-ruuvitag-weather.git
cd node-ruuvitag-weather
npm install

Start the server

node server.js

The default port is 8000, so you can access the UI in http://[your-raspberrys-ip]:8000
To run in in another port, just use the PORT env variable;

PORT=8080 node server.js

To start it in test mode with the UI populated with dummy data, start it with

NODE_ENV=test node server.js

This is so cool and exactly what I wanted to get my tags to do. My problem is that I’m new to programming but that’s ok… I still wanted to say Thank You! I’ve looked thru everything and it looks like fun! You have made it very understandable. Thanks again, Buddy

Nice! Works as intended!
Just a quick note, to get NoBLE running without sudo I needed to run the following line:
sudo setcap cap_net_raw+eip $(eval readlink -f which node)
It will not find the RuuviTag otherwise.

@samuelphy Thanks, good catch! I had done that too in some point while experimenting with nodejs BT support. Will add to the instructions.

Hi, looks nice. But is there any possible to get this to openwrt(omega2+ board) guide for newbies? :smiley:

This does exactly what I wanted and looks nice as well, I managed to name my beacons by adding an if statement for each of them in views/index.pug.