## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Luis Montes
@monteslu
I can't seem to find anyone actually using it though :)
of course I found this after spending a bit of time making one to trying and match the j5 IO feature set.
will probably keep working on my service since this is just basic pin IO without things like i2c
Akash Budhia
JhonnyFive vs OnOff vs pi-gpio vs r-pi-gpio : Which npm is recommended for use with Raspberry Pi. The one with best performance.
Brian Cooke
@fivdi
@akashbudhia_twitter It depends on what needs to be done. pi-gpio looks like it was abandoned a long time ago and r-pi-gpio is documented as deprecated. That leaves Johnny-Five and onoff (although there are others.) Johnny-Five is a framework that offers high-level access to a ton of components. onoff is a simple library that allows GPIOs to be accessed efficiently. onoff offers a subset of the functionality offered by Johnny-Five. Take a look at the Johnny-Five API and onoff API to see which of them supports what's needs and decide based on that.
Akash Budhia
@fivdi thanks for the prompt response. We have seen both the APIs.
@fivdi from an underlying implementation stand point which one would have been written with an intent for best performance? For our requirement we don't need ready made API for common components. Jhonny-Five seemed to have bigger community, will we be missing on anything if we chose onoff as that's what I'm considering. Also due to the event interrupts.
Brian Cooke
@fivdi

from an underlying implementation stand point which one would have been written with an intent for best performance?

We have to be careful not to compare apples and oranges here as Johnny-Five doesn't perform the actual low level IO on the Raspberry Pi, the IO-Plugin does.

Quite a bit of effort went into making onoff as fast as possible at what it does which is DigitalRead, DigitalWrite and interrupt detection from userspace using the sysfs files located at /sys/class/gpio. I'm unaware of another package that uses sysfs files and is faster than onoff. The advantage of sysfs files is that they exist on many platforms like the Raspberry Pi, BeagleBone, C.H.I.P, ... On a Raspberry Pi 3 onoff can do up to 300,000 digital writes per second.

Because onoff uses sysfs files it functions on multiple platforms. There are also platform specific packages like pigpio that only run on the Raspberry Pi and that take advantage of platform specific hardware to make things faster. For example, pigpio can do up to 2,000,000 digital writes per second on a raspberry Pi 3.

There are two Johnny-Five IO-Plugins for the Raspberry Pi; Rasp-IO and Pi-IO. I implemented Pi-IO and can confirm that Johnny-Five was implemented in a way that makes it possible to write IO-Plugins that are fast. Johnny-Five brings very little additional overhead and performance is highly dependent on how the IO-Plugin is implemented. For example, Pi-IO which uses pigpio internally can do up to 1,700,000 digital writes per second on a Raspberry Pi 3. The corresponding test program can be found here.

In summary, both onoff and Johnny-Five offer excellent performance.

Jhonny-Five seemed to have bigger community

This doesn't just seem to be the case it is the case :)

will we be missing on anything if we chose onoff as that's what I'm considering.

I don't know what the requirements are so I can't tell.

Also due to the event interrupts.

Don't overestimate the capabilities of interrupt detection from userspace on Linux systems. Linux isn't a realtime operating system and there are no guarantees about interrupt latency.

Akash Budhia

Wow. I missed pigpio. I was using onoff so far.

My PI will be integrated with 8 Ultrasonic Sensors, 5 x RS232/RS485 Serial Ports(still deciding on USB vs UART) and 6 Digital IO Pins.

I think will move to pigpio especially for the high number of writes per second.

@fivdi
Brian Cooke
@fivdi
@akashbudhia_twitter HC-SR04 ultrasonic sensors? If so, pigpio provides better timing information than onoff so the measured distances will be more accurate. This may be obvious but don't try to measure distance with multiple ultrasonic sensors at the same time in order to prevent the pulses from one sensor messing up the measurement from another sensor. Pi-IO also supports HC-SR04 ultrasonic sensors (although I'm not sure if Johnny-Five prevents multiple ultrasonic sensors from interfering with each other because Pi-IO currently doesn't prevent it.)
Akash Budhia
I managed to run multiple HC-SR04 by spacing out the cycle. Put the source in JSFiddle for your reference.
This is using OnOff. Planning on rewriting using pigpio.
Brian Cooke
@fivdi
@akashbudhia_twitter interrupt latency will have a negative impact on the accuracy of the proximity measurements when onoff is used. pigpio has a feature called alerts that can determine the time of a state change on a GPIO accurate to a few microseconds and the results will be better. There's an an example here.
Brian Cooke
@fivdi
That example uses two pins, one for trigger and one for echo. Things get trickier with one pin. The IO-Plugin code corresponding to this example which uses one pin for both trigger and echo is here.
Akash Budhia
@fivdi - Thanks for sharing the examples. Will move to pigpio alerts then. For single pin using pigpio will have to change mode to input after sending trigger, subsc.ribe to alert, after every 60us again change mode to output, send trigger for 10us and changed mode to input and so on. Will prepare the code and share with you.
Akash Budhia
@fivdi - I'm writing the code for single pin using pigpio. In the trigger pulse function will need a callback handler as parameter which can be invoked to set the pin as input for listening the echo.
https://github.com/fivdi/pigpio/blob/master/doc/gpio.md#triggerpulselen-level
Brian Cooke
@fivdi
@akashbudhia_twitter the trigger function is a synchronous blocking call that will block for 10 microseconds in this case (which is a very short time.) A callback is therefore not needed.
@akashbudhia_twitter perhaps it would be better to create an issue at the pigpio repo for further discussion as the discussion isn't really related to io-plugins.
Akash Budhia
Will do
dub-ab
@dub-ab
I am using Visual Studio Code as the editor for the Johnny-Five Inventor's Kit projects. The first two projects compile and run with out problem so there is no problem with the code examples. I get error when using the debug process and step through the code on:
Module._resolveFilename
Exception has occurred: Error
Error: Cannot find module 'tessel'
at Function.Module._resolveFilename (module.js:469:15)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (c:\VSCode\j5ik-Exp1\node_modules\tessel-io\lib\index.js:39:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I suspect a path error but can'
t understand how the code will compile and run but not allow debugging.
Does anyone else have this issue?
Rick Waldron
@rwaldron
@dub-ab sorry, just seeing this now
What is Visual Studio Code trying to do? How does this error occur? Are you building with t2 run file.js?
t2-cli knows how to handle resolving the on-board tessel module
dub-ab
@dub-ab
I'm sorry. It's been so long now, that I don't recall. thanks.
dub-ab
@dub-ab
Now I have this problem. any ideas?
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
PS C:\VSCode\j5ik> t2 wifi on
INFO Connected to Tessel-Lime.
INFO Signal Strength: (70/70)
INFO Bitrate: 54mbps
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
PS C:\VSCode\j5ik> t2 provision
INFO Connected to Tessel-Lime.
INFO Authenticating Tessel with public key...
INFO Tessel is already authenticated with this computer.
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
PS C:\VSCode\j5ik>
Donovan Buck
@dtex

Make sure you don't have an access point on.

t2 ap --off

dub-ab
@dub-ab
no go on the access point. I've never turned it on. Then issuing the command
t2 ap --off
I still get the same list. NO wifi.
PS C:\VSCode\j5ik> t2 ap --off
INFO Connected to Tessel-Lime.
INFO Access Point successfully disabled.
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
PS C:\VSCode\j5ik>
Thank you Donovan Buck for leading to the solution. I had pushed an image to the board.
By having erased the image,
t2 erase
I can now list both interfaces.
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
PS C:\VSCode\j5ik> t2 erase
INFO Connected to Tessel-Lime.
INFO Erasing files from Flash...
INFO Files erased.
PS C:\VSCode\j5ik> t2 list
INFO Searching for nearby Tessels...
USB Tessel-Lime
LAN Tessel-Lime
PS C:\VSCode\j5ik>
Donovan Buck
@dtex