Building an internet connected Sound Detector on an Arduino Yun using Node.js
Connect your sound system to an analogue pin. If you're using the Arduino microphone connect the VCC-pin to the 3.3V pin (not the 5V, that one's comming from the USB power).
opkg update
opkg install openssh-sftp-server
(http://dev.mikamai.com/post/62145565365/how-to-install-an-sftp-server-on-arduino-yun)
http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace
opkg update
opkg install node
Don't install serialport using npm but use the precompiled version for the Yun:
opkg update
opkg install node-serialport
Don't install socket.io using npm but use the precompiled version for the Yun:
opkg update
opkg install node-socket.io
Try to install other Node.js modules on your computer and then copy them to the Yun. Installing modules on can take up some time.
Copy the code to /www/sd/node-sounddetector/app
Linux uses the /dev/ttyATH0
serial port as its main console (it displays booting data when you boot the Linux CPU). You have to disable it in order to use this as a communication channel between the Arduino chip and the Linux CPU.
Open /etc/inittab
and comment out the following line:
ttyATH0::askfirst:/bin/ash --login
Change it to:
# ttyATH0::askfirst:/bin/ash --login
Run the code at least once on your computer so that a fresh public/index.html
is created. Make sure you copy it to the Yun.
Go to /www/sd/node-sounddetector/app
and run:
NODE_ENV=production node app
Go the OpenWRT control panel of your Yun. Go to System
, Local Startup
and add the following line to /etc/rc.local
just before exit 0
:
NODE_ENV=production /usr/bin/node /www/sd/node-sounddetector/app/app.js 1>/www/sd/node-sounddetector/app.log 2>&1 &
Execute:
export TERM=xterm
Edit /usr/bin/node
.
Change:
NODE_PATH=/usr/lib/node_modules /usr/bin/nodejs --stack_size=1024 --max_old_space_size=20 --max_new_space_size=2048 --max_executable_size=5 --gc_global --gc_interval=100 $@
To:
NODE_PATH=/usr/lib/node_modules /usr/bin/nodejs $@
Temporarily.