sarahghp / p5bots

Use your microcontroller with p5.js
GNU Lesser General Public License v2.1
199 stars 45 forks source link

FIRMATA WIFI ESP8266 #12

Open rahul-thakoor opened 8 years ago

rahul-thakoor commented 8 years ago

hey there, is there a way to use this library with esp8266 running wifi firmata? I mean not using serial but instead use etherport client?

sarahghp commented 8 years ago

There is not currently. I would like to add it — perhaps over the summer — but graduate school has made development on this slow. I would also love a PR for this. hint, hint

Wqrld commented 7 years ago

Any progress? I would also really want to control it from wifi or lan or bluettooth whatever is the easiest for you.

Wqrld commented 7 years ago

this project is kinda dead, you could try to use something like p5.dom and johnny five. It would be a bit harder but that's the way it is

sarahghp commented 7 years ago

Yes, I am pretty taken with other things these days. PRs welcome, tho.

Wqrld commented 7 years ago

i did a little bit of research and it seems like the only thing we need to do is to use etherport.

var Etherport = require("etherport");
var Board = require("firmata");
var board = new Board(new Etherport(3030));

board.on("ready", () => {
  // esp is ready to communicate
});

That should be all we need to do, appart from making a way to select one of the two

edit: the etherport is saying it does only support ethernet but according to firmata.js it isn't

Wqrld commented 7 years ago

i don't know how johnny-five code is related to normal firmata but maybe we can also do it like this:

var EtherPortClient = require("etherport-client").EtherPortClient;
var five = require('johnny-five');
var board = new five.Board({
  port: new EtherPortClient({
    host: "192.168.0.221",
    port: 3030
  }),
  timeout: 1e5,
  repl: false
});
Wqrld commented 7 years ago

i will try to test it myself once i have an esp2866 but that will take some time.

Wqrld commented 7 years ago

this should do the trick but we need to add a dependency for etherport and we need a good way to change between serial and wifi.

Wqrld commented 7 years ago

are you okay with a comment "do this do enable wifi" or do you want a dedicated setting for the server?

edit: if normal etherport doesn't work i/you should try etherport-client

sarahghp commented 7 years ago

Thanks for looking into all this! I think it would be better to let people toggle between wifi and serialport with an optional flag. Once you have a chance to test that it works, open the PR and I can merge and update the new version on npm?