Openwrt is a nice LEDE based router platform works on many embedded devices. I am starting to move my IOT platform to it for better easier after install configuration and a much smaller foot print
Getting Openwrt
if installing on pi
https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi
if installing on orange pi bananapi (sunxi) or other platform
https://downloads.openwrt.org/releases/17.01.4/targets/
flash image to your SD as you normally do
expanding the File structure is not so straight forward the as you have to do it externally- the simplest method down load a copy of hiren’s boot cd and use its graphical partitioning software-- also a good little tools to have for a variety of reasons
now log into openwrt and install your related software you may or may not want. perl, collectd, RRD, mosquitto, nano, bash, samba, apache …ETC but most importantly you want to node.js for NODE-RED… you can also setup network related software such as snort (intrusion detection software) wiidog ( captive portal ) .
Installing NODE-RED
installing NODE-RED is easy but not straight forward, you have to compile and setup NODE-RED on another device or platform first- once you do that and NODE-RED has all that you want in it - compress to iot.tar.gz and copy it to a USB stick ( you can also strip it down removing unnecessary files if you like to reduce its size)
USB mounting
ssh into your openwrt -ie:
ssh [email protected]
then
opkg update
opkg install kmod-usb-storage kmod-fs-ext4 kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1
mkdir -p /mnt/usb
mount -t vfat /dev/sda1 /mnt/usb
enter Dir
cd /mnt/usb/
Tar extraction
tar -zxvf iot.tar.gz -C /root
if you need to copy file ( ie such as my mqtt to RRD or influxdb from other howto’s )
cp file.ext /root/iot/file.ext
to list dir "ls "
what i had the most trouble with was setting up NODE-RED and other Software to start at boot as @reboot does not work in cron
the simplest method is in openwrt go to System>Startup near the bottom of the page Local Startup and enter in a format like this, you need the logging otherwise depending on the program it may never move onto the next is also will prevent the device from rebooting normally
/root/iot/./grid.pl & echo "Started Grid RRD" > /root/iot.log
/root/iot/./solar.pl & echo "Started Solar RRD" >> /root/iot.log
/root/iot/./wind.pl & echo "Started Wind RRD" >> /root/iot.log
/usr/bin/node-red >> /root/iot.log & echo "Starting Node-Red" >> /root/iot.log
since it meant for smaller embeded platform if using RRD you could use this for creating RRD it should hold 5 years of data and consumes about 80kb of space
RRDs::create "grid.rrd",
"-s", "300",
"DS:kw:GAUGE:600:U:U",
"RRA:AVERAGE:0.5:1:2016",
"RRA:MIN:0.5:1:2016",
"RRA:MAX:0.5:1:2016",
"RRA:AVERAGE:0.5:6:1344",
"RRA:MIN:0.5:6:1344",
"RRA:MAX:0.5:6:1344",
"RRA:AVERAGE:0.5:24:2190",
"RRA:MIN:0.5:24:2190",
"RRA:MAX:0.5:24:2190",
"RRA:AVERAGE:0.5:144:3650",
"RRA:MIN:0.5:144:3650",
"RRA:MAX:0.5:144:3650";
if using freeboard in NODE-RED its WWW dir is located at
node-red/node_modules/node-red-contrib-freeboard/node_modules/freeboard
and base CGI-BIN
/www/cgi-bin
from here you can follow other tutorial on how to set up your IOT platforms or simply use this
and then simply edit settings.js and change it current port setting of 80 to another one otherwise it will conflict with openwrt
okay good luck have fun