New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 Firmata #257

Closed
soundanalogous opened this Issue Dec 24, 2015 · 74 comments

Comments

Projects
None yet
@soundanalogous
Member

soundanalogous commented Dec 24, 2015

Add support for the ESP8266 Wi-Fi module. An arduino core for the ESP8266 is available here. Should be fairly straight forward to add Firmata support.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Dec 24, 2015

Member

Looks like there is work in progress here: https://github.com/kotl/esp8266-firmata.

Member

soundanalogous commented Dec 24, 2015

Looks like there is work in progress here: https://github.com/kotl/esp8266-firmata.

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Feb 18, 2016

Contributor

@monteslu has had me working on this today. Since esp's are in the board manager now, https://github.com/esp8266/Arduino/ StandardFirmata works just fine, you just need to add a Board definition. Heres one without analog or pwm

// ESP8266 generic
#elif defined(ARDUINO_ESP8266_ESP01)
#define TOTAL_ANALOG_PINS       0
#define TOTAL_PINS              17
#define VERSION_BLINK_PIN       4
#define IS_PIN_DIGITAL(p)       ((p) == 0 || (p) == 2 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16)
#define IS_PIN_ANALOG(p)        (false)
#define IS_PIN_PWM(p)           (false)
#define IS_PIN_SERVO(p)         ((p) >= 0 && (p) < MAX_SERVOS)
#define IS_PIN_I2C(p)           (false)
#define IS_PIN_SPI(p)           (false)
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        ((p) - 17)
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p)         p

Playing with wifi now. The ESP wifi is mostly compatible, Im working on either forking the WifiStream or upstreaming changes to the ESP's wifi.h to make it 100% compat so firmata wifi should work out of the box as well.

Contributor

jacobrosenthal commented Feb 18, 2016

@monteslu has had me working on this today. Since esp's are in the board manager now, https://github.com/esp8266/Arduino/ StandardFirmata works just fine, you just need to add a Board definition. Heres one without analog or pwm

// ESP8266 generic
#elif defined(ARDUINO_ESP8266_ESP01)
#define TOTAL_ANALOG_PINS       0
#define TOTAL_PINS              17
#define VERSION_BLINK_PIN       4
#define IS_PIN_DIGITAL(p)       ((p) == 0 || (p) == 2 || (p) == 4 || (p) == 5 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 || (p) == 16)
#define IS_PIN_ANALOG(p)        (false)
#define IS_PIN_PWM(p)           (false)
#define IS_PIN_SERVO(p)         ((p) >= 0 && (p) < MAX_SERVOS)
#define IS_PIN_I2C(p)           (false)
#define IS_PIN_SPI(p)           (false)
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        ((p) - 17)
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p)         p

Playing with wifi now. The ESP wifi is mostly compatible, Im working on either forking the WifiStream or upstreaming changes to the ESP's wifi.h to make it 100% compat so firmata wifi should work out of the box as well.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Feb 18, 2016

Member

Thanks! Looking forward to this! There are different configurations based on solder jumpers right? Maybe that is specific to Sparkfun ESP8266 boards however. Any particular ESP8266 modules you recommend? I haven't messed around with them yet but will order some.

Member

soundanalogous commented Feb 18, 2016

Thanks! Looking forward to this! There are different configurations based on solder jumpers right? Maybe that is specific to Sparkfun ESP8266 boards however. Any particular ESP8266 modules you recommend? I haven't messed around with them yet but will order some.

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal
Contributor

jacobrosenthal commented Feb 18, 2016

@jacobrosenthal

This comment has been minimized.

Show comment
Hide comment
@jacobrosenthal

jacobrosenthal Feb 18, 2016

Contributor

@soundanalogous I literally touched them for the first time today as a favor to @monteslu :) Just wanted to connect these dots I saw.

Contributor

jacobrosenthal commented Feb 18, 2016

@soundanalogous I literally touched them for the first time today as a favor to @monteslu :) Just wanted to connect these dots I saw.

@rwaldron

This comment has been minimized.

Show comment
Hide comment
@rwaldron

rwaldron Feb 18, 2016

Contributor

Wow, this is awesome.

I have 3 different ESP boards:

Here are the notes I started when I first looked at the ESP8266: https://github.com/rwaldron/esp-io/blob/master/journal.md#io

Contributor

rwaldron commented Feb 18, 2016

Wow, this is awesome.

I have 3 different ESP boards:

Here are the notes I started when I first looked at the ESP8266: https://github.com/rwaldron/esp-io/blob/master/journal.md#io

@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Feb 18, 2016

we used the ESP8266 01 boards and connected to an ftdi chip like this to program it:
esp

When it gets power it boots into programming mode.

With Jacob's sketch we were able to blink pin 2 with johnny-five like this:

var net = require('net');

var firmata = require('firmata');
var five = require("johnny-five");


var options = {   
  host: '172.22.111.111',  // IP of ESP board
  port: 3030  
};



var client = net.connect(options, function() {

  var socketClient = this;

  var io = new firmata.Board(socketClient);
  io.once('ready', function(){
      console.log('IO Ready');
      io.isReady = true;

      var board = new five.Board({io: io, repl: true});

      board.on('ready', function(){
          console.log('five ready');
          //Full Johnny-Five support here:

          var led = new five.Led(2);
          led.blink();
      });
  });

});


monteslu commented Feb 18, 2016

we used the ESP8266 01 boards and connected to an ftdi chip like this to program it:
esp

When it gets power it boots into programming mode.

With Jacob's sketch we were able to blink pin 2 with johnny-five like this:

var net = require('net');

var firmata = require('firmata');
var five = require("johnny-five");


var options = {   
  host: '172.22.111.111',  // IP of ESP board
  port: 3030  
};



var client = net.connect(options, function() {

  var socketClient = this;

  var io = new firmata.Board(socketClient);
  io.once('ready', function(){
      console.log('IO Ready');
      io.isReady = true;

      var board = new five.Board({io: io, repl: true});

      board.on('ready', function(){
          console.log('five ready');
          //Full Johnny-Five support here:

          var led = new five.Led(2);
          led.blink();
      });
  });

});


@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous
Member

soundanalogous commented Mar 6, 2016

@mwittig

This comment has been minimized.

Show comment
Hide comment
@mwittig

mwittig Mar 7, 2016

That's awesome! Thank you very much! I have managed to successfully install the firmata sketch on "WeMos D1 mini" and to run blink LED client application. I have used the following client code which is using the "etherport-client" package I had written a couple of weeks ago to do some experiments with remote boards.

var five = require("johnny-five");
var firmata = require("firmata");
var EtherPortClient = require('etherport-client').EtherPortClient;
var io = new firmata.Board(new EtherPortClient({
    host: '192.168.178.80',
    port: 3030
}));

io.once('ready', function(){
    console.log('IO Ready');
    io.isReady = true;

    var board = new five.Board({io: io, repl: true});

    board.on('ready', function(){
        console.log('five ready');

        var led = new five.Led(2);
        led.blink();
    });
});

I have also tried to use the J5 board directly by passing the EtherPortClient as part of the J5 board configuration (using 'port' property), but this did not work as expected: First, the program ran into a board timeout and shortly after it turned to "ready" (and the LED started blinking). May be this is because the "isReady" flag is missing somehow in this case.

mwittig commented Mar 7, 2016

That's awesome! Thank you very much! I have managed to successfully install the firmata sketch on "WeMos D1 mini" and to run blink LED client application. I have used the following client code which is using the "etherport-client" package I had written a couple of weeks ago to do some experiments with remote boards.

var five = require("johnny-five");
var firmata = require("firmata");
var EtherPortClient = require('etherport-client').EtherPortClient;
var io = new firmata.Board(new EtherPortClient({
    host: '192.168.178.80',
    port: 3030
}));

io.once('ready', function(){
    console.log('IO Ready');
    io.isReady = true;

    var board = new five.Board({io: io, repl: true});

    board.on('ready', function(){
        console.log('five ready');

        var led = new five.Led(2);
        led.blink();
    });
});

I have also tried to use the J5 board directly by passing the EtherPortClient as part of the J5 board configuration (using 'port' property), but this did not work as expected: First, the program ran into a board timeout and shortly after it turned to "ready" (and the LED started blinking). May be this is because the "isReady" flag is missing somehow in this case.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Mar 7, 2016

Member

J5 needs a much longer timeout when using non Serial transports.

Member

soundanalogous commented Mar 7, 2016

J5 needs a much longer timeout when using non Serial transports.

@mwittig

This comment has been minimized.

Show comment
Hide comment
@mwittig

mwittig Mar 7, 2016

Yes, possibly. This is why a created a fork of J5 which allows for passing in a timeout value as part of the board configuration. May be it makes sense to submit a PR (need to add documentation)?

mwittig/johnny-five@d4ced98

EDIT: The following works with my fork and a timeout of 10 seconds:

var five = require("johnny-five");
var EtherPortClient = require('etherport-client').EtherPortClient;

var board = new five.Board({
    port: new EtherPortClient({
            host: '192.168.178.80', // IP address of the ESP
            port: 3030
        }),
    timeout: 1e5,
    repl: true});

board.on('ready', function(){
    console.log('five ready');

    var led = new five.Led(2);
    led.blink();
});

mwittig commented Mar 7, 2016

Yes, possibly. This is why a created a fork of J5 which allows for passing in a timeout value as part of the board configuration. May be it makes sense to submit a PR (need to add documentation)?

mwittig/johnny-five@d4ced98

EDIT: The following works with my fork and a timeout of 10 seconds:

var five = require("johnny-five");
var EtherPortClient = require('etherport-client').EtherPortClient;

var board = new five.Board({
    port: new EtherPortClient({
            host: '192.168.178.80', // IP address of the ESP
            port: 3030
        }),
    timeout: 1e5,
    repl: true});

board.on('ready', function(){
    console.log('five ready');

    var led = new five.Led(2);
    led.blink();
});
@monteslu

This comment has been minimized.

Show comment
Hide comment
@monteslu

monteslu Mar 7, 2016

+1 on that timeout option. You should PR that.

monteslu commented Mar 7, 2016

+1 on that timeout option. You should PR that.

@samjulien

This comment has been minimized.

Show comment
Hide comment
@samjulien

samjulien Mar 16, 2016

I'm going to test this out with my Huzzah Feather tonight or tomorrow - is it still necessary to use the ESP working branch of firmata? Happy to provide feedback/help out if I'm able if it's useful (total n00b to this whole world so bear with me!).

samjulien commented Mar 16, 2016

I'm going to test this out with my Huzzah Feather tonight or tomorrow - is it still necessary to use the ESP working branch of firmata? Happy to provide feedback/help out if I'm able if it's useful (total n00b to this whole world so bear with me!).

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Mar 16, 2016

Member

yes you must still use the esp branch

Member

soundanalogous commented Mar 16, 2016

yes you must still use the esp branch

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Apr 11, 2016

Member

Initial ESP8266 support has been merged into master. So far it only enables use of ESP8266 as a Wi-Fi server. Here's a simple firmata.js client example with additional instructions). Ability for ESP8266 to function as a Wi-Fi Client coming soon (@jnsbyr is working on it).

Tested with Adafruit HUZZAH ESP8266 Feather. Please test with other ESP boards (simply flash StandardFirmataWiFi and see wifiConfig.h for details). Make sure you have the latest Firmata master.

Member

soundanalogous commented Apr 11, 2016

Initial ESP8266 support has been merged into master. So far it only enables use of ESP8266 as a Wi-Fi server. Here's a simple firmata.js client example with additional instructions). Ability for ESP8266 to function as a Wi-Fi Client coming soon (@jnsbyr is working on it).

Tested with Adafruit HUZZAH ESP8266 Feather. Please test with other ESP boards (simply flash StandardFirmataWiFi and see wifiConfig.h for details). Make sure you have the latest Firmata master.

@rahul-thakoor

This comment has been minimized.

Show comment
Hide comment
@rahul-thakoor

rahul-thakoor Apr 11, 2016

The standard Firmata doesnt work well on Esp8266 Node MCU 0.9(ESP-12). It crashes after uploading the sketch, and simple blink sketch on johnny-five cannot connect even via usb ftdi. any clues?

rahul-thakoor commented Apr 11, 2016

The standard Firmata doesnt work well on Esp8266 Node MCU 0.9(ESP-12). It crashes after uploading the sketch, and simple blink sketch on johnny-five cannot connect even via usb ftdi. any clues?

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Apr 11, 2016

Member

You need to install StandardFirmataWiFi on the ESP8266. Make sure you have the latest version of the ESP8266 core: https://github.com/esp8266/Arduino. You need at least v2.1.0.

Member

soundanalogous commented Apr 11, 2016

You need to install StandardFirmataWiFi on the ESP8266. Make sure you have the latest version of the ESP8266 core: https://github.com/esp8266/Arduino. You need at least v2.1.0.

@jnsbyr

This comment has been minimized.

Show comment
Hide comment
@jnsbyr

jnsbyr Apr 11, 2016

Contributor

@rahul2704
If you want to use the analog input you need to install the current github version. V2.1.0 has some iissues that will be fixed with the pending V2.2.0 release.

Contributor

jnsbyr commented Apr 11, 2016

@rahul2704
If you want to use the analog input you need to install the current github version. V2.1.0 has some iissues that will be fixed with the pending V2.2.0 release.

@henricavalcante

This comment has been minimized.

Show comment
Hide comment
@henricavalcante

henricavalcante Apr 12, 2016

I had some troubles to compile StandardFirmataWiFi on lines:

  if (Firmata.getPinMode(pin) == PIN_MODE_I2C && isI2CEnabled && mode != PIN_MODE_I2C) {
    // disable i2c so pins can be used for other functions
    // the following if statements should reconfigure the pins properly
    disableI2CPins(); // <<
  }
  if (IS_PIN_ANALOG(pin)) {
    reportAnalogCallback(PIN_TO_ANALOG(pin), mode == PIN_MODE_ANALOG ? 1 : 0); // turn on/off reporting  // <<
  }
      if (!isI2CEnabled) {
        enableI2CPins();  // <<
      }

After comment those lines of code I got another problem:

Sketch uses 236,343 bytes (54%) of program storage space. Maximum is 434,160 bytes.
Global variables use 33,184 bytes (40%) of dynamic memory, leaving 48,736 bytes for local variables. Maximum is 81,920 bytes.
Uploading 240496 bytes from to flash at 0x00000000
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed

I'm using ESP8266-01

henricavalcante commented Apr 12, 2016

I had some troubles to compile StandardFirmataWiFi on lines:

  if (Firmata.getPinMode(pin) == PIN_MODE_I2C && isI2CEnabled && mode != PIN_MODE_I2C) {
    // disable i2c so pins can be used for other functions
    // the following if statements should reconfigure the pins properly
    disableI2CPins(); // <<
  }
  if (IS_PIN_ANALOG(pin)) {
    reportAnalogCallback(PIN_TO_ANALOG(pin), mode == PIN_MODE_ANALOG ? 1 : 0); // turn on/off reporting  // <<
  }
      if (!isI2CEnabled) {
        enableI2CPins();  // <<
      }

After comment those lines of code I got another problem:

Sketch uses 236,343 bytes (54%) of program storage space. Maximum is 434,160 bytes.
Global variables use 33,184 bytes (40%) of dynamic memory, leaving 48,736 bytes for local variables. Maximum is 81,920 bytes.
Uploading 240496 bytes from to flash at 0x00000000
error: failed reading byte
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed

I'm using ESP8266-01

@henricavalcante

This comment has been minimized.

Show comment
Hide comment
@henricavalcante

henricavalcante Apr 12, 2016

After use an external power source to ESP I got this error:

Sketch uses 236,343 bytes (54%) of program storage space. Maximum is 434,160 bytes.
Global variables use 33,184 bytes (40%) of dynamic memory, leaving 48,736 bytes for local variables. Maximum is 81,920 bytes.
warning: espcomm_send_command: wrong direction/command: 0x01 0x00, expected 0x01 0x08
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

henricavalcante commented Apr 12, 2016

After use an external power source to ESP I got this error:

Sketch uses 236,343 bytes (54%) of program storage space. Maximum is 434,160 bytes.
Global variables use 33,184 bytes (40%) of dynamic memory, leaving 48,736 bytes for local variables. Maximum is 81,920 bytes.
warning: espcomm_send_command: wrong direction/command: 0x01 0x00, expected 0x01 0x08
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Apr 12, 2016

Member

I can compile StandardFirmataWiFi on each of the ESP8266 modules supported by the ESP8266 Arduino core v2.1.0 except ThaiEasyElec's ESPino without issue using Arduino v1.6.8 on Mac OS X. The only physical board I have to test with is the Adafruit HUZZAH ESP8266 Feather.

For people having issues, please make sure you are running at least v2.1.0 of the ESP8266 Arduino core and that you're using Arduino 1.6.8 or newer (if you use the nightly build). If you are and are still having issues, specify which board you are using, what it's name is in the Arduino Boards dropdown and a link to the any info about that particular board. Also include any error messages you are seeing while compiling and/or attempting to upload the sketch.

Member

soundanalogous commented Apr 12, 2016

I can compile StandardFirmataWiFi on each of the ESP8266 modules supported by the ESP8266 Arduino core v2.1.0 except ThaiEasyElec's ESPino without issue using Arduino v1.6.8 on Mac OS X. The only physical board I have to test with is the Adafruit HUZZAH ESP8266 Feather.

For people having issues, please make sure you are running at least v2.1.0 of the ESP8266 Arduino core and that you're using Arduino 1.6.8 or newer (if you use the nightly build). If you are and are still having issues, specify which board you are using, what it's name is in the Arduino Boards dropdown and a link to the any info about that particular board. Also include any error messages you are seeing while compiling and/or attempting to upload the sketch.

@henricavalcante

This comment has been minimized.

Show comment
Hide comment
@henricavalcante

henricavalcante Apr 12, 2016

Finally I could flash the esp8266-01 with StandardFirmataWiFi. After update everything I could compile, but I had some troubles with my Serial USB adapter on MAC, fortunately It works fine on Ubuntu.

I'm trying to connect to esp with johnny-five without success:

var five = require("johnny-five");
var EtherPortClient = require('etherport-client').EtherPortClient;

var board = new five.Board({
    port: new EtherPortClient({
            host: '192.168.4.1',
            port: 3030
        }),
    timeout: 1e5,
    repl: true});

board.on('ready', function(){
    console.log('five ready');
});
1460434123414 SerialPort Connecting to host:port: 192.168.4.1:3030
1460434123418 Connected Connecting to host:port: 192.168.4.1:3030
1460434223422 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:146
      throw err;
      ^

Error: Uncaught, unspecified "error" event. ([object Object])
    at Board.emit (events.js:144:17)
    at Board.log (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:630:8)
    at Board.(anonymous function) [as error] (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:641:14)
    at Board.<anonymous> (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:418:14)
    at Timer.listOnTimeout (timers.js:92:15)

henricavalcante commented Apr 12, 2016

Finally I could flash the esp8266-01 with StandardFirmataWiFi. After update everything I could compile, but I had some troubles with my Serial USB adapter on MAC, fortunately It works fine on Ubuntu.

I'm trying to connect to esp with johnny-five without success:

var five = require("johnny-five");
var EtherPortClient = require('etherport-client').EtherPortClient;

var board = new five.Board({
    port: new EtherPortClient({
            host: '192.168.4.1',
            port: 3030
        }),
    timeout: 1e5,
    repl: true});

board.on('ready', function(){
    console.log('five ready');
});
1460434123414 SerialPort Connecting to host:port: 192.168.4.1:3030
1460434123418 Connected Connecting to host:port: 192.168.4.1:3030
1460434223422 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:146
      throw err;
      ^

Error: Uncaught, unspecified "error" event. ([object Object])
    at Board.emit (events.js:144:17)
    at Board.log (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:630:8)
    at Board.(anonymous function) [as error] (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:641:14)
    at Board.<anonymous> (/Users/henricavalcante/git/henricavalcante/robotjs/node_modules/johnny-five/lib/board.js:418:14)
    at Timer.listOnTimeout (timers.js:92:15)
@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Apr 12, 2016

Member

this works for me:

var EtherPortClient = require("etherport-client").EtherPortClient;
var five = require('johnny-five');

var board = new five.Board({
  port: new EtherPortClient({
    host: "10.0.0.17",
    port: 3030
  }),
  timeout: 1e5,
  repl: false
});

board.on("ready", function() {
  console.log("READY!");
  var led = new five.Led(0);
  led.blink(500);
});

And blinks the red LED on the HUZZAH. However, strangely specifying pin 2 instead of 0 does not blink the blue LED, while using pin 2 with Firmata.js rather than johnny-five works without issue.

Make sure if you have SERIAL_DEBUG enabled (it's disabled by default - line 85) in StandardFirmataWiFi that you are connected to a console or the sketch won't get past while(!Serial) {;} in firmataDebug.h. That could be a reason for the timeout you are experiencing. Otherwise make sure the IP you are connecting to is correct. You will know by logging the serial output.

Member

soundanalogous commented Apr 12, 2016

this works for me:

var EtherPortClient = require("etherport-client").EtherPortClient;
var five = require('johnny-five');

var board = new five.Board({
  port: new EtherPortClient({
    host: "10.0.0.17",
    port: 3030
  }),
  timeout: 1e5,
  repl: false
});

board.on("ready", function() {
  console.log("READY!");
  var led = new five.Led(0);
  led.blink(500);
});

And blinks the red LED on the HUZZAH. However, strangely specifying pin 2 instead of 0 does not blink the blue LED, while using pin 2 with Firmata.js rather than johnny-five works without issue.

Make sure if you have SERIAL_DEBUG enabled (it's disabled by default - line 85) in StandardFirmataWiFi that you are connected to a console or the sketch won't get past while(!Serial) {;} in firmataDebug.h. That could be a reason for the timeout you are experiencing. Otherwise make sure the IP you are connecting to is correct. You will know by logging the serial output.

@henricavalcante

This comment has been minimized.

Show comment
Hide comment
@henricavalcante

henricavalcante Apr 12, 2016

You guys from Firmata are doing a great job, so I never had to use SERIAL_DEBUG hahaha :D

Before use the debug I was trying to use ESP as access point which doesn't work, after use the serial debug I could see that my ESP was trying to connect to an SSID and after configure wifiConfig.h correctly I could connect to ESP with J5. Thanks @soundanalogous

henricavalcante commented Apr 12, 2016

You guys from Firmata are doing a great job, so I never had to use SERIAL_DEBUG hahaha :D

Before use the debug I was trying to use ESP as access point which doesn't work, after use the serial debug I could see that my ESP was trying to connect to an SSID and after configure wifiConfig.h correctly I could connect to ESP with J5. Thanks @soundanalogous

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Apr 14, 2016

Member

Successfully tested boards can be added to this wiki page: https://github.com/firmata/arduino/wiki/WiFi-compatible-boards-and-shields.

Member

soundanalogous commented Apr 14, 2016

Successfully tested boards can be added to this wiki page: https://github.com/firmata/arduino/wiki/WiFi-compatible-boards-and-shields.

@rahul-thakoor

This comment has been minimized.

Show comment
Hide comment
@rahul-thakoor

rahul-thakoor Apr 15, 2016

I just tested on Node MCU 0.9 running esp8266 core, it works fine. added to wiki

rahul-thakoor commented Apr 15, 2016

I just tested on Node MCU 0.9 running esp8266 core, it works fine. added to wiki

@rahul-thakoor

This comment has been minimized.

Show comment
Hide comment
@rahul-thakoor

rahul-thakoor Apr 16, 2016

Here is an instructable. Please let me know if I omitted anything.
http://www.instructables.com/id/ESP8266-Firmata-J5-NodeBot/

rahul-thakoor commented Apr 16, 2016

Here is an instructable. Please let me know if I omitted anything.
http://www.instructables.com/id/ESP8266-Firmata-J5-NodeBot/

@alfredoborrero

This comment has been minimized.

Show comment
Hide comment
@alfredoborrero

alfredoborrero Jun 25, 2016

Hi, I am traying to connect a ESP8266 D1 Mini and i am having timeout issues.
This is a chineese version:
http://www.aliexpress.com/item/Smart-Electronics-D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based/32628017688.html

I installed latest version of the Arduino Library (Firmata Version 2.5.3) https://github.com/firmata/arduino and i was able add the parameters to wifiConfig.h and finally I uploaded the firmware to my ESP8266 Board (StandardFirmataWiFi.ino).

I also uncommented the line #85, so I enabled the serial debugging. And I was able to see when the board connects to my house SSID and I get a decent signal strength (-66 dBm), I can actually specify the local static IP Address or let the routher assign a Dynamic IP address from the DHCP. So its actually connecting to my WiFi Network.

The problem that I have right now is that I have timeout error when I run the Javascript file in nodeJS. And I tried with 4 different boards already. Is there anything i can do to troubleshoot this?

`var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
var board = new five.Board({
port: new EtherPortClient({
host: "192.168.1.64",
port: 3030
}),
timeout: 1e5,
repl: false
});

board.on("ready", function() {
console.log("READY!");
var led = new five.Led(2);
led.blink(500);
});`

All I am trying to do is run the board as a Client and the server is a local host in my PC (192.168.1.64), I installed the NodeJS as well. Actually I run multiple Arduino's MEGA and Particle and I haven got any issues, for some reason I am having problems with the D1 Mini. I already read all the comments in this forum and I think I was able to troubleshoot everything but still is not working :-(

Any help would be appreciated.

Regards,

Alfredo Borrero

alfredoborrero commented Jun 25, 2016

Hi, I am traying to connect a ESP8266 D1 Mini and i am having timeout issues.
This is a chineese version:
http://www.aliexpress.com/item/Smart-Electronics-D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based/32628017688.html

I installed latest version of the Arduino Library (Firmata Version 2.5.3) https://github.com/firmata/arduino and i was able add the parameters to wifiConfig.h and finally I uploaded the firmware to my ESP8266 Board (StandardFirmataWiFi.ino).

I also uncommented the line #85, so I enabled the serial debugging. And I was able to see when the board connects to my house SSID and I get a decent signal strength (-66 dBm), I can actually specify the local static IP Address or let the routher assign a Dynamic IP address from the DHCP. So its actually connecting to my WiFi Network.

The problem that I have right now is that I have timeout error when I run the Javascript file in nodeJS. And I tried with 4 different boards already. Is there anything i can do to troubleshoot this?

`var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
var board = new five.Board({
port: new EtherPortClient({
host: "192.168.1.64",
port: 3030
}),
timeout: 1e5,
repl: false
});

board.on("ready", function() {
console.log("READY!");
var led = new five.Led(2);
led.blink(500);
});`

All I am trying to do is run the board as a Client and the server is a local host in my PC (192.168.1.64), I installed the NodeJS as well. Actually I run multiple Arduino's MEGA and Particle and I haven got any issues, for some reason I am having problems with the D1 Mini. I already read all the comments in this forum and I think I was able to troubleshoot everything but still is not working :-(

Any help would be appreciated.

Regards,

Alfredo Borrero

@bkrajendra

This comment has been minimized.

Show comment
Hide comment
@bkrajendra

bkrajendra Jun 29, 2016

My board (ESP-7) after flashing only show blue led ON.. also showing following on terminal

ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v00000000
~ld

Does not connect to AP.
I'm using StandardFirmataWiFi.ino
Also I'm using all latest libs (ESP8266 arduino 2.3.0-rc2 and firmata 2.5.3)
Any Ides.. what could be the cause.?

bkrajendra commented Jun 29, 2016

My board (ESP-7) after flashing only show blue led ON.. also showing following on terminal

ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v00000000
~ld

Does not connect to AP.
I'm using StandardFirmataWiFi.ino
Also I'm using all latest libs (ESP8266 arduino 2.3.0-rc2 and firmata 2.5.3)
Any Ides.. what could be the cause.?

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jun 29, 2016

Member

@bkrajendra try downgrading to ESP8266 arduino version 2.2.0. Perhaps version 2.3.0 introduced an incompatibility. I haven't had a chance to test it yet.

Member

soundanalogous commented Jun 29, 2016

@bkrajendra try downgrading to ESP8266 arduino version 2.2.0. Perhaps version 2.3.0 introduced an incompatibility. I haven't had a chance to test it yet.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 1, 2016

Member

@bkrajendra I just tested with StandardFirmataWiFi from Firmata v2.5.3 running on an Adafruit ESP8266 Huzzah (the only ESP8266 board I have) compiled with the Arduino ESP8266 v2.3.0 board package and had no issues with either the TCP client or TCP server configuration.

I suspect either you are missing a step in the wifiConfig.h file or the ESP-7 board is for some reason not compatible. Here is the list of ESP8266 boards that have proven to be compatible so far: https://github.com/firmata/arduino/wiki/WiFi-compatible-boards-and-shields.

Member

soundanalogous commented Jul 1, 2016

@bkrajendra I just tested with StandardFirmataWiFi from Firmata v2.5.3 running on an Adafruit ESP8266 Huzzah (the only ESP8266 board I have) compiled with the Arduino ESP8266 v2.3.0 board package and had no issues with either the TCP client or TCP server configuration.

I suspect either you are missing a step in the wifiConfig.h file or the ESP-7 board is for some reason not compatible. Here is the list of ESP8266 boards that have proven to be compatible so far: https://github.com/firmata/arduino/wiki/WiFi-compatible-boards-and-shields.

@bkrajendra

This comment has been minimized.

Show comment
Hide comment
@bkrajendra

bkrajendra Jul 13, 2016

Dear @soundanalogous I don't think the problem is with board. ESP8266 only differs in pinouts for each board. Do you think a physical pinout could be a problem in any way? A code should generally run . Also ESP-7, ESP-12, ESP-12E and Huzzah board are almost same. There is no difference in these board which may crash or prevent to run a sketch on them.
I've tried downgrading to 2.2.0 which does not worked either
Then tried uninstalling and cleaning everything from Arduino, ESP libraries , core and all
Done a fresh install of Arduino 1.6.10 + Fresh ESP 8266 Arduino from master + Fresh Fermata master repo.
I guess only changes required in Wificonfig is related to Line no 119 and 151 for ssid pass/key.
Which I have done .. (is anything other than this is required?)

After doing all this,
It compiles successfully with no error...
But when flashed my ESP blue (Data) Led glows continuously...
Nothing happens...

bkrajendra commented Jul 13, 2016

Dear @soundanalogous I don't think the problem is with board. ESP8266 only differs in pinouts for each board. Do you think a physical pinout could be a problem in any way? A code should generally run . Also ESP-7, ESP-12, ESP-12E and Huzzah board are almost same. There is no difference in these board which may crash or prevent to run a sketch on them.
I've tried downgrading to 2.2.0 which does not worked either
Then tried uninstalling and cleaning everything from Arduino, ESP libraries , core and all
Done a fresh install of Arduino 1.6.10 + Fresh ESP 8266 Arduino from master + Fresh Fermata master repo.
I guess only changes required in Wificonfig is related to Line no 119 and 151 for ssid pass/key.
Which I have done .. (is anything other than this is required?)

After doing all this,
It compiles successfully with no error...
But when flashed my ESP blue (Data) Led glows continuously...
Nothing happens...

@Strophe27

This comment has been minimized.

Show comment
Hide comment
@Strophe27

Strophe27 Jul 20, 2016

Hi,
NodeMCU 1.0 (ESP 12E) with 2.3.0 and all fresh firmata, with standardFirmataWifi, all configured, debug on, connected to the access point.
Problem : the 2 blue LEDs are ON continuously.
I send data from Max/Msp Maxuino with the mxj net.tcp.send object (instead of Serial), and I can see

TCP connection established
TCP connection disconnected

on each data sent. But nothing work : board's led (tried all pins nbr) nor servo.
Each time I try to set a pin mode in Maxuino, maxuino.js says :
js: *** WARNING ***: For pin 2 Firmata reports this as an invalid pinMode
It was just to inform you.
I'm waiting for a ethernet shield because my goal is to make my apps with maxuino to remote 4 units by rj45. Hope it will work...
thxs a lot guys, Firmata is... whaou... it have a long future...

Strophe27 commented Jul 20, 2016

Hi,
NodeMCU 1.0 (ESP 12E) with 2.3.0 and all fresh firmata, with standardFirmataWifi, all configured, debug on, connected to the access point.
Problem : the 2 blue LEDs are ON continuously.
I send data from Max/Msp Maxuino with the mxj net.tcp.send object (instead of Serial), and I can see

TCP connection established
TCP connection disconnected

on each data sent. But nothing work : board's led (tried all pins nbr) nor servo.
Each time I try to set a pin mode in Maxuino, maxuino.js says :
js: *** WARNING ***: For pin 2 Firmata reports this as an invalid pinMode
It was just to inform you.
I'm waiting for a ethernet shield because my goal is to make my apps with maxuino to remote 4 units by rj45. Hope it will work...
thxs a lot guys, Firmata is... whaou... it have a long future...

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 20, 2016

Member

@Strophe27 it's difficult for me to troubleshoot Maxuino issues and I haven't used Max/MSP in several years (don't even have a license anymore). The NodeMCU 1.0 board has been successfully tested so it's not likely an issue with Firmata you are having but rather with how Maxuino integrates with tcp. I recommend trying to get in contact with someone working with Maxuino.

Member

soundanalogous commented Jul 20, 2016

@Strophe27 it's difficult for me to troubleshoot Maxuino issues and I haven't used Max/MSP in several years (don't even have a license anymore). The NodeMCU 1.0 board has been successfully tested so it's not likely an issue with Firmata you are having but rather with how Maxuino integrates with tcp. I recommend trying to get in contact with someone working with Maxuino.

@Strophe27

This comment has been minimized.

Show comment
Hide comment
@Strophe27

Strophe27 Jul 20, 2016

Thx. So, the 2 blue leds full on is a normal state ? Another strange thing is the right baud settings to see debug in serial monitor is 9600. Is that correct?

Strophe27 commented Jul 20, 2016

Thx. So, the 2 blue leds full on is a normal state ? Another strange thing is the right baud settings to see debug in serial monitor is 9600. Is that correct?

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 20, 2016

Member

Correct, serial debug baud is 9600. The LEDs are probably on because Firmata sets all pins to output/LOW by default and I'm assuming those LEDs are wired so that LOW turns them on and HIGH turns them off.

Member

soundanalogous commented Jul 20, 2016

Correct, serial debug baud is 9600. The LEDs are probably on because Firmata sets all pins to output/LOW by default and I'm assuming those LEDs are wired so that LOW turns them on and HIGH turns them off.

@Strophe27

This comment has been minimized.

Show comment
Hide comment
@Strophe27

Strophe27 Jul 20, 2016

Ok. So I can see Firmata need to send back infos to maxuino.js
I'm a very bad code reader, I try hard, but I don't understand how standardFirmataWifi send back infos, and where is it sent...
If Firmata is in server mode, how can I tell to send infos to my Max computer ? If Firmata is in client mode, I can't receive stream from Max but I can specify the Max Ip computer.
Also I would like to debug the raw data stream input in firmata, but I can' find where to put a DEBUG_PRINTLN
Maybe it isn't the right place to discuss about that beacause talking about networking (wifi + ethernet) and a client so called Maxuino... feel free to point me somewhere else

Strophe27 commented Jul 20, 2016

Ok. So I can see Firmata need to send back infos to maxuino.js
I'm a very bad code reader, I try hard, but I don't understand how standardFirmataWifi send back infos, and where is it sent...
If Firmata is in server mode, how can I tell to send infos to my Max computer ? If Firmata is in client mode, I can't receive stream from Max but I can specify the Max Ip computer.
Also I would like to debug the raw data stream input in firmata, but I can' find where to put a DEBUG_PRINTLN
Maybe it isn't the right place to discuss about that beacause talking about networking (wifi + ethernet) and a client so called Maxuino... feel free to point me somewhere else

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 20, 2016

Member

@Strophe27 file an issue on the Maxuino github repo. It doesn't look like development has been active in a while, but Chris may respond: https://github.com/maxuino/maxuino.

Member

soundanalogous commented Jul 20, 2016

@Strophe27 file an issue on the Maxuino github repo. It doesn't look like development has been active in a while, but Chris may respond: https://github.com/maxuino/maxuino.

@Strophe27

This comment has been minimized.

Show comment
Hide comment
@Strophe27

Strophe27 Jul 21, 2016

@soundanalogous I wrote this issue 2 days ago. I really need this working for my job, so I will figure it out. I wait for Ethernet shield to dig deeper into.
I don't think Chris will do something (just an intuition, but I hope he will), so I want to contibute to Maxuino, to add Ethernet config. I know a large community of Max and Ableton Live users will be happy to have something like that.
Maybe, if I fail to reverse engineering your code I will ask you again about how StandardFirmataEthernet works, maybe on a new issue, and maybe same questions above.

Back to ESP8266 (and end): my latest test are very strange... I tried different Firmatas, tried with serial, wifi etc. always LEDs on, except when serial connection is initialised (from Max), LED are off.
The exe program test you provide do not recognize the board.
But I'm done with ESP, I don't need this working for the moment, it was just for tests, waiting for shield, back on 3D design.

Strophe27 commented Jul 21, 2016

@soundanalogous I wrote this issue 2 days ago. I really need this working for my job, so I will figure it out. I wait for Ethernet shield to dig deeper into.
I don't think Chris will do something (just an intuition, but I hope he will), so I want to contibute to Maxuino, to add Ethernet config. I know a large community of Max and Ableton Live users will be happy to have something like that.
Maybe, if I fail to reverse engineering your code I will ask you again about how StandardFirmataEthernet works, maybe on a new issue, and maybe same questions above.

Back to ESP8266 (and end): my latest test are very strange... I tried different Firmatas, tried with serial, wifi etc. always LEDs on, except when serial connection is initialised (from Max), LED are off.
The exe program test you provide do not recognize the board.
But I'm done with ESP, I don't need this working for the moment, it was just for tests, waiting for shield, back on 3D design.

@Strophe27

This comment has been minimized.

Show comment
Hide comment
@Strophe27

Strophe27 Jul 21, 2016

SOLVED !
Thanks to Sadam and his awesome Max object sadam.tcpClient which is a bi-directional TCP object. (Very hard to find, since his website is down... thx googlecache...)
You were right about the two LEDs status by default.
Some more test, whith Ethernet Shield also, and I will contribute to Maxuino, and share Sadam objects to save and keep sharing them.
Thank you @soundanalogous and sorry for the noise here.

Strophe27 commented Jul 21, 2016

SOLVED !
Thanks to Sadam and his awesome Max object sadam.tcpClient which is a bi-directional TCP object. (Very hard to find, since his website is down... thx googlecache...)
You were right about the two LEDs status by default.
Some more test, whith Ethernet Shield also, and I will contribute to Maxuino, and share Sadam objects to save and keep sharing them.
Thank you @soundanalogous and sorry for the noise here.

@mhanuel26

This comment has been minimized.

Show comment
Hide comment
@mhanuel26

mhanuel26 Oct 3, 2016

Hi bkrajendra,

I actually have same issue here as you but with ESP-12. See #303

Did you find a workaround? I actually brick my ESP-12 to the point that I have to remove it from PCB since bootloader was giving me problems even with already tested basic wifi example.

http://bbs.espressif.com/viewtopic.php?f=7&t=2809&p=10045#p10045

I am afraid to do some further tests on a fresh ESP-12.

I have tested with ESP-01 and it works! I suspect something with pinout, perhaps some I/O make some damage to Flash IC.

I was trying to figure out how would it look this code for esp-12, perhaps some Huzzah owner know if you need some change here

#elif defined(ESP8266)
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS
#define TOTAL_PINS A0 + NUM_ANALOG_INPUTS
#define PIN_SERIAL_RX 3
#define PIN_SERIAL_TX 1
#define IS_PIN_DIGITAL(p) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) < A0))
#define IS_PIN_ANALOG(p) ((p) >= A0 && (p) < A0 + NUM_ANALOG_INPUTS)
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS)
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL)
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define IS_PIN_INTERRUPT(p) (digitalPinToInterrupt(p) > NOT_AN_INTERRUPT)
#define IS_PIN_SERIAL(p) ((p) == PIN_SERIAL_RX || (p) == PIN_SERIAL_TX)
#define PIN_TO_DIGITAL(p) (p)
#define PIN_TO_ANALOG(p) ((p) - A0)
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p) (p)
#define DEFAULT_PWM_RESOLUTION 10

mhanuel26 commented Oct 3, 2016

Hi bkrajendra,

I actually have same issue here as you but with ESP-12. See #303

Did you find a workaround? I actually brick my ESP-12 to the point that I have to remove it from PCB since bootloader was giving me problems even with already tested basic wifi example.

http://bbs.espressif.com/viewtopic.php?f=7&t=2809&p=10045#p10045

I am afraid to do some further tests on a fresh ESP-12.

I have tested with ESP-01 and it works! I suspect something with pinout, perhaps some I/O make some damage to Flash IC.

I was trying to figure out how would it look this code for esp-12, perhaps some Huzzah owner know if you need some change here

#elif defined(ESP8266)
#define TOTAL_ANALOG_PINS NUM_ANALOG_INPUTS
#define TOTAL_PINS A0 + NUM_ANALOG_INPUTS
#define PIN_SERIAL_RX 3
#define PIN_SERIAL_TX 1
#define IS_PIN_DIGITAL(p) (((p) >= 0 && (p) <= 5) || ((p) >= 12 && (p) < A0))
#define IS_PIN_ANALOG(p) ((p) >= A0 && (p) < A0 + NUM_ANALOG_INPUTS)
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) < MAX_SERVOS)
#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL)
#define IS_PIN_SPI(p) ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
#define IS_PIN_INTERRUPT(p) (digitalPinToInterrupt(p) > NOT_AN_INTERRUPT)
#define IS_PIN_SERIAL(p) ((p) == PIN_SERIAL_RX || (p) == PIN_SERIAL_TX)
#define PIN_TO_DIGITAL(p) (p)
#define PIN_TO_ANALOG(p) ((p) - A0)
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p) (p)
#define DEFAULT_PWM_RESOLUTION 10

@bkrajendra

This comment has been minimized.

Show comment
Hide comment
@bkrajendra

bkrajendra Oct 4, 2016

@mhanuel26
Actually in my case it started working without doing any changes.
I generally use generic ESP-12 or ESP-7. currently I'm using ESP12-F which is very good with 4MB Flash
This might be started working as I generally keep my ESP8266 Arduino core up to date by frequently running git update.

Keep firmata up to date, keep ESP8266 Arduino core to latest staging build,
Just configure Firmata Wifi config file with your ssid and password.
Flash it to ESP and everything should work properly.
LED glows continuously is Ok and its not a problem.

Mostly ESP does not brick as you are saying. Mostly it happens due to corruption in ur flash memory.

I found a good solution in such scenarios:
Download OLD ESP flasher (it flashes AT command binaries into entire flash and mostly clears remaining flash).

NodeMCU flasher might also work ok (Download it here)

My problems with bricked esps mostly get resolved with this trick.
I hope this helps you!

bkrajendra commented Oct 4, 2016

@mhanuel26
Actually in my case it started working without doing any changes.
I generally use generic ESP-12 or ESP-7. currently I'm using ESP12-F which is very good with 4MB Flash
This might be started working as I generally keep my ESP8266 Arduino core up to date by frequently running git update.

Keep firmata up to date, keep ESP8266 Arduino core to latest staging build,
Just configure Firmata Wifi config file with your ssid and password.
Flash it to ESP and everything should work properly.
LED glows continuously is Ok and its not a problem.

Mostly ESP does not brick as you are saying. Mostly it happens due to corruption in ur flash memory.

I found a good solution in such scenarios:
Download OLD ESP flasher (it flashes AT command binaries into entire flash and mostly clears remaining flash).

NodeMCU flasher might also work ok (Download it here)

My problems with bricked esps mostly get resolved with this trick.
I hope this helps you!

@techniq

This comment has been minimized.

Show comment
Hide comment
@techniq

techniq Oct 20, 2016

Took me a while to figure out how to turn off the onboard LEDs on my NodeMCU 12-E. Turns out I was missing 2 important things regarding this board:

  • The logic is backwards: HIGH/1 turns the lights off, LOW/0 turns the lights on
  • The blue LED on the ESP 12-E is available on pin 2, and the red LED on the dev board is available on pin 16 (no pin 13 like I'm used to on my Teensy / traditional Arduino).
var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
var board = new five.Board({
  port: new EtherPortClient({
    host: "192.168.1.120",
    port: 3030
  })
});

board.on("ready", function() {
  console.log('turning off LEDs');
  this.digitalWrite(2, 1);  // Blue LED
  this.digitalWrite(16, 1); // Red LED
});

techniq commented Oct 20, 2016

Took me a while to figure out how to turn off the onboard LEDs on my NodeMCU 12-E. Turns out I was missing 2 important things regarding this board:

  • The logic is backwards: HIGH/1 turns the lights off, LOW/0 turns the lights on
  • The blue LED on the ESP 12-E is available on pin 2, and the red LED on the dev board is available on pin 16 (no pin 13 like I'm used to on my Teensy / traditional Arduino).
var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
var board = new five.Board({
  port: new EtherPortClient({
    host: "192.168.1.120",
    port: 3030
  })
});

board.on("ready", function() {
  console.log('turning off LEDs');
  this.digitalWrite(2, 1);  // Blue LED
  this.digitalWrite(16, 1); // Red LED
});
@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Mar 19, 2017

Member

Closing this since the primary task of adding ESP8266 support has been done for quite some time. Users experiencing issues with particular ESP8266 boards should open a new issue for the particular board.

Member

soundanalogous commented Mar 19, 2017

Closing this since the primary task of adding ESP8266 support has been done for quite some time. Users experiencing issues with particular ESP8266 boards should open a new issue for the particular board.

@andriyadi

This comment has been minimized.

Show comment
Hide comment
@andriyadi

andriyadi Jul 2, 2017

Added ESPectro Core as supported ESP8266 board. I've tried: write/read GPIO, access I2C peripherals, Serial communication, all working well so far.

Thanks for providing Firmata support for ESP8266 boards. Awesome work!

andriyadi commented Jul 2, 2017

Added ESPectro Core as supported ESP8266 board. I've tried: write/read GPIO, access I2C peripherals, Serial communication, all working well so far.

Thanks for providing Firmata support for ESP8266 boards. Awesome work!

@Scolioza

This comment has been minimized.

Show comment
Hide comment
@Scolioza

Scolioza Jul 8, 2017

Good day everybody. I want to use NodeMcu V1.0 with nodeJs via johnny-five library. I am developing an IOT application and I want to get rid of wires so wifi seems to be a good solution. Since I have a lot of sensors to read (digital, one wire etc) I wanted to give a try to custom firmata
I managed to upload firmata to nodemcu but nothing happened. Here are the codes that I used:

for firmata:

`/*
 * firmataESP_srv_v5.ino generated by FirmataBuilder
 * Fri Jul 07 2017 16:51:13 GMT-0400 (EDT)
 */

#include <ConfigurableFirmata.h>

// uncomment to enable debugging over Serial (9600 baud)
#define SERIAL_DEBUG
#include "utility/firmataDebug.h"

#include <ESP8266WiFi.h>
#include "utility/WiFiClientStream.h"
#include "utility/WiFiServerStream.h"

#define WIFI_MAX_CONN_ATTEMPTS 20

#if defined(ESP8266) && defined(SERIAL_DEBUG)
#define IS_IGNORE_PIN(p)  ((p) == 1)
#endif

// IP address of remote server
#define REMOTE_SERVER_IP 192, 168, 0, 220

#define NETWORK_PORT 30301

char ssid[] = "######";
char wpa_passphrase[] = "######";

// comment out local_ip, subnet and gateway to use DHCP
IPAddress local_ip(192, 168, 0, 221);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(192, 168, 0, 1);

WiFiClientStream stream(IPAddress(REMOTE_SERVER_IP), NETWORK_PORT);

int connectionAttempts = 0;
bool streamConnected = false;

#include <DigitalInputFirmata.h>
DigitalInputFirmata digitalInput;

#include <DigitalOutputFirmata.h>
DigitalOutputFirmata digitalOutput;

#include <AnalogInputFirmata.h>
AnalogInputFirmata analogInput;

#include <Wire.h>
#include <I2CFirmata.h>
I2CFirmata i2c;

#include <OneWireFirmata.h>
OneWireFirmata oneWire;

#include <StepperFirmata.h>
StepperFirmata stepper;

#include <FirmataExt.h>
FirmataExt firmataExt;

#include <FirmataReporting.h>
FirmataReporting reporting;

void systemResetCallback()
{
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_PIN_ANALOG(i)) {
      Firmata.setPinMode(i, ANALOG);
    } else if (IS_PIN_DIGITAL(i)) {
      Firmata.setPinMode(i, OUTPUT);
    }
  }
  firmataExt.reset();
}

void hostConnectionCallback(byte state)
{
  switch (state) {
    case HOST_CONNECTION_CONNECTED:
      DEBUG_PRINTLN("TCP connection established");
      break;
    case HOST_CONNECTION_DISCONNECTED:
      DEBUG_PRINTLN("TCP connection disconnected");
      break;
  }
}

void printWiFiStatus()
{
  if (WiFi.status() != WL_CONNECTED) {
    DEBUG_PRINT("WiFi connection failed. Status value: ");
    DEBUG_PRINTLN(WiFi.status());
  } else {
    DEBUG_PRINTLN("Board configured as a TCP client");
    DEBUG_PRINT("Remote TCP server address: ");
    DEBUG_PRINTLN("192, 168, 0, 220");

    DEBUG_PRINT("SSID: ");
    DEBUG_PRINTLN(WiFi.SSID());

    DEBUG_PRINT("Local IP Address: ");
    IPAddress ip = WiFi.localIP();
    DEBUG_PRINTLN(ip);

    DEBUG_PRINT("Signal strength (RSSI): ");
    long rssi = WiFi.RSSI();
    DEBUG_PRINT(rssi);
    DEBUG_PRINTLN(" dBm");
  }
}

void ignorePins()
{
#ifdef IS_IGNORE_PIN
  // ignore pins used for WiFi controller or Firmata will overwrite their modes
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_IGNORE_PIN(i)) {
      Firmata.setPinMode(i, PIN_MODE_IGNORE);
    }
  }
#endif
}

void initTransport()
{
  // IMPORTANT: if SERIAL_DEBUG is enabled, program execution will stop
  // at DEBUG_BEGIN until a Serial conneciton is established
  DEBUG_BEGIN(9600);
  DEBUG_PRINTLN("Attempting a WiFi connection using the ESP8266 WiFi library.");

  DEBUG_PRINT("Using static IP: ");
  DEBUG_PRINTLN(local_ip);
  stream.config(local_ip, gateway, subnet);

  stream.attach(hostConnectionCallback);

  DEBUG_PRINT("Attempting to connect to WPA SSID: ");
  DEBUG_PRINTLN(ssid);
  stream.begin(ssid, wpa_passphrase);

  DEBUG_PRINTLN("WiFi setup done.");

  while(WiFi.status() != WL_CONNECTED && ++connectionAttempts <= WIFI_MAX_CONN_ATTEMPTS) {
    delay(500);
    DEBUG_PRINT(".");
  }

  printWiFiStatus();

  ignorePins();

  Firmata.begin(stream);
}

void initFirmata()
{
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);

  firmataExt.addFeature(digitalInput);
  firmataExt.addFeature(digitalOutput);
  firmataExt.addFeature(analogInput);
  firmataExt.addFeature(i2c);
  firmataExt.addFeature(oneWire);
  firmataExt.addFeature(stepper);
  firmataExt.addFeature(reporting);

  Firmata.attach(SYSTEM_RESET, systemResetCallback);
}

void setup()
{
  initFirmata();
  initTransport();
  
  systemResetCallback();
}

void loop()
{
  digitalInput.report();

  while(Firmata.available()) {
    Firmata.processInput();

    
  }

  if (reporting.elapsed()) {
    analogInput.report();
    i2c.report();
  }

  stepper.update();

  stream.maintain();
}`

for node

`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: 30301
  }),
  timeout: 1e5,
  repl: false
});

board.on("ready", function() {
  console.log("READY!");
  /*var led = new five.Led(13);
  led.blink(500);*/
});`

All i get is the following message:
`

`1499495457108 SerialPort Connecting to host:port: 192.168.0.221:30301
1499495457112 Connected Connecting to host:port: 192.168.0.221:30301
1499495557114 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 (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:635:8)
    at Board.(anonymous function) [as error] (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:646:14)
    at Board.<anonymous> (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:390:14)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)`

I used custom firmata with succes with arduino.

Thank you in advance.

Scolioza commented Jul 8, 2017

Good day everybody. I want to use NodeMcu V1.0 with nodeJs via johnny-five library. I am developing an IOT application and I want to get rid of wires so wifi seems to be a good solution. Since I have a lot of sensors to read (digital, one wire etc) I wanted to give a try to custom firmata
I managed to upload firmata to nodemcu but nothing happened. Here are the codes that I used:

for firmata:

`/*
 * firmataESP_srv_v5.ino generated by FirmataBuilder
 * Fri Jul 07 2017 16:51:13 GMT-0400 (EDT)
 */

#include <ConfigurableFirmata.h>

// uncomment to enable debugging over Serial (9600 baud)
#define SERIAL_DEBUG
#include "utility/firmataDebug.h"

#include <ESP8266WiFi.h>
#include "utility/WiFiClientStream.h"
#include "utility/WiFiServerStream.h"

#define WIFI_MAX_CONN_ATTEMPTS 20

#if defined(ESP8266) && defined(SERIAL_DEBUG)
#define IS_IGNORE_PIN(p)  ((p) == 1)
#endif

// IP address of remote server
#define REMOTE_SERVER_IP 192, 168, 0, 220

#define NETWORK_PORT 30301

char ssid[] = "######";
char wpa_passphrase[] = "######";

// comment out local_ip, subnet and gateway to use DHCP
IPAddress local_ip(192, 168, 0, 221);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(192, 168, 0, 1);

WiFiClientStream stream(IPAddress(REMOTE_SERVER_IP), NETWORK_PORT);

int connectionAttempts = 0;
bool streamConnected = false;

#include <DigitalInputFirmata.h>
DigitalInputFirmata digitalInput;

#include <DigitalOutputFirmata.h>
DigitalOutputFirmata digitalOutput;

#include <AnalogInputFirmata.h>
AnalogInputFirmata analogInput;

#include <Wire.h>
#include <I2CFirmata.h>
I2CFirmata i2c;

#include <OneWireFirmata.h>
OneWireFirmata oneWire;

#include <StepperFirmata.h>
StepperFirmata stepper;

#include <FirmataExt.h>
FirmataExt firmataExt;

#include <FirmataReporting.h>
FirmataReporting reporting;

void systemResetCallback()
{
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_PIN_ANALOG(i)) {
      Firmata.setPinMode(i, ANALOG);
    } else if (IS_PIN_DIGITAL(i)) {
      Firmata.setPinMode(i, OUTPUT);
    }
  }
  firmataExt.reset();
}

void hostConnectionCallback(byte state)
{
  switch (state) {
    case HOST_CONNECTION_CONNECTED:
      DEBUG_PRINTLN("TCP connection established");
      break;
    case HOST_CONNECTION_DISCONNECTED:
      DEBUG_PRINTLN("TCP connection disconnected");
      break;
  }
}

void printWiFiStatus()
{
  if (WiFi.status() != WL_CONNECTED) {
    DEBUG_PRINT("WiFi connection failed. Status value: ");
    DEBUG_PRINTLN(WiFi.status());
  } else {
    DEBUG_PRINTLN("Board configured as a TCP client");
    DEBUG_PRINT("Remote TCP server address: ");
    DEBUG_PRINTLN("192, 168, 0, 220");

    DEBUG_PRINT("SSID: ");
    DEBUG_PRINTLN(WiFi.SSID());

    DEBUG_PRINT("Local IP Address: ");
    IPAddress ip = WiFi.localIP();
    DEBUG_PRINTLN(ip);

    DEBUG_PRINT("Signal strength (RSSI): ");
    long rssi = WiFi.RSSI();
    DEBUG_PRINT(rssi);
    DEBUG_PRINTLN(" dBm");
  }
}

void ignorePins()
{
#ifdef IS_IGNORE_PIN
  // ignore pins used for WiFi controller or Firmata will overwrite their modes
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_IGNORE_PIN(i)) {
      Firmata.setPinMode(i, PIN_MODE_IGNORE);
    }
  }
#endif
}

void initTransport()
{
  // IMPORTANT: if SERIAL_DEBUG is enabled, program execution will stop
  // at DEBUG_BEGIN until a Serial conneciton is established
  DEBUG_BEGIN(9600);
  DEBUG_PRINTLN("Attempting a WiFi connection using the ESP8266 WiFi library.");

  DEBUG_PRINT("Using static IP: ");
  DEBUG_PRINTLN(local_ip);
  stream.config(local_ip, gateway, subnet);

  stream.attach(hostConnectionCallback);

  DEBUG_PRINT("Attempting to connect to WPA SSID: ");
  DEBUG_PRINTLN(ssid);
  stream.begin(ssid, wpa_passphrase);

  DEBUG_PRINTLN("WiFi setup done.");

  while(WiFi.status() != WL_CONNECTED && ++connectionAttempts <= WIFI_MAX_CONN_ATTEMPTS) {
    delay(500);
    DEBUG_PRINT(".");
  }

  printWiFiStatus();

  ignorePins();

  Firmata.begin(stream);
}

void initFirmata()
{
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);

  firmataExt.addFeature(digitalInput);
  firmataExt.addFeature(digitalOutput);
  firmataExt.addFeature(analogInput);
  firmataExt.addFeature(i2c);
  firmataExt.addFeature(oneWire);
  firmataExt.addFeature(stepper);
  firmataExt.addFeature(reporting);

  Firmata.attach(SYSTEM_RESET, systemResetCallback);
}

void setup()
{
  initFirmata();
  initTransport();
  
  systemResetCallback();
}

void loop()
{
  digitalInput.report();

  while(Firmata.available()) {
    Firmata.processInput();

    
  }

  if (reporting.elapsed()) {
    analogInput.report();
    i2c.report();
  }

  stepper.update();

  stream.maintain();
}`

for node

`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: 30301
  }),
  timeout: 1e5,
  repl: false
});

board.on("ready", function() {
  console.log("READY!");
  /*var led = new five.Led(13);
  led.blink(500);*/
});`

All i get is the following message:
`

`1499495457108 SerialPort Connecting to host:port: 192.168.0.221:30301
1499495457112 Connected Connecting to host:port: 192.168.0.221:30301
1499495557114 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 (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:635:8)
    at Board.(anonymous function) [as error] (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:646:14)
    at Board.<anonymous> (D:\nodeJs\nodeFirmata\node_modules\johnny-five\lib\board.js:390:14)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)`

I used custom firmata with succes with arduino.

Thank you in advance.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 8, 2017

Member

You have configured your Arduino sketch as a TCP client so you either need to use EtherPort instead of EtherPortClient, or comment out the following line in your sketch (in which case EtherPortClient should work):

// IP address of remote server
#define REMOTE_SERVER_IP 192, 168, 0, 220

I realize now I need to update the output from firmatabuilder to add a comment to more clearly explain that the above line is what is used to determine if the sketch is configured as a TCP client (uncommented) or TCP server (commented).

Also make sure you supply adequate current to the board. The 500mA or so a laptop typically supplies is sometimes not enough so you may also need to try a 1000mA USB power supply if the code changes alone don't resolve the issue.

Member

soundanalogous commented Jul 8, 2017

You have configured your Arduino sketch as a TCP client so you either need to use EtherPort instead of EtherPortClient, or comment out the following line in your sketch (in which case EtherPortClient should work):

// IP address of remote server
#define REMOTE_SERVER_IP 192, 168, 0, 220

I realize now I need to update the output from firmatabuilder to add a comment to more clearly explain that the above line is what is used to determine if the sketch is configured as a TCP client (uncommented) or TCP server (commented).

Also make sure you supply adequate current to the board. The 500mA or so a laptop typically supplies is sometimes not enough so you may also need to try a 1000mA USB power supply if the code changes alone don't resolve the issue.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 8, 2017

Member

Actually if you want your ESP board to be the TCP server, rebuild a new sketch from firmatabuilder.com and select TCP server (which is the default selection).

If you still have trouble, also try leaving the Local IP field blank in firmatabuilder to use DHCP.

Member

soundanalogous commented Jul 8, 2017

Actually if you want your ESP board to be the TCP server, rebuild a new sketch from firmatabuilder.com and select TCP server (which is the default selection).

If you still have trouble, also try leaving the Local IP field blank in firmatabuilder to use DHCP.

@Scolioza

This comment has been minimized.

Show comment
Hide comment
@Scolioza

Scolioza Jul 9, 2017

It worked.

That is the Arduino code:

/*
 * server_node_firmata_v_ok.ino generated by FirmataBuilder
 * Sat Jul 08 2017 05:59:52 GMT-0400 (EDT)
 */

#include <ConfigurableFirmata.h>

// uncomment to enable debugging over Serial (9600 baud)
#define SERIAL_DEBUG
#include "utility/firmataDebug.h"

#include <ESP8266WiFi.h>
#include "utility/WiFiClientStream.h"
#include "utility/WiFiServerStream.h"

#define WIFI_MAX_CONN_ATTEMPTS 20

#if defined(ESP8266) && defined(SERIAL_DEBUG)
#define IS_IGNORE_PIN(p)  ((p) == 1)
#endif

#define NETWORK_PORT 3030

char ssid[] = "#######";
char wpa_passphrase[] = "#######";

// comment out local_ip, subnet and gateway to use DHCP
IPAddress local_ip(192, 168, 0, 221);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(0, 0, 0, 0);

WiFiServerStream stream(NETWORK_PORT);

int connectionAttempts = 0;
bool streamConnected = false;

#include <DigitalInputFirmata.h>
DigitalInputFirmata digitalInput;

#include <DigitalOutputFirmata.h>
DigitalOutputFirmata digitalOutput;

#include <AnalogInputFirmata.h>
AnalogInputFirmata analogInput;

#include <Wire.h>
#include <I2CFirmata.h>
I2CFirmata i2c;

#include <OneWireFirmata.h>
OneWireFirmata oneWire;

#include <FirmataExt.h>
FirmataExt firmataExt;

#include <FirmataReporting.h>
FirmataReporting reporting;

void systemResetCallback()
{
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_PIN_ANALOG(i)) {
      Firmata.setPinMode(i, ANALOG);
    } else if (IS_PIN_DIGITAL(i)) {
      Firmata.setPinMode(i, OUTPUT);
    }
  }
  firmataExt.reset();
}

void hostConnectionCallback(byte state)
{
  switch (state) {
    case HOST_CONNECTION_CONNECTED:
      DEBUG_PRINTLN("TCP connection established");
      break;
    case HOST_CONNECTION_DISCONNECTED:
      DEBUG_PRINTLN("TCP connection disconnected");
      break;
  }
}

void printWiFiStatus()
{
  if (WiFi.status() != WL_CONNECTED) {
    DEBUG_PRINT("WiFi connection failed. Status value: ");
    DEBUG_PRINTLN(WiFi.status());
  } else {
    DEBUG_PRINTLN("Board configured as a TCP server");

    DEBUG_PRINT("SSID: ");
    DEBUG_PRINTLN(WiFi.SSID());

    DEBUG_PRINT("Local IP Address: ");
    IPAddress ip = WiFi.localIP();
    DEBUG_PRINTLN(ip);

    DEBUG_PRINT("Signal strength (RSSI): ");
    long rssi = WiFi.RSSI();
    DEBUG_PRINT(rssi);
    DEBUG_PRINTLN(" dBm");
  }
}

void ignorePins()
{
#ifdef IS_IGNORE_PIN
  // ignore pins used for WiFi controller or Firmata will overwrite their modes
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_IGNORE_PIN(i)) {
      Firmata.setPinMode(i, PIN_MODE_IGNORE);
    }
  }
#endif
}

void initTransport()
{
  // IMPORTANT: if SERIAL_DEBUG is enabled, program execution will stop
  // at DEBUG_BEGIN until a Serial conneciton is established
  DEBUG_BEGIN(9600);
  DEBUG_PRINTLN("Attempting a WiFi connection using the ESP8266 WiFi library.");

  DEBUG_PRINT("Using static IP: ");
  DEBUG_PRINTLN(local_ip);
  stream.config(local_ip, gateway, subnet);

  stream.attach(hostConnectionCallback);

  DEBUG_PRINT("Attempting to connect to WPA SSID: ");
  DEBUG_PRINTLN(ssid);
  stream.begin(ssid, wpa_passphrase);

  DEBUG_PRINTLN("WiFi setup done.");

  while(WiFi.status() != WL_CONNECTED && ++connectionAttempts <= WIFI_MAX_CONN_ATTEMPTS) {
    delay(500);
    DEBUG_PRINT(".");
  }

  printWiFiStatus();

  ignorePins();

  Firmata.begin(stream);
}

void initFirmata()
{
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);

  firmataExt.addFeature(digitalInput);
  firmataExt.addFeature(digitalOutput);
  firmataExt.addFeature(analogInput);
  firmataExt.addFeature(i2c);
  firmataExt.addFeature(oneWire);
  firmataExt.addFeature(reporting);

  Firmata.attach(SYSTEM_RESET, systemResetCallback);
}

void setup()
{
  initFirmata();

  initTransport();

  systemResetCallback();
}

void loop()
{
  digitalInput.report();

  while(Firmata.available()) {
    Firmata.processInput();
  }

  if (reporting.elapsed()) {
    analogInput.report();
    i2c.report();
  }

  stream.maintain();
}

But now I have an issue reading the DS18B20 sensor. the code that I used is:

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
});

board.on("ready", function() {
  console.log("READY!");
  /*var led = new five.Led(16);
  led.blink(2000);*/
  var thermometer = new five.Thermometer({
  controller: "DS18B20",
  pin: 2,
  //freq:1000
});

thermometer.on("change", function() {
  console.log(this.celsius + "°C");
  console.log("0x" + this.address.toString(16));
});

});

I was able to toggle leds but when I try to read temperature I got an error stack and boards resets. I was digging in previous posts and I saw that NodeMcu might be incompatible with oneWire firmata.

Is that correct?

Thank you for you for everything.

Scolioza commented Jul 9, 2017

It worked.

That is the Arduino code:

/*
 * server_node_firmata_v_ok.ino generated by FirmataBuilder
 * Sat Jul 08 2017 05:59:52 GMT-0400 (EDT)
 */

#include <ConfigurableFirmata.h>

// uncomment to enable debugging over Serial (9600 baud)
#define SERIAL_DEBUG
#include "utility/firmataDebug.h"

#include <ESP8266WiFi.h>
#include "utility/WiFiClientStream.h"
#include "utility/WiFiServerStream.h"

#define WIFI_MAX_CONN_ATTEMPTS 20

#if defined(ESP8266) && defined(SERIAL_DEBUG)
#define IS_IGNORE_PIN(p)  ((p) == 1)
#endif

#define NETWORK_PORT 3030

char ssid[] = "#######";
char wpa_passphrase[] = "#######";

// comment out local_ip, subnet and gateway to use DHCP
IPAddress local_ip(192, 168, 0, 221);
IPAddress subnet(255, 255, 255, 0);
IPAddress gateway(0, 0, 0, 0);

WiFiServerStream stream(NETWORK_PORT);

int connectionAttempts = 0;
bool streamConnected = false;

#include <DigitalInputFirmata.h>
DigitalInputFirmata digitalInput;

#include <DigitalOutputFirmata.h>
DigitalOutputFirmata digitalOutput;

#include <AnalogInputFirmata.h>
AnalogInputFirmata analogInput;

#include <Wire.h>
#include <I2CFirmata.h>
I2CFirmata i2c;

#include <OneWireFirmata.h>
OneWireFirmata oneWire;

#include <FirmataExt.h>
FirmataExt firmataExt;

#include <FirmataReporting.h>
FirmataReporting reporting;

void systemResetCallback()
{
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_PIN_ANALOG(i)) {
      Firmata.setPinMode(i, ANALOG);
    } else if (IS_PIN_DIGITAL(i)) {
      Firmata.setPinMode(i, OUTPUT);
    }
  }
  firmataExt.reset();
}

void hostConnectionCallback(byte state)
{
  switch (state) {
    case HOST_CONNECTION_CONNECTED:
      DEBUG_PRINTLN("TCP connection established");
      break;
    case HOST_CONNECTION_DISCONNECTED:
      DEBUG_PRINTLN("TCP connection disconnected");
      break;
  }
}

void printWiFiStatus()
{
  if (WiFi.status() != WL_CONNECTED) {
    DEBUG_PRINT("WiFi connection failed. Status value: ");
    DEBUG_PRINTLN(WiFi.status());
  } else {
    DEBUG_PRINTLN("Board configured as a TCP server");

    DEBUG_PRINT("SSID: ");
    DEBUG_PRINTLN(WiFi.SSID());

    DEBUG_PRINT("Local IP Address: ");
    IPAddress ip = WiFi.localIP();
    DEBUG_PRINTLN(ip);

    DEBUG_PRINT("Signal strength (RSSI): ");
    long rssi = WiFi.RSSI();
    DEBUG_PRINT(rssi);
    DEBUG_PRINTLN(" dBm");
  }
}

void ignorePins()
{
#ifdef IS_IGNORE_PIN
  // ignore pins used for WiFi controller or Firmata will overwrite their modes
  for (byte i = 0; i < TOTAL_PINS; i++) {
    if (IS_IGNORE_PIN(i)) {
      Firmata.setPinMode(i, PIN_MODE_IGNORE);
    }
  }
#endif
}

void initTransport()
{
  // IMPORTANT: if SERIAL_DEBUG is enabled, program execution will stop
  // at DEBUG_BEGIN until a Serial conneciton is established
  DEBUG_BEGIN(9600);
  DEBUG_PRINTLN("Attempting a WiFi connection using the ESP8266 WiFi library.");

  DEBUG_PRINT("Using static IP: ");
  DEBUG_PRINTLN(local_ip);
  stream.config(local_ip, gateway, subnet);

  stream.attach(hostConnectionCallback);

  DEBUG_PRINT("Attempting to connect to WPA SSID: ");
  DEBUG_PRINTLN(ssid);
  stream.begin(ssid, wpa_passphrase);

  DEBUG_PRINTLN("WiFi setup done.");

  while(WiFi.status() != WL_CONNECTED && ++connectionAttempts <= WIFI_MAX_CONN_ATTEMPTS) {
    delay(500);
    DEBUG_PRINT(".");
  }

  printWiFiStatus();

  ignorePins();

  Firmata.begin(stream);
}

void initFirmata()
{
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);

  firmataExt.addFeature(digitalInput);
  firmataExt.addFeature(digitalOutput);
  firmataExt.addFeature(analogInput);
  firmataExt.addFeature(i2c);
  firmataExt.addFeature(oneWire);
  firmataExt.addFeature(reporting);

  Firmata.attach(SYSTEM_RESET, systemResetCallback);
}

void setup()
{
  initFirmata();

  initTransport();

  systemResetCallback();
}

void loop()
{
  digitalInput.report();

  while(Firmata.available()) {
    Firmata.processInput();
  }

  if (reporting.elapsed()) {
    analogInput.report();
    i2c.report();
  }

  stream.maintain();
}

But now I have an issue reading the DS18B20 sensor. the code that I used is:

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
});

board.on("ready", function() {
  console.log("READY!");
  /*var led = new five.Led(16);
  led.blink(2000);*/
  var thermometer = new five.Thermometer({
  controller: "DS18B20",
  pin: 2,
  //freq:1000
});

thermometer.on("change", function() {
  console.log(this.celsius + "°C");
  console.log("0x" + this.address.toString(16));
});

});

I was able to toggle leds but when I try to read temperature I got an error stack and boards resets. I was digging in previous posts and I saw that NodeMcu might be incompatible with oneWire firmata.

Is that correct?

Thank you for you for everything.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 9, 2017

Member

The OneWire library is compatible with the ESP8266, but OneWire doesn't work well in Firmata and no one working on Firmata has extensive OneWire experience so until someone contributes a patch it will be unreliable.

Member

soundanalogous commented Jul 9, 2017

The OneWire library is compatible with the ESP8266, but OneWire doesn't work well in Firmata and no one working on Firmata has extensive OneWire experience so until someone contributes a patch it will be unreliable.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 9, 2017

Member

I suggest getting an I2C or an analog temperature sensor to use with Firmata.

Member

soundanalogous commented Jul 9, 2017

I suggest getting an I2C or an analog temperature sensor to use with Firmata.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jul 9, 2017

Member

I also don't know if the OneWire issue is in Firmata (Arduino firmware), firmata.js or in johnny-five.

Member

soundanalogous commented Jul 9, 2017

I also don't know if the OneWire issue is in Firmata (Arduino firmware), firmata.js or in johnny-five.

@testacode

This comment has been minimized.

Show comment
Hide comment
@testacode

testacode Jan 14, 2018

Is there a simple way to make firmata.js and johnny five work on a esp8266 over OSX? I'm a newbie and I'm going crazy over hundreds of tutorials for using it without luck. Do I need to burn firmata into the esp8266 or I just have to flash the normal esp8266 firmware to use it. I'm not getting that.

testacode commented Jan 14, 2018

Is there a simple way to make firmata.js and johnny five work on a esp8266 over OSX? I'm a newbie and I'm going crazy over hundreds of tutorials for using it without luck. Do I need to burn firmata into the esp8266 or I just have to flash the normal esp8266 firmware to use it. I'm not getting that.

@soundanalogous

This comment has been minimized.

Show comment
Hide comment
@soundanalogous

soundanalogous Jan 15, 2018

Member

Are you trying to connect via Serial (USB cable) or Wi-Fi? If you're trying to use Serial, you need to upload this version of StandardFirmata to the esp8266: https://gist.github.com/soundanalogous/87ea10c07c3f072cb46d8cad206b42d1

If you are trying to use Wi-Fi, then you need to configure StandardFirmataWiFi as either a client or a server and upload that to the esp8266, then setup your J5 script to be the opposite (server or client). Here are examples of client and server esp8266 J5 scripts.

Member

soundanalogous commented Jan 15, 2018

Are you trying to connect via Serial (USB cable) or Wi-Fi? If you're trying to use Serial, you need to upload this version of StandardFirmata to the esp8266: https://gist.github.com/soundanalogous/87ea10c07c3f072cb46d8cad206b42d1

If you are trying to use Wi-Fi, then you need to configure StandardFirmataWiFi as either a client or a server and upload that to the esp8266, then setup your J5 script to be the opposite (server or client). Here are examples of client and server esp8266 J5 scripts.

@rahul-thakoor

This comment has been minimized.

Show comment
Hide comment
@rahul-thakoor

rahul-thakoor commented Jan 15, 2018

Perhaps this can help for wifi version
http://www.instructables.com/id/ESP8266-Firmata-J5-NodeBot/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment