Simultaneous use of i2c libraries or Wire.begin


#1

Hello all,

I have noted that it is impossible to use any more that one community library that accesses the i2c bus.
Just one loads fine and works. Any more than one, or even a simple call to Wire.begin() when a library is loaded will send the DK into SOS mode with one flash after the SOS.

Here is the example code that crashes the DK, If i omit the Wire.begin(); line the library loads and works normally.

// This #include statement was automatically added by the Particle IDE.
#include “adafruit-sht31/adafruit-sht31.h”

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup()
{
sht31.begin(0x44);
Wire.begin();
}

void loop() {
System.sleep(SLEEP_MODE_CPU);
}

this will also crash the board, but if only either one of the libraries is they work

// This #include statement was automatically added by the Particle IDE.
#include “Adafruit_TSL2591/Adafruit_TSL2591.h”
#include “adafruit-sht31/adafruit-sht31.h”

Adafruit_SHT31 sht31 = Adafruit_SHT31();
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591);

void setup()
{
sht31.begin(0x44);
tsl.begin();
}

void loop() {
System.sleep(SLEEP_MODE_CPU);
}

Any ideas? I think that since all libraries that access the i2c bus call the Wire.begin(), the double call to the library causes a crash.


#2

Thanks for the report, this is now fixed in develop!


#3

@eric good ! to flash development firmware do i need FTDI interface?


#4

you can do it OTA, just use the Particle CLI to send it over. you can see more details here: http://docs.bluz.io/tutorials/updates/


#5

thank you @eric there is a folder zip with a lot of files, do I have to compile to a .bin file?


#6

zip files? where?

yes, you need to send bin files over through either OTA or through the UART option in bootloader setup.


#7

@eric can’t find the bin on githib, just the source, which is a zip file of a folder which contains a series of files and folders. I tried the instructions on the particle website to cd into modules and run a make command but i get errors.


#8

ah, yes, we don’t regularly build files and post them as things change very often in that branch. i can help you get your build environment setup if you would like to go that route. what errors are you seeing?


#9

Luigis-MacBook-Pro:modules gigi$ make clean all PLATFORM=bluz -s program-dfu
/Users/gigi/Downloads/firmware/modules/bluz/system-part1/makefile /Users/gigi/Downloads/firmware/modules/bluz/user-part/makefile
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
/bin/sh: arm-none-eabi-gcc: command not found
make[2]: *** […/build/target/communication/platform-103-m-prod-103/./lib/mbedtls/library/aes.o] Error 127
make[1]: *** [communication] Error 2
make: *** [/Users/gigi/Downloads/firmware/modules/bluz/system-part1/makefile] Error 2
Luigis-MacBook-Pro:modules gigi$


#10

ok, that is pretty easy, you just need to install arm gcc. you can download the tried and true version that I use here: https://launchpad.net/gcc-arm-embedded/+milestone/4.9-2015-q3-update