Go Down

Topic: Yun, johnny-five and firmata question (Read 2150 times) previous topic - next topic


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

Code: [Select]
  // Firmata.begin(57600);

and replace it with

Code: [Select]

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
Code: [Select]
  umount /mnt/sda1
  mkswap -f /dev/sda1
  swapon /dev/sda1

Install the packages
Code: [Select]
  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
Code: [Select]
  sed -i -e 's/ttyATH0/# ttyATH0/g' /etc/inittab

Modify the board setup e.g. in led-strobe.js
Code: [Select]
  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

And it blinks nicely

Code: [Select]
  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?


Dec 18, 2014, 10:37 pm Last Edit: Dec 18, 2014, 10:38 pm by theluk
Ha! found a hack around: sleep for like a minute before running the sketch. Pretty? Hell no, but it works :-)

Code: [Select]
void setup()


  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
  Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
  Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
  Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
  Firmata.attach(SET_PIN_MODE, setPinModeCallback);
  Firmata.attach(START_SYSEX, sysexCallback);
  Firmata.attach(SYSTEM_RESET, systemResetCallback);
  Serial1.begin(57600); // Set the baud.

  systemResetCallback();  // reset to default config


i need help!! please! once i  Use /dev/sda1 as swap , the system cant detect the sd card once it is connected to my comp-to upload the nodejs file

2)and for windows,how do i Modify /etc/inittab ?

i hope i can get a reply soon
Thank you!

Go Up