Closed The-Alchemist closed 8 years ago
That's...strange. If i2cdetect isn't showing it, this sounds like a slightly catastrophic failure, but unfortunately I have no idea why.
Some generic troubleshooting tips that might help:
@fivdi do you have any more ideas on what could be causing this?
Despite the fact that i2cdetect -y 1
initially works, I'd say the baud rate is too high.
@fivdi : I have everything at the defaults (i.e., I started with a clean Raspbian Jessie image). What's the best way to change the baud rate?
I can probably try this out later today. :)
The default baud rate is 100,000. Change it to 10,000 to see if it works.
After installing raspi-io
, edit /boot/config.txt
and change the following line:
dtparam=i2c_arm_baudrate=100000
to:
dtparam=i2c_arm_baudrate=10000
Note that the Pi needs a reboot for the change to take effect.
Strangely, I can't reproduce the red RST light on the GrovePI error anymore. I had some bad SD cards, so I maybe that was the cause of it??
But with the baud rate of 10,000 (still Node v4), everything works great, thanks @fivdi and @nebrius !
For the record, this is the code I tested with:
var five = require("johnny-five");
var raspi = require('raspi-io');
var board = new five.Board({
io: new raspi()
});
board.on("ready", function() {
var virtual = new five.Board.Virtual(
new five.Expander("GROVEPI")
);
// Plug the Rotary Angle sensor module
// into the Grove Shield's A0 jack
var rotary = new five.Sensor({
pin: "A1",
board: virtual});
// Plug the LED module into the
// Grove Shield's D6 jack. See
// grove-led for more information.
var led = new five.Led({
pin: "D6",
board: virtual});
// Plug the Rotary Angle sensor module
// into the Grove Shield's A0 jack
var rotary = new five.Sensor({pin: "A0", board: virtual});
// Set scaling of the Rotary angle
// sensor's output to 0-255 (8-bit)
// range. Set the LED's brightness
// based on the value of the sensor.
rotary.scale(0, 255).on("change", function() {
led.brightness(this.value);
});
// Plug the LCD module into any of the
// Grove Shield's I2C jacks.
var lcd = new five.LCD({
controller: "JHD1313M1"
});
// Set scaling of the Rotary angle
// sensor's output to 0-255 (8-bit)
// range. Set the LCD's background
// color to a RGB value between
// Red and Violet based on the
// value of the rotary sensor.
rotary.scale(0, 255).on("change", function() {
var r = linear(0xFF, 0x4B, this.value, 0xFF);
var g = linear(0x00, 0x00, this.value, 0xFF);
var b = linear(0x00, 0x82, this.value, 0xFF);
lcd.bgColor(r, g, b);
});
});
// [Linear Interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
function linear(start, end, step, steps) {
return (end - start) * step / steps + start;
}
P.S. If I get around to it, I'll post some examples using the Raspberry Pi + GrovePi because docs/
.
var five = require("johnny-five");
var raspi = require('raspi-io');
var board = new five.Board({
io: new raspi()
});
board.on("ready", function() {
var virtual = new five.Board.Virtual(
new five.Expander("GROVEPI")
);
var led = new five.Led({
pin: "D4",
board: virtual
});
led.on();
});
sudo node test.js
1494937528166 Available RaspberryPi-IO
1494937528197 Connected RaspberryPi-IO
1494937528211 Repl Initialized
fs.js:718
return binding.writeBuffer(fd, buffer, offset, length, position);
^
Error: Unknown system error -121: Unknown system error -121, write
at Object.fs.writeSync (fs.js:718:20)
I still got the same error above.
Specs
Crossposting for posterity:
So this is a thing: https://github.com/rwaldron/johnny-five/issues/1343#issuecomment-302909593.
There's a fix out that may fix your issue too. Can you update to the latest version of raspi-i2c (one of raspi-io's dependencies) when you get a chance and let me know if you still see this issue?
Stack Trace
i2cdetect -y 1
shows the GrovePi at address 0x04Code
...and then:
i2cdetect -y 1
does NOT show the GrovePi anymore :(Specs