Johnny-five: [Question] Does it have any practical use?

Created on 2 Jan 2018  路  12Comments  路  Source: rwaldron/johnny-five

I like this tool, but a huge downside is that, the arduino has to stay connected to the computer. Now this is fine for development and hackathon showcasing. However, if I need to make an actual product, eg: a smart bulb then what should I do?

Most helpful comment

So to summarize:

  • You can't run Johnny-Five directly on an Arduino because an Arduino is just a humble microprocessor
  • There are a number of Single Board Computers (SBC's) that will run node and Johnny-Five (Tessel 2, Raspberry Pi's, Beaglebones, C.H.I.P, etc). They are about the size of a deck of playing cards and plenty powerful for most tasks
  • There are microprocessors that you can communicate with remotely from Johnny-Five over wi-fi, cellular, or the internet (Electric Imp, Photon, etc)
  • There are options that don't use Johnny-Five or node at all, but are in fact Javascript (Espruino and I think Samsung is working on some new devices)

Johnny-Five is awesome for learning, testing and prototyping but if you really are building a product (like a smart light bulb) you are probably going to optimize your hardware to minimize costs and maximize profits. That probably means engineering something that runs on a micro-controller without all the overhead of an operating system and JS engine.

Good luck, and let us know if you need help implementing things in Johnny-Five.

All 12 comments

host your nodejs code in a raspberry pi

As @tvalentius mentions one option would be to host the code on a single board computer that can run Node.js like the Raspberry Pi or BeagleBone Black. The Arduino UNO would then be connected to the single board computer via USB. An Arduino UNO with 32kB of flash and 2kB of RAM is too small for running Node.js.

Alternatively, there are IO-Plugins for Johnny-Five that can run on single board computers and directly use the I/O capabilities of the single board computer thus eliminating the need for an Arduino UNO. Examples of such IO-Plugins are BeagleBone-IO, CHIP-IO, Raspi-IO and Tessel-IO.

It will also be necessary to determine if Johnny-Five (and the IO-Plugin if one is used) supports the devices that you need to have supported. For example, above a smart bulb is mentioned. Does Johnny-Five provide the functionality that's needed to do what you would like to do with the smart bulb?

Agree with everything @fivdi said. Also check out the Electric Imp and imp-io for Johnny-Five. Their target market is IOT devices (like light bulbs) and rather than be a whole SBC it's just a smart, programmable micro-controller with wi-fi and a supporting cloud infrastructure. On one hand that cloud infrastructure is super annoying, but on the other it solves a lot of problems for you. It's worth checking out.

Here's a page with all the platforms Johnny-Five supports

I'm a little confused. What I gathered is that I need a master computer (single board) like raspberry pi which uses the firmata protocol to exchange IO msg with cheap iot chips. am I right?

I'm a little confused. What I gathered is that I need a master computer (single board) like raspberry pi which uses the firmata protocol to exchange IO msg with cheap iot chips. am I right?

IoT is a catch-all term used to describe all sorts of machine-to-machine connectivity where hardware, sensors and actuators communicate with each other. Whether or not Johnny-Five is suitable for what you would like to do depends on your use case.

Above you ask if it's correct that a Raspberry Pi can use the Firmata protocol to exchange IO messages with cheap IoT chips. I would say this depends on what your understanding of a cheap IoT chip is. If a cheap IoT chip is an ATmega328 microcontroller on an Arduino UNO then the answer is yes. Communicating with an Arduino UNO is one of the main uses cases of Johnny-Five. So how can the Arduino UNO connected to the Raspberry Pi be controlled over the Internet? One way to do this is with a service like PubNub. Take a look at the Prototyping a smart bulb with JavaScript, Arduino + PubNub to see how this can be achieved.

@fivdi but in the demo, it will only work when the arduino is connected to the pc so that the pc does all the heavy lifting (communicating with pubnub) and then send instructions to the arduino.

In reality javascript is not run on the arduino right?
Is there any solution in which I can put Javascript on the board so that it doesn't need to be connected to the pc at all times during its operation.

One such thing I found is MongooseOS, but it works with specific boards only.

@fivdi but in the demo, it will only work when the arduino is connected to the pc so that the pc does all the heavy lifting (communicating with pubnub) and then send instructions to the arduino.

A PC isn't needed. We discussed this above. It can be replaced with a Raspberry Pi.

In reality javascript is not run on the arduino right?

Correct.

Is there any solution in which I can put Javascript on the board so that it doesn't need to be connected to the pc at all times during its operation.

Yes, I mentioned this in my fist response above: _"Alternatively, there are IO-Plugins for Johnny-Five that can run on single board computers and directly use the I/O capabilities of the single board computer thus eliminating the need for an Arduino UNO. Examples of such IO-Plugins are BeagleBone-IO, CHIP-IO, Raspi-IO and Tessel-IO."_ In such a scenario the Raspberry Pi could control the bulb directly and the Ardunino UNO would not be needed.

One such thing I found is MongooseOS, but it works with specific boards only.

If you want to use Johnny-Five / Node.js you need a big heavy application processor to run it. An application processor like those found in PCs and single board computers like the Raspberry Pi. Mongoose OS is for microcontrollers, not for application processors. Node.js does not run on microcontrollers it only runs on big heavy application processors.

Is there any solution in which I can put Javascript on the board so that it doesn't need to be connected to the pc at all times during its operation.

I highly recommend Espruino. Not only you can put JS _directly_ on the board, but you can also use it interactively like REPL which makes prototyping into really amazing experience. One drawback is that due to memory limitations you should forget about using npm modules.
Check out this basic demo at https://www.youtube.com/watch?v=j1TsCmDhFtk

another drawback of espruino is that it doesn't follow the io-plugin architecture of johnny-five. So even if the espruino device had enough memory for npm, you couldn't leverage johnny-five apis and johnny-five related apis such as oled.js and node-led.

raspberry pi, C.H.I.P, and beaglebone can all run j5 on board and directly interface with the GPIOs.

even if the espruino device had enough memory for npm, you couldn't leverage johnny-five apis and johnny-five related apis such as oled.js and node-led

I'm not sure if it matters at all. Espruino comes with its own modules and supports a ton of devices.

Just to make it clear - I absolutely admire j5 for its architecture and features and I DO use johnny-five as well. That's because in my opinion they are both fit for very different projects and you can't swap j5 for espruino and vice versa.

So to summarize:

  • You can't run Johnny-Five directly on an Arduino because an Arduino is just a humble microprocessor
  • There are a number of Single Board Computers (SBC's) that will run node and Johnny-Five (Tessel 2, Raspberry Pi's, Beaglebones, C.H.I.P, etc). They are about the size of a deck of playing cards and plenty powerful for most tasks
  • There are microprocessors that you can communicate with remotely from Johnny-Five over wi-fi, cellular, or the internet (Electric Imp, Photon, etc)
  • There are options that don't use Johnny-Five or node at all, but are in fact Javascript (Espruino and I think Samsung is working on some new devices)

Johnny-Five is awesome for learning, testing and prototyping but if you really are building a product (like a smart light bulb) you are probably going to optimize your hardware to minimize costs and maximize profits. That probably means engineering something that runs on a micro-controller without all the overhead of an operating system and JS engine.

Good luck, and let us know if you need help implementing things in Johnny-Five.

Thanks @dtex

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Spy474 picture Spy474  路  10Comments

peetj picture peetj  路  7Comments

beriberikix picture beriberikix  路  11Comments

hxlnt picture hxlnt  路  6Comments

camer0 picture camer0  路  5Comments