Giter Club home page Giter Club logo

Comments (3)

UncleRus avatar UncleRus commented on August 27, 2024

Latest ESP8266 RTOS SDK supports only one I2C port

components/esp8266/include/driver/i2c.h

typedef enum {
    I2C_NUM_0 = 0,  /*!< I2C port 0 */
    I2C_NUM_MAX
} i2c_port_t;

from esp-idf-lib.

UncleRus avatar UncleRus commented on August 27, 2024

I fixed the driver reinstallation error for esp8266 in the latest master. Please do a git update.

With this fix you can use your devices on single HW I2C port like this:

static i2c_dev_t bh1750;
static bmp180_dev_t bmp180;
...
void some_task(void *pvParameters)
{
    // Use I2C devices
   ....
}
...
void other_task(void *pvParameters)
{
    // Use I2C devices
   ....
}

void app_main()
{
    ....
    ESP_ERROR_CHECK(i2cdev_init()); // Init library

    memset(&bh1750, 0, sizeof(i2c_dev_t)); // Zero BH1750 descriptor
    memset(&bmp180, 0, sizeof(bmp180_dev_t)); // Zero BMP180 descriptor

    // Init descriptors
    ESP_ERROR_CHECK(bh1750_init_desc(&bh1750, BH1750_ADDR, 0, BH1750_SDA_GPIO, BH1750_SCL_GPIO));
    ESP_ERROR_CHECK(bmp180_init_desc(&bmp180, 0, BMP180_SDA_GPIO, BMP180_SCL_GPIO));
    ...
    // Init devices
    ESP_ERROR_CHECK(bmp180_init(&bmp180));
    ESP_ERROR_CHECK(bh1750_setup(&bh1750, BH1750_MODE_CONTINIOUS, BH1750_RES_HIGH));
    ...
    // Create tasks and so on
    ...
}

from esp-idf-lib.

UncleRus avatar UncleRus commented on August 27, 2024

I'm closing this issue for now, feel free to reopen.

from esp-idf-lib.

Related Issues (20)

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.