Giter Site home page Giter Site logo

etherport's Introduction

EtherPort

Build Status

EtherPort is a transport layer that works in conjunction with Firmata.js to enable communcation with an Ethernet capable Arduino or similar device.

Setup

EtherPort can be used to communicate with an Arduino (or similar) board running either:

  1. Update your Arduino IDE's version of Firmata to the latest release following these directions. For StandardFirmataEthernet, be sure to download a Firmata release and not a ConfigurableFirmata pre-release.
  2. If using an Ethernet shield, plug the shield into the board.
  3. Connect the board to the computer via USB (for flashing StandardFirmataEthernet.ino)
  4. Connect the board to the computer via Ethernet
  5. Open Arduino IDE, then: File -> Examples -> Ethernet -> DhcpAddressPrinter and then press the upload button.
  6. Open the serial terminal and copy the IP address
  7. Obtain your ethernet port IP address (many ways to do this)
  8. In the Arduino IDE, open File -> Examples -> Firmata -> StandardFirmataEthernet
  9. If you are using an Arduino Yun, comment out the SPI.h and Ethernet.h includes and uncomment the Bridge.h and YunClient.h includes See Options A and B in the Network Configuration notes.
  10. Update these lines with your computer and board IP addresses:
  • This is the computer's address
#define remote_ip IPAddress(10, 0, 0, 3)
  • This is the arduino's address
#define local_ip IPAddress(10, 0, 0, 15)

Everything on the board side should be ready now, all you need to do is install the latest Johnny-Five and EtherPort:

npm install johnny-five etherport

To test:

var five = require("johnny-five");
var EtherPort = require("etherport");
var board = new five.Board({ 
  port: new EtherPort(3030) 
});

board.on("ready", function() {
  var led = new five.Led(8);
  led.blink(500);
});

License

See LICENSE-MIT file.

etherport's People

Contributors

rwaldron avatar soundanalogous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etherport's Issues

HCSR04 over etherport hangs

Setup:

  1. ATMEGA644PU with microduino bootloader.
  2. ENC28j60 for ethernet communication with UIPEthernet
  3. Modified etherport.ino to add proximity capability ( case PING_READ added in sysexCallback ) - files attached StandardFirmataEthernetPlus_UIPEthernet_proximity.zip.
  4. J5: 0.9.23

Issue:
HCSR04 is connected as in J5 wiki to the pin 22.

HCSR is giving correct values for some time, after which it is hanging/ freezing. On investigation we found that onChange is not getting any values but onData is showing constant values.
We noticed that HCSR object is only freezing whereas everything else is working as expected.

Note:
To quickly check we connected the same via serial-port it apparently is working fine.

var this.pinTrig = 22;
this.usSensor = new five.Proximity(
      {controller: 'HCSR04', pin: this.pinTrig}
);
this.usSensor.on('change', data => {
          this.level = data.inches; 
};
this.usSensor.on('data', data => {
          console.log("in: ", data.inches); 
};

Question:
Not sure what is going wrong. Please help us identify where the problem could be.

My arduino seems to have a stutter

Hi @rwaldron

Again great work on etherport, I have been playing a little with some simple REPL and have noticed some "stuttering" on the arduino.

Here is a little sample code:

var five = require("johnny-five");
var EtherPort = require("etherport");
var myBoard, myLed;

myBoard = new five.Board({
port: new EtherPort(3030)
});

myBoard.on("ready", function() {

led = new five.Led(5);
// make led available as "led" in REPL
this.repl.inject({
led: led
});
});

I first noticed a slight issue on: led.strobe(200)

The flashes seemed a little inconsistent.

I then tried a pulse and noticed the fading again was a little inconsistent.

Then I got the error in the screenshot.

Again not sure if this is a direct result of running over ethernet or not but, I didn't notice this behaviour previously?

image

Many thanks

Andy

Some updates

Regarding the setup instructions for StandardFirmataEthernet, the user now needs to uncomment a couple of includes for their particular ethernet hardware. See this section: https://github.com/firmata/arduino/blob/ethernet/examples/StandardFirmataEthernet/StandardFirmataEthernet.ino#L67-L106

Also, the second part of step 11 should read:

#define local_ip IPAddress(10, 0, 0, 15)

Another thing to note is that if the user uploads ConfigurableFirmata with all of the includes uncommented it will occupy nearly all of the flash and ram on an Arduino Uno so StandardFirmataEthernet is currently the better choice for anyone using and Arduino Uno or other ATmega328 or ATmega32u4-based board. Commenting out unused includes in Configurable is another approach to reducing ram and flash usage.

Connecting does not work anymore. Event Emitter ready never fires

In the past I used ether-port alot to use johnny five with my ESP8266 chips. But now with the newer versions I tried everything and I just cannot get it to work. Even with the most simple setting. This is the code

// I've also tried classical require just to be sure. Same result
import five from 'johnny-five';
import { EtherPortClient } from 'etherport-client';

const board = new five.Board({
  port: new EtherPort({ host: '192.168.xxx.xxx', port: 3030 }),
  repl: false,
  timeout: 1e5
});
board.on('ready', () => {
  console.log('Board Ready');
});

This setting used to work just fine. However the ready emitter never fires and the connection times out. Now I am still using the firmata from http://firmatabuilder.com as I have in the past (could this be a possible issue). Apart from that I checked everything.

  1. The ESP8266 is properly connected to wifi
  2. I scanned the ports and my 3030 is open.
  3. Tested everyhthing with 3 different ESP8266 boards. Same result

I also checked the comms with WireShark and PC and Board are communicating. But not really much and I can't make anything out of it. Here's the data I logged (it's always fired 6 times with this data)

PORT OPEN
<Buffer f9>
<Buffer 02 06 f0 79 02 0a 4d 00 75 00 65 00 6e 00 63 00 68 00 65 00 6e 00 5f 00 41 00 57 00 53 00 31 00 2e 00 69 00 6e 00 6f 00 f7>
<Buffer f0>
<Buffer 6c 00 01 0b 01 7f 00 01 0b 01 7f 00 01 0b 01 7f 00 01 0b 01 7f 00 01 0b 01 7f 00 01 0b 01 7f 7f 7f 7f 7f 7f 7f 00 01 0b 01 7f 00 01 0b 01 7f
00 01 0b ... 14 more bytes>
<Buffer f0>
<Buffer 71 55 00 6e 00 68 00 61 00 6e 00 64 00 6c 00 65 00 64 00 20 00 73 00 79 00 73 00 65 00 78 00 20 00 63 00 6f 00 6d 00 6d 00 61 00 6e 00 64 00
f7>
25 secs over. Closing...

I am completely out of ideas. Here are my currently installed versions

etherport-client: 0.1.4
johnny-five: 1.4.0
serialport: 8.0.6

Need explain:

Hi,

I have three question:

  1. What is easiest way to get my ethernet port IP address?

  2. If i have a friend in another county and i want let him to control on my Arduino throw the Internet, What i have to do?

  3. In line 4 the port is 3030 how to make it a universal port for my Arduino ?

var five = require("johnny-five");
var EtherPort = require("etherport");
var board = new five.Board({
port: new EtherPort(3030)
});

Thank you.

etherport + firmata throws es6-shim bad set error

If I create a new empty project, npm install firmata (eventually swapping with my firmata serial branch once I get this to work) and etherport and try to run blink-firmata like this:

var Firmata = require("firmata").Board;
var EtherPort = require("etherport");
var board = new Firmata(new EtherPort(3030));

board.on("ready", function() {
  console.log("READY!");
  console.log(
    board.firmware.name + "-" +
    board.firmware.version.major + "." +
    board.firmware.version.minor
  );

  var state = 1;

  this.pinMode(8, this.MODES.OUTPUT);

  setInterval(function() {
    this.digitalWrite(8, (state ^= 1));
  }.bind(this), 500);
});

I get the following error:

/Users/soundanalogous/Desktop/etherport-test/node_modules/etherport/node_modules/es6-shim/es6-shim.js:2079
            throw new TypeError('bad set');
                  ^
TypeError: bad set
    at new Set (/Users/soundanalogous/Desktop/etherport-test/node_modules/etherport/node_modules/es6-shim/es6-shim.js:2079:19)
    at /Users/soundanalogous/Desktop/etherport-test/node_modules/etherport/node_modules/es6-shim/es6-shim.js:2218:9
    at isCallableWithoutNew (/Users/soundanalogous/Desktop/etherport-test/node_modules/etherport/node_modules/es6-shim/es6-shim.js:22:22)
    at Object.<anonymous> (/Users/soundanalogous/Desktop/etherport-test/node_modules/etherport/node_modules/es6-shim/es6-shim.js:27:2)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Any idea how to resolve this? I'm trying to test Firmata serial integration in StandardFirmataEthernet and this is the first step.

App takes longer to connect

What are the possible causes of connection delays using Etherport?

When I am using USB, the connection seems to be a lot quicker.
I
Thank you.

serialport dependency

`It looks like serialport didn't compile properly. This is a common problem and its fix is well documented here https://github.com/voodootikigod/node-serialport#to-install

/Users/M.Qaoud/Desktop/tesi/node_modules/johnny-five/node_modules/firmata/lib/firmata.js:28
throw "Missing serialport dependency";
^
Missing serialport dependency`

this issue appears when i run an app.js with node. can you help me!?

board disconnection/connection.

I am experiencing a problem of J5 server crash stop upon arduino disconnected from the network (ECONNRESET), please let me know how to handle this situation.

My understandings are below. Please correct if I am wrong.
J5 don't have board close/reconnect option - so we can't reconnect to arduino once it is detached from the network. unless we restart the server?

Using Configurable firmata

image
Can i use ConfigurableFirmata with this configurations? from http://firmatabuilder.com/
I cant go In the Arduino IDE, open File -> Examples -> Firmata -> StandardFirmataEthernet
because it didn't work for some reason with ENC28J60. It's complicated without examples...
Can i merge https://github.com/ntruchsess/arduino_uip with StandardFirmataEthernet?

p.s I think if it'l will work that will be solution https://github.com/rwaldron/etherport/blob/master/eg/blink-firmata.js

Object #<Object> has no method 'emit'

hi,

i was playing around with my arduino ethernet and looked into etherport. it seems like its not working ootb as it throws this error:

/Users/kevin/Desktop/node_modules/etherport/lib/index.js:29
        this.emit("open");
             ^
TypeError: Object #<Object> has no method 'emit'
    at Object.EtherPort.state.flushTo (/Users/kevin/Desktop/node_modules/etherport/lib/index.js:29:14)
    at Server.<anonymous> (/Users/kevin/Desktop/node_modules/etherport/lib/index.js:42:11)
    at Server.emit (events.js:117:20)
    at TCP.onconnection (net.js:1192:8)

the code I used is fairly simple:

var EtherPort = require("etherport");
new EtherPort(8282) 

simply disabling the line in question in etherport/lib/index.js:29 will fix this issue for now. i have no idea what this line of code is supposed to do, so this might not be the proper way to fix it.

Error A timeout occurred while connecting to the Board.

Hi.
I don't know if this the correct repository to report this issue or if I had to report on J5 repo. Let me know if it is.
Anyway, i'm facing this error while trying to connect J5 to any of my arduino (I had two boards, a UNO and a MEGA).

1493654577494 SerialPort Listening on port: 3030  
1493654577498 Connected Listening on port: 3030  
1493654587501 Device or Firmware Error A timeout occurred while connecting to the Board.

Please check that you've properly flashed the board with the correct firmware.
See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting

If connecting to a Leonardo or Leonardo clone, press the 'Reset' button on the board, wait approximately 11 seconds for complete reset, then run your program again.  
events.js:165
      throw err;

Error: Uncaught, unspecified "error" event. ([object Object])
    at Board.emit (events.js:163:17)
    at Board.log (/home/mateus/Desktop/FronTião/ethernet/node_modules/johnny-five/lib/board.js:635:8)
    at Board.(anonymous function) [as error] (/home/mateus/Desktop/FronTião/ethernet/node_modules/johnny-five/lib/board.js:646:14)
    at Board.<anonymous> (/home/mateus/Desktop/FronTião/ethernet/node_modules/johnny-five/lib/board.js:390:14)
    at ontimeout (timers.js:380:14)
    at tryOnTimeout (timers.js:244:5)
    at Timer.listOnTimeout (timers.js:214:5)

My code is:

var five = require("johnny-five");
var EtherPort = require('etherport');
//var EtherPortClient = require('etherport-client').EtherPortClient;
var board = new five.Board({
  port: new EtherPort(3030)
});
//var board = new five.Board();
board.on("ready", function () {
  var led = new five.Led(13);
  led.blink(500);
});

When I ping on either of them, they respond, and the RX/TX led blink.

I tried use EtherPortClient too, without success (that's why i said that I don't know if this is the correct repository to report this issue). I tried use the timeout on board, without success.

It's weird, because some days ago (a month ago, I think) I could use any of the boards without trouble to my network.

Just to clarify:

  • I'm using node v6.10.1
  • J5 version is 0.10.10
  • Etherport version is 0.1.4
  • Using Ubuntu Gnome 16.04
  • My computer IP is 192.168.0.5
  • My Arduino UNO IP is 192.168.0.9 (Using port 3030 on Standart Firmata Ethernet)
  • My Arduino MEGA IP is 192.168.0.10 (Using port 3040 on Standart Firmata Ethernet)
  • Both of them
  • Using Ethernet Shield W5100

I will wait some help and let me know if I didn't report anything.
Thanks, and sorry for my rusty english.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.