diff --git a/NodeJsController/NodeJsController.sh b/NodeJsController/MySensors.sh
similarity index 100%
rename from NodeJsController/NodeJsController.sh
rename to NodeJsController/MySensors.sh
diff --git a/NodeJsController/NodeJsControllerInitScript.sh b/NodeJsController/MySensorsInitScript.sh
similarity index 99%
rename from NodeJsController/NodeJsControllerInitScript.sh
rename to NodeJsController/MySensorsInitScript.sh
index 2c934a5..38a9feb 100644
--- a/NodeJsController/NodeJsControllerInitScript.sh
+++ b/NodeJsController/MySensorsInitScript.sh
@@ -19,7 +19,7 @@
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="MySensors NodeJs Controller"
-NAME="NodeJsController.sh"
+NAME="MySensors.sh"
PIDFILE="/usr/local/var/run/$NAME.pid"
DAEMON="/home/pi/Arduino/NodeJsController/$NAME"
DAEMON_ARGS="$PIDFILE"
diff --git a/NodeJsController/Readme.html b/NodeJsController/Readme.html
new file mode 100644
index 0000000..a2ca54e
--- /dev/null
+++ b/NodeJsController/Readme.html
@@ -0,0 +1,298 @@
+
MySensors with NodeJS Controller and OTA bootloader on RPi
+My RPi runs Arduino to compile and flash sketches and the bootloader. With this setup no separate PC/Mac is needed. Exactly the same could be achieved (faster) using a PC/Mac for all the Arduino compilation and flashing activities – just skip the steps and execute on PC/Mac instead.
+
Hardware
+Headless Raspberry Pi model B with wired Ethernet
+I'm connecting a monitor only for first time boot to get the IP address and then connect via Putty/xRDP
+Download and install latest Raspbian version on a fresh SD-Card
+Tutorials for this task are available on the internet (download, copy to SD)
+Setup base parameters
+(adjust to your needs - here: RPi-IP: 10.0.1.5 / Router-IP: 10.0.1.1 / password: test / timezone: Europe,Berlin / hostname: mysensors)
+
+Install latest updates
+
+- login as pi / test
+
- sudo apt-get update
+
- sudo apt-get upgrade
+
- sudo reboot
+
+Install Remote Desktop
+Optional… my RPi is headless and I use xRDP to connect from a Windows PC to run a graphical UI if needed (e.g. for Arduino IDE)
+
+- login as pi / test
+
- sudo apt-get install xrdp
+
- to confirm it's working as expected try to connect from a remote computer to the RPi (e.g. from a Windows PC using the "Remote Desktop Connection" tool)
+
+Install NodeJS (here: latest stable version available for RPi: 0.10.28)
+
+Install MongoDB
+
+- login as pi / test
+
- sudo useradd -c mongodb -d /home/mongodb -m -U mongodb
+
- sudo mkdir -p /opt/mongo/bin
+
- sudo mkdir /var/lib/mongodb
+
- sudo chown mongodb:nogroup /var/lib/mongodb
+
- sudo mkdir /var/log/mongodb
+
- sudo chown mongodb:nogroup /var/log/mongodb
+
- wget https://github.com/brice-morin/ArduPi/raw/master/mongodb-rpi/mongo/bin/mongo
+
- wget https://github.com/brice-morin/ArduPi/raw/master/mongodb-rpi/mongo/bin/mongod
+
- wget https://github.com/brice-morin/ArduPi/raw/master/mongodb-rpi/mongo/bin/mongodump
+
- wget https://github.com/brice-morin/ArduPi/raw/master/mongodb-rpi/mongo/bin/bsondump
+
- sudo mv mongo /opt/mongo/bin/
+
- sudo mv mongod /opt/mongo/bin/
+
- sudo mv mongodump /opt/mongo/bin/
+
- sudo mv bsondump /opt/mongo/bin/
+
- sudo chmod -R 775 /opt/mongo/bin
+
- sudo ln -s /opt/mongo/bin/mongod /usr/bin/mongod
+
- wget https://raw.githubusercontent.com/skrabban/mongo-nonx86/master/debian/mongodb.conf
+
- wget https://raw.githubusercontent.com/skrabban/mongo-nonx86/master/debian/init.d
+
- sudo mv mongodb.conf /etc/mongodb.conf
+
- sudo mv init.d /etc/init.d/mongodb
+
- sudo chmod 755 /etc/init.d/mongodb
+
- sudo update-rc.d mongodb defaults
+
- sudo reboot
+
- to confirm it's working as expected login as pi/test and run "/opt/mongo/bin/mongo" which should start the mongo shell (type "exit" to close the shell again)
+
- if the RPi loses power without proper shutdown while mongod is running, you can't restart without manually removing the pid file first. To do so run “sudo rm /var/lib/mongodb/mongod.lock”
+
+Install Arduino (and update to latest 1.0.5)
+
+- login as pi / test
+
- sudo apt-get install arduino
+
- wget http://arduino.googlecode.com/files/arduino-1.0.5-linux32.tgz
+
- tar zxvf arduino-1.0.5-linux32.tgz
+
- rm arduino-1.0.5-linux32.tgz
+
- cd arduino-1.0.5
+
- rm -rf hardware/tools
+
- sudo cp -ru lib /usr/share/arduino
+
- sudo cp -ru libraries /usr/share/arduino
+
- sudo cp -ru tools /usr/share/arduino
+
- sudo cp -ru hardware /usr/share/arduino
+
- sudo cp -ru examples /usr/share/doc/arduino-core
+
- sudo cp -ru reference /usr/share/doc/arduino-core
+
- cd ~
+
- rm -rf arduino-1.0.5
+
+Enable programming via GPIO UART (for serial gateway only)
+
+- login as pi / test
+
- wget https://github.com/SpellFoundry/avrdude-rpi/archive/master.zip
+
- unzip master.zip
+
- rm master.zip
+
- cd avrdude-rpi-master
+
- sudo cp autoreset /usr/bin
+
- sudo cp avrdude-autoreset /usr/bin
+
- sudo mv /usr/bin/avrdude /usr/bin/avrdude-original
+
- sudo ln -s /usr/bin/avrdude-autoreset /usr/bin/avrdude
+
- cd ..
+
- rm -rf avrdude-rpi-master
+
+Install MySensors from Git branch development (here: password: test)
+
+- login as pi / test
+
- git clone https://github.com/mysensors/Arduino.git
+
- cd Arduino
+
- git checkout development
+
- cd NodeJsController
+
- npm install
+
- nano NodeJsController.js (optional : removing sample firmwares)
+
const fwHexFiles = [ ];
+ - to confirm that the NodeJsController is working as expected and connects to the local mongo DB: "node NodeJsController.js" which should start the controller, connect to the database and run into an error connecting to the gateway. Stop node again via Ctrl-c
+
+Start NodeJsController on boot
+
+- cd ~/Arduino/NodeJsController
+
- chmod 755 *.sh
+
- sudo cp MySensorsInitScript.sh /etc/init.d/mysensors
+
- sudo mkdir -p /usr/local/var/run
+
- sudo chmod -R 777 /usr/local/var/run
+
- sudo update-rc.d mysensors defaults
+
- sudo reboot
+
- to confirm that NodeJsController is starting at boot, check the log file /home/pi/logs/NodeJsController.log
+
+Configure Arduino
+
+- start graphical UI (startx on RPi or via RDP)
+
- start Arduino IDE
+
- File - Preferences
+
+- set sketchbook location to /home/pi/Arduino
+
- enable verbose output for compilation
+
- enable verbose output for upload
+
+ - Close Arduino IDE
+
+
+Serial Gateway
+Hardware
+
+Disable default use of serial port
+
+Flash (assuming that the ATmega has a valid Arduino bootloader installed)
+
+- login as pi / test
+
- start Arduino IDE
+
+- Tools - Board - Arduino - Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
+
- Tools - Serial Port - /dev/ttyUSB9
+
- File - Sketchbook - SerialGateway
+
- File - Upload
+
+
+Setup NodeJsController
+
+
+Ethernet Gateway
+Hardware
+
+- as described for the standard Ethernet Gateway
+
- I'm using the version with inclusion mode button and LEDs based on no Arduino but a plain ATmega328p on a breadboard and the ENC28J60 Ethernet module
+
+Adjust Sourcecode (here: address 10.0.1.99 / port: 9999)
+
+- [I you are running into compilation errors due to missing files in the utility directory, do the following]
+cp -R ~/Arduino/libraries/UIPEthernet/src/utility ~/Arduino/libraries/UIPEthernet/utility
+
- nano ~/Arduino/libraries/MySensors/MyConfig.h
+
//#define DEBUG
+ - start Arduino IDE
+
+
Flash (assuming that the ATmega has a valid Arduino bootloader installed)
+
+- Connect ethernet gateway to RPi (setup as above for serial gateway or via USB FTDI cable
+
- login as pi / test
+
- start Arduino IDE
+
+- Tools - Board - Arduino - Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
+
- Tools - Serial Port - /dev/ttyUSB9 (or /dev/ttyUSB0 if connecting through USB cable)
+
- File - Sketchbook - EthernetGateway
+
- File - Upload
+
+
+Setup NodeJsController
+
+
+Sensor Node Bootloader
+Hardware
+
+- as described for a simple Sensor Node
+
- here: no Arduino but a plain ATmega328p on a breadboard
+
- using DallasTemperature example (one sensor connected to pin 3)
+
+Compile Bootloader (can be skipped but good to see if everything is working)
+
+- cd ~/Arduino/Bootloader
+
- make
+
- this should compile the bootloader and produce three files in the same directory: MyOtaBootloader.o / MyOtaBootloader.elf / MyOtaBootloader.hex
+
+Flash Bootloader
+
+
+End-to-End Test
+Add Firmware to Controller
+
+Flash Firmware OTA
+
+- tail -f ~/logs/NodeJsController.log
+
- Power up sensor node with OTA bootloader
+
+Check functionality
+
+- in addition to watching the log file (tail command above) you can connect to the mongo db using a client (e.g. Robomongo) and check if new values are written to the database as a real end-to-end test
+
diff --git a/NodeJsController/package.json b/NodeJsController/package.json
index f9ec6ff..a4866a6 100644
--- a/NodeJsController/package.json
+++ b/NodeJsController/package.json
@@ -3,7 +3,8 @@
"version": "0.0.1",
"description": "MySensors Controller based on Node JS",
"dependencies": {
+ "mongodb": "~1.4.7",
"net": "~1.0.2",
- "mongodb": "~1.4.7"
+ "serialport": "^1.4.5"
}
}