esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
15.98k stars 13.34k forks source link

Support the esp8266 in Firmata Boards.h #9

Closed probonopd closed 6 years ago

probonopd commented 9 years ago

Firmata errors with

libraries/Firmata/src/Boards.h:337:2: error: #error "Please edit Boards.h with a hardware abstraction for this board"
 #error "Please edit Boards.h with a hardware abstraction for this board"
  ^

Possibly https://github.com/esp8266/Arduino/blob/esp8266/libraries/Firmata/src/Boards.h could be changed to support the esp8266?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

scryb3 commented 9 years ago

This seems to be an important one, I'm researching adding a definition, but am starting at nothing, please feel free to help!

Edit: I'm running into the same issue trying to get https://github.com/octoblu/microblu_mqtt running on the ESP8266

scryb3 commented 9 years ago

I tried this hack around and it seems to have worked for now (IOW I'm getting other errors now):

(in sketch for now)

define ESP8266

(in boards.h before "// anything else")

// ESP8266

elif defined(ESP8266)

define TOTAL_ANALOG_PINS 15

define TOTAL_PINS 15 // 16 GPIO

define VERSION_BLINK_PIN 13

define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 15)

define IS_PIN_ANALOG(p) ((p) >= 0 && (p) <= 15)

define IS_PIN_PWM(p) digitalPinHasPWM(p)

define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS)

define IS_PIN_I2C(p) ((p) >= 0 && (p) <= 15)

define PIN_TO_DIGITAL(p) (p)

define PIN_TO_ANALOG(p) ((p) - 14)

define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)

define PIN_TO_SERVO(p) ((p) - 2)

scryb3 commented 9 years ago

I think that my cavalier copying of the text above, which did fix my compilation errors, is causing me other problems.

If someone more experienced can help me figure out the right config for this board I would appreciate it.

mralexgray commented 8 years ago

is there any update on this? support for firmata is really missed/would be great!

gmag11 commented 7 years ago

Hello, some time ago I was playing with Firmata and successfully used on it with Snap4Arduino.

The problem in definition is that Serial pins are defined as digital pins. They have to be excluded from definition. I used this one

// ESP8266
// note: boot mode GPIOs 0, 2 and 15 can be used as outputs, GPIOs 6-11 are in use for flash IO
#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
devyte commented 6 years ago

3rd party lib. The referenced file above is no longer hosted in this repo. Closing.