Arduino MKR WAN 1310 won't read i2c devices

Hi! I'm new to MKR series. I'm trying to make an open-source ambient kit monitoring to be connected to LoRa. I want to use Grove Sunlight Sensor and Grove Barometer Sensor. I'm connecting them like this but when I use this i2c scanner I just get the internal 0x60 and 0x6B addresses. Can anyone help me with this? Thanks in advance!

Welcome to the forum.

Why the 220Ω and 470Ω resistors ? The person who made that picture does not know what the I2C bus is. Can you remove them ? Just connect SDA to SDA and SCL to SCL. Power the modules with 3.3V.

There might already be a lot pullup resistors on those modules.
Both the barometer and sunlight sensors have two 4k7 on SDA and SCL, because they included a I2C level shifter on the module. That makes a total of 4 pullup resistors to 3.3V.
The current should not exceed 3mA: 3.3V / (four 4k7) = 2.8 mA
That is close.
Adafruit uses 10k pullup for their onlboard I2C level shifters.

Now it works! Thank you so much @Koepel

Now my doubt is how to call the different devices in the loop. One device is at 0x76 and the other 0x53. If I want to print 0x76's readings for example. Thanks!

Let the libraries for the sensors deal with the I2C bus and the I2C address.
If you try an example sketch from the library from one sensor and then an example sketch for the other sensor, then you can combine them and they both will work.

Look at such an example: Grove_Sunlight_Sensor/SI1145DEMO.ino at Si1151 · Seeed-Studio/Grove_Sunlight_Sensor · GitHub
There are no I2C things there, that is done in the library. You can just use the library.

Thanks for that! I've already tried with that library, it works fine for arduino nano but for MKR 1310 it delivers me this message:

Arduino:1.8.19 (Mac OS X), Tarjeta:"Arduino MKR WAN 1310"

In file included from /Users/nix/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                 from /Users/nix/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd.h:105,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/cores/arduino/WVariant.h:22,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/variants/mkrwan1300/variant.h:24,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/libraries/Wire/Wire.h:24,
                 from /Users/nix/Library/CloudStorage/GoogleDrive-nicosaga@gmail.com/Mi unidad/Arduino-share/groveSunlightDetector_not_work_with_mkr_1310_/groveSunlightDetector_not_work_with_mkr_1310_.ino:1:
/Users/nix/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined
 #define LITTLE_ENDIAN          1
 
In file included from /Users/nix/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/types.h:67:0,
                 from /Users/nix/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/stdio.h:61,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/cores/arduino/api/Print.h:22,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/cores/arduino/api/Stream.h:25,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/cores/arduino/api/HardwareI2C.h:22,
                 from /Users/nix/Library/Arduino15/packages/arduino/hardware/samd/1.8.13/libraries/Wire/Wire.h:23,
                 from /Users/nix/Library/CloudStorage/GoogleDrive-nicosaga@gmail.com/Mi unidad/Arduino-share/groveSunlightDetector_not_work_with_mkr_1310_/groveSunlightDetector_not_work_with_mkr_1310_.ino:1:
/Users/nix/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/machine/endian.h:17:0: note: this is the location of the previous definition
 #define LITTLE_ENDIAN _LITTLE_ENDIAN
 
sketch/groveSunlightDetector_not_work_with_mkr_1310_.ino.cpp.o: In function `loop':
/Users/nix/Library/CloudStorage/GoogleDrive-nicosaga@gmail.com/Mi unidad/Arduino-share/groveSunlightDetector_not_work_with_mkr_1310_/groveSunlightDetector_not_work_with_mkr_1310_.ino:31: undefined reference to `Si115X::ReadHalfWord()'
/Users/nix/Library/CloudStorage/GoogleDrive-nicosaga@gmail.com/Mi unidad/Arduino-share/groveSunlightDetector_not_work_with_mkr_1310_/groveSunlightDetector_not_work_with_mkr_1310_.ino:33: undefined reference to `Si115X::ReadHalfWord_VISIBLE()'
/Users/nix/Library/CloudStorage/GoogleDrive-nicosaga@gmail.com/Mi unidad/Arduino-share/groveSunlightDetector_not_work_with_mkr_1310_/groveSunlightDetector_not_work_with_mkr_1310_.ino:35: undefined reference to `Si115X::ReadHalfWord_UV()'
collect2: error: ld returned 1 exit status
exit status 1
Error compilando para la tarjeta Arduino MKR WAN 1310.

Do you have any clue what this could be? I suppose this library is not supported for SAMD procesor maybe...

As far as I can tell, the library uses the Arduino Wire library in a normal way. It should work with every (compatible) Wire library on every board.

The compiler complains that it can not find the function "ReadHalfWord()", but it is here in the library.

If you download the Arduino IDE, and store the sketch locally in "Documents / Arduino" and install a library via the Arduino IDE in the local folder "Documents / Arduino / libraries", I think it should work.

Yes..I see it also in my .cpp file but it still does not compile nor upload for my MKR 1310.. I don't know..I'll continue searching. Thanks!

Sorry, I see now that it is a Mac OS. I know nothing about that. If you can not make it work, you could start a new topic, specifically for: Mac OS + MKR1310 + library.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.