rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.31k stars 1.76k forks source link

Support for INA219 High Side DC Current Sensor Breakout #1500

Closed msi-matthew closed 6 years ago

msi-matthew commented 6 years ago

It would be nice to have support for a current sensor, which could be used to trigger other devices. There is an Arduino library made by Adafruit (https://github.com/adafruit/Adafruit_INA219) and a Python library by Chris Borrill (https://github.com/chrisb2/pi_ina219) as well as a few others an Github repos.

What would it take to port one of these into the Johnny Five environment?

dtex commented 6 years ago

This device uses I2C so it is totally doable. The first thing to solve is whether it should be its own, new class, a plug-in, or if an existing class should be expanded to include current sensors (i.e. Relay becomes Power).

I lean toward its own new class. but would be interested to hear what others think.

msi-matthew commented 6 years ago

I also found this repo, which seems capable of interfacing with Johnny Five, but perhaps not in a standardized way. (https://www.npmjs.com/package/ina219)

I'm not sure how J5 classes/plugins are defined, what features are required to make an appropriately defined plug-in?

dtex commented 6 years ago

@msi-matthew I don't know enough about the raspi-io to know if Johnny-Five and the ina219 code can both have access to different GPIO pins on the Pi, but I bet @nebrius can advise on this. I seem to recall that there is a way to tell raspi-io to not use certain pins, leaving them available for other code.

Apart from sharing access to the GPIO pins on the Pi there is no reason that Johnny-Five can't work with that code. Johnny-Five plays nice with others.

nebrius commented 6 years ago

I followed up in the Raspi IO issue thread, but tl;dr yes the ina219 module and raspi-io should work together without modification or the need to use the excludePins property that @dtex was referring to.

dtex commented 6 years ago

Closing. This is being handled over in the raspi-io issue linked above.