rwaldron / johnny-five

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

How to fix EIO,i/o error #1128

Closed asit569 closed 8 years ago

asit569 commented 8 years ago

Getting this error please resolve

pi@raspberrypi:~ $ cd waterpi-node pi@raspberrypi:~/waterpi-node $ sudo node index.js 1462815306876 Device(s) RaspberryPi-IO 1462815307277 Connected /dev/ttyACM0 1462815307365 Connected RaspberryPi-IO connect 1462815311112 Board ID: pi 1462815311114 Board ID: uno 1462815311129 Repl Initialized

ready Temperature: 33.00C, humidity: 45.00% fs.js:613 return binding.writeBuffer(fd, buffer, offset, length, position); ^ Error: EIO, i/o error at Error (native) at Object.fs.writeSync (fs.js:613:20) at Bus.i2cWriteSync (/home/pi/waterpi-node/node_modules/raspi-io/node_modules/raspi-i2c/node_modules/i2c-bus/i2c-bus.js:340:13) at I2C.writeSync (/home/pi/waterpi-node/node_modules/raspi-io/node_modules/raspi-i2c/lib/index.js:332:34) at Raspi.i2cWrite (/home/pi/waterpi-node/node_modules/raspi-io/lib/index.js:559:19) at Expander.write (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:49:11) at LCD.Controllers.PCF8574.initialize.value (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:341:23) at new LCD (/home/pi/waterpi-node/node_modules/johnny-five/lib/lcd.js:734:10) at Boards. (/home/pi/waterpi-node/index.js:60:9) at Boards.emit (events.js:107:17) at Boards. (/home/pi/waterpi-node/node_modules/johnny-five/lib/board.js:1197:14) at process._tickDomainCallback (node.js:381:11)

nebrius commented 8 years ago

Looking at the output, it would appear that you are trying to use Raspi IO and an Arduino Uno connected to the serial port, is that correct? Do you need to use both boards?

If so, I think I know what's going on, Raspi IO is trying to claim the serial port for use with board.io.serial* and Johnny-Five is also trying to claim the serial port for use with the Uno+Firmata. Yeah, we need to do something about this.

Regardless, I think it would be worthwhile to add a flag to the Raspi IO constructor to tell it to not initialize the serial port.

nebrius commented 8 years ago

Thinking through this more, this serial port that it's talking about (/dev/ttyAMA0) is different than the USB one used by an Uno. @rwaldron does J5 try and open all serial ports it can find and scan them for Firmata devices? If so, is there a way to blacklist certain ports?

fivdi commented 8 years ago

The stack trace indicates that an attempt is being made to send information to an I2C LCD wired to the GPIO header on a Raspberry Pi but the I2C LCD can't be found.

As mentioned above, there also appears to be an Arduino Uno connected via USB (/dev/ttyACM0) to the Raspberry Pi, is this correct? There's no mention of the serial port broken out onto the GPIO header on the Raspberry Pi (/dev/ttyAMA0) in the OP.

@asit569 It's probably best if you explain what needs to be achieved with the Arduino Uno and the Raspberry Pi.

asit569 commented 8 years ago

@fivdi i am using aws iot and dynamo db for sensor will timely monitor and display it on lcd if everything correct but it ends up with error please see these below what i want to achieve

https://www.hackster.io/demirhanaydin/waterpi-houseplant-remote-watering-and-monitoring-system-340400 https://github.com/demirhanaydin/waterpi-node

fivdi commented 8 years ago

Lets see if the LCD can be found on the Raspberry Pi.

First run this command:

pi@raspberrypi:~ $ ls -l /dev/i2*

This should output either this:

crw-rw---- 1 root i2c 89, 1 May  8 23:04 /dev/i2c-1

or this:

crw-rw---- 1 root i2c 89, 1 May  8 23:04 /dev/i2c-0

If /dev/i2c-1 was found, run the following command:

i2cdetect -y -r 1

If /dev/i2c0 was found, run the following command:

i2cdetect -y -r 0

Note that if command i2cdetect can't be found it will need to be installed with the following command first:

sudo apt-get update
sudo apt-get install i2c-tools

Then post the output of the command i2cdetect

nebrius commented 8 years ago

Good catch, I was misreading the output @fivdi.

fivdi commented 8 years ago

@nebrius perhaps you were being distracted by work :)

asit569 commented 8 years ago

@fivdi pi@raspberrypi:~/waterpi-node $ i2cdetect -y -r 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3f 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

asit569 commented 8 years ago

i have detached all parts lcd,dht 11,relay from pi then also same error exist @nebrius @fivdi

fivdi commented 8 years ago

Yes, if everything is detached the same error should occur.

Please edit /home/pi/waterpi-node/index.js

and change these lines:

  lcd = new five.LCD({ 
    controller: "LCM1602",
    board: this.byId('pi')
  });

to:

  lcd = new five.LCD({ 
    controller: "PCF8574A",
    board: this.byId('pi')
  });

and then check to see if the LCD works.

asit569 commented 8 years ago

Yes finally it solves the issue @fivdi Thankyou

nebrius commented 8 years ago

perhaps you were being distracted by work :)

It's what they pay me for after all :) Thanks for the help @fivdi, and I'm glad you got it working @asit569!

fivdi commented 8 years ago

Excellent!

@asit569 If all is ok now you could hit the Close issue button at the bottom of the page :)

yangzai commented 8 years ago

Is there any way to catch i2c errors like this?

nickcoutsos commented 8 years ago

Sorry to bring up a closed issue but I got here with the same question as @yangzai and didn't see a solution documented. The i2c error is raised by the board itself and can be handled by listening for its error event:

board.on('error', function(err) { console.error(err) })
NishantWioc commented 6 years ago

This problem still exists for me Please Help

`1520356539428 Available RaspberryPi-IO 1520356539906 Connected /dev/ttyACM0 1520356540206 Connected RaspberryPi-IO connect 1520356544141 Board ID: pi 1520356544150 Board ID: uno 1520356544197 Repl Initialized

ready Temperature: 0.00C, humidity: 0.00% fs.js:753 return binding.writeBuffer(fd, buffer, offset, length, position); ^

Error: EREMOTEIO: remote I/O error, write at Object.fs.writeSync (fs.js:753:20) at Bus.i2cWriteSync (/home/pi/Desktop/waterpi-node-master/node_modules/i2c-bus/i2c-bus.js:348:13) at I2C.writeSync (/home/pi/Desktop/waterpi-node-master/node_modules/raspi-i2c/dist/index.js:294:38) at RaspiIOCore.i2cWrite (/home/pi/Desktop/waterpi-node-master/node_modules/raspi-io-core/dist/index.js:744:19) at Expander.portWrite (/home/pi/Desktop/waterpi-node-master/node_modules/johnny-five/lib/lcd.js:64:11) at LCD.value (/home/pi/Desktop/waterpi-node-master/node_modules/johnny-five/lib/lcd.js:371:23) at new LCD (/home/pi/Desktop/waterpi-node-master/node_modules/johnny-five/lib/lcd.js:792:10) at Boards. (/home/pi/Desktop/waterpi-node-master/index.js:60:9) at Boards.emit (events.js:159:13) at Boards. (/home/pi/Desktop/waterpi-node-master/node_modules/johnny-five/lib/board.js:1208:14) `

I tried the above solutions, My LCD is connected and i'm able to detect it using the method suggested by @fivdi

I changed lcd = new five.LCD({ controller: "LCM1602", board: this.byId('pi') }); lcd = new five.LCD({ controller: "PCF8574AT", board: this.byId('pi') }); Because my I2c module uses this controller i found it on the backside of it, but still same error :( Is there something related to temperature sensor not working or not connected ?

fivdi commented 6 years ago

@NishantWioc

The "remote I/O error" means that Johnny-Five / Raspi-IO can't communicate with the I2C LCD.

Can you post the complete output of i2cdetect -y -r 1 please? Please also post the complete content of /boot/config,txt. Can you post a picture that clearly shows how the I2C LCD is connected to the Raspberry Pi?

Is there something related to temperature sensor not working or not connected ?

There appears to be something wrong as "Temperature: 0.00C, humidity: 0.00%" is displayed which doesn't seem plausible. I'm not familiar with the node-dht-sensor module which is used to measure the temperature and humidity. You'll need to figure out if the library is being used correctly. It may also be necessary to use the Raspi-IO excludePins option to tell Raspi-IO not to initialize the pins used by the DHT sensor.

NishantWioc commented 6 years ago

Output for ls -l /dev/i2

crw-rw---- 1 root i2c 89, 1 Mar 6 18:02 /dev/i2c-1

Output For `i2cdetect -y -r 1

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3f 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

Content of Boot/config.txt

config.txt

Image for Raspberry to LCD connection

2

Image for i2cdetect -y -r 1

screenshot 27

NishantWioc commented 6 years ago

MORE PICTURES

p_20180308_225733 p_20180308_225045 p_20180308_225127 p_20180308_225219 p_20180308_225231

NishantWioc commented 6 years ago

Now I'm getting this New Error

screenshot 29

fivdi commented 6 years ago

Nice pictures. Everything and in particular the LCD looks good to me.

The "TypeError: Cannot read property forEach of undefined" is occurring on this line of code which is for a parallel LCD not an I2C LCD.

Has the code been modified since yesterday? Is the following line of code not being use to create an LCD instance anymore?

 lcd = new five.LCD({ controller: "PCF8574AT", board: this.byId('pi') });
fivdi commented 6 years ago

There's also an Arduino UNO connected to one of the USB ports on the Pi, correct? I can't see it in the photos.

fivdi commented 6 years ago

Maybe it would be a good idea to test the components one by one to get them to work before tyring everything at the same time.

For example, if the Arduino UNO is disconnected from the USB port and the following (untested) program is run on the Pi does it display anything on the LCD?

const Raspi = require('raspi-io');
const five = require('johnny-five');
const board = new five.Board({
  io: new Raspi()
});

board.on('ready', () => {
  var count = 0;
  var lcd = new five.LCD({ 
    controller: "PCF8574AT"
  });

  setInterval(() => {
    count += 1;
    lcd.print('Hello' + count);
  }, 1000);
});
NishantWioc commented 6 years ago

Thanks for your quick reply :) umm I didn't modified the code. What i can do is download the project once again with clean code. Because it may be possible that i removed something from code during removing lcd code. but that's an another file with lcd code removed

this code is still in use lcd = new five.LCD({ controller: "PCF8574AT", board: this.byId('pi') });

Yes You are right there's an Arduino Uno connected to one of the Usb Port of pi, I'll try the same as you suggested then i will tell you the results :) Thanks once again :D

NishantWioc commented 6 years ago

Lcd Prints Nothing

I tried the above code and everything looked fine, i disconnected Arduino too but lcd prints nothing

following is the output

` 1520617959178 Available RaspberryPi-IO 1520617959535 Connected RaspberryPi-IO 1520617959617 Repl Initialized

`

Here's the picture

screenshot 30

It tried something

lcd.print('Hello'); console.log(lcd.print('Hello'))

Output

`1520618340723 Available RaspberryPi-IO 1520618341140 Connected RaspberryPi-IO 1520618341233 Repl Initialized

LCD { board: Board { io: RaspiIOCore { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, name: 'RaspberryPi-IO', isReady: [Getter], pins: [Getter], analogPins: [Getter], MODES: [Object], HIGH: 1, LOW: 0, defaultLed: -1, SERIAL_PORT_IDs: [Object] }, timer: Timeout { '0': null, _called: false, _idleTimeout: -1, _idlePrev: null, _idleNext: null, _idleStart: 5974, _onTimeout: null, _timerArgs: undefined, _repeat: null, _destroyed: false,

[Symbol(triggerAsyncId)]: 7 }, isConnected: true, isReady: true, register: [ [Circular] ], occupied: [], Drivers: {}, id: 'DE2690CA-F153-4772-A103-41E63E2F5537', debug: true, repl: Repl { context: [Object], ready: true, cmd: [REPLServer] }, sigint: true, pins: Pins { '0': [Object], '1': [Object], '2': [Object], '3': [Object], '4': [Object], '5': [Object], '6': [Object], '7': [Object], '8': [Object], '9': [Object], '10': [Object], '11': [Object], '12': [Object], '13': [Object], '14': [Object], '15': [Object], '16': [Object], '17': [Object], '18': [Object], '19': [Object], '20': [Object] }, transport: null, port: 'RaspberryPi-IO', type: 'OTHER', _events: { ready: [Function] }, _eventsCount: 1, MODES: { INPUT: 0, OUTPUT: 1, ANALOG: 2, PWM: 3, SERVO: 4 }, millis: [Function] }, io: RaspiIOCore { domain: null, _events: { close: [Function: bound ], disconnect: [Function: bound ], error: [Function: bound ], string: [Function: bound ] }, _eventsCount: 4, _maxListeners: undefined, name: 'RaspberryPi-IO', isReady: [Getter], pins: [Getter], analogPins: [Getter], MODES: { INPUT: 0, OUTPUT: 1, ANALOG: 2, PWM: 3, SERVO: 4 }, HIGH: 1, LOW: 0, defaultLed: -1, SERIAL_PORT_IDs: { HW_SERIAL0: '/dev/ttyAMA0', DEFAULT: '/dev/ttyAMA0' } }, id: '0B7F4E4B-BD82-4092-B263-56F9D574D61D', custom: {}, controller: 'PCF8574AT', ctype: 'PCF8574AT', bitMode: 4, lines: 2, rows: 2, cols: 16, dots: '5x8', address: { lcd: 63 }, expander: Expander { address: 63, mask: 0, memory: 249, io: RaspiIOCore { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, name: 'RaspberryPi-IO', isReady: [Getter], pins: [Getter], analogPins: [Getter], MODES: [Object], HIGH: 1, LOW: 0, defaultLed: -1, SERIAL_PORT_IDs: [Object] } } }`

LCD Status

p_20180309_235324

fivdi commented 6 years ago

So there are no errors but nothing is displayed on the LCD. This is strange. Does adjusting the blue potentiometer on the LCD interface board help? If it doesn't, I can't think of anything else to do other than trying to debug the problem. I'm afraid I don't have an I2C LCD to give it a try.

NishantWioc commented 6 years ago

I think either i have to adujst the potentiometer or the lcd is getting the garbage data. For Now i have just removed the lcd code, and the project is working fine. I'll try to debug the problem :) Thanks for your help ;)