Hi Guys,
I wanted to run johnny-five.js on the arduino-yun’s Linux/Linino (Atheros AR933) and talk to the Arduino (MCU;32U4) on the other side.
It took me like two nights to figure it out properly, but it works until the reboot. The hints are on many sites - so I thought i’d consolidate it.
Prepare the Yun’s Arduino
You need more space, buy a 8GB micro-sd card and format it with the YunDiskSpaceExpander sketch. Add like 1000mb for sda1.
Open the sketch Firmata / StandardFirmata and comment the following line
// Firmata.begin(57600);
and replace it with
Serial1.begin(57600);
Firmata.begin(Serial1);
Upload the new sketch (It will ask you for a new file name).
Prepare the Yun’s Linux
(Make sure your Disks is expanded by running above’s YunDiskSpaceExpander sketch).
Use /dev/sda1 as swap
umount /mnt/sda1
mkswap -f /dev/sda1
swapon /dev/sda1
Install the packages
cd /opt
opkg update
# vi sometimes generates xterm errors
opkg install vim
opkg install node
opkg install node-serialport
npm install johnny-five
Modify /etc/inittab
sed -i -e 's/ttyATH0/# ttyATH0/g' /etc/inittab
Modify the board setup e.g. in led-strobe.js
var five = require("johnny-five");
var serialport = require("serialport");
var led;
var serialPort = new serialport.SerialPort("/dev/ttyATH0", {
baudrate: 57600
});
var board = new five.Board({
port: serialPort,
debug: true
});
board.on("ready", function() {
// Create a standard `led` hardware instance
led = new five.Led(13);
// "strobe" the led in 100ms on-off phases
led.strobe(100);
})
And it blinks nicely
root@yun12:/opt# node led-strobe.js
1418849951091 SerialPort /dev/ttyATH0
1418849956331 Connected /dev/ttyATH0
1418849956338 Repl Initialized
But when I reboot the YUN, it won't start up, no white usb light nada. Then I basically have to overwrite the sketch to make the yun accessible again. Its probably something with the firmata modification to Serial1. How can I make that poperly?