I’ve bought a pair of expLoRaBLE. I have successfully tested the LoRa radios using The Things Network. However i’m unable to get any readings out of the DFRobot_B_LUX_V30B sensor. The sensor works perfectly with an Arduino Uno. The connection can be viewed in the attached image.
The code I’m using is also attached.
Below is the code I’m using
#include <DFRobot_B_LUX_V30B.h>
DFRobot_B_LUX_V30B myLux(D7,I2C1_SCL,I2C1_SDA);
void setup() {
Serial.begin(115200);
myLux.begin();
}
void loop() {
Serial.print("value: ");
Serial.print(myLux.lightStrengthLux());
Serial.println(" (lux).");
delay(20000);
}
Currently the output is either -1 lux or 6012954.00 lux. I would be grateful if someone could help me get the correct readings.
The schematic is making me think there might be a typo in our docs/silk screen…
https://cdn.sparkfun.com/assets/4/4/f/7 … ematic.pdf shows qwiic_sda and scl as “2” in the main/1st page, and d16 sda d17 scl…but the hookup guide https://learn.sparkfun.com/tutorials/sp … e-overview (Additional Functions → i2c) shows the qwiic sda/scl labeled as being ‘main’ and the 2nd page of schematic shows them as being “1” , not “2”…
So, try simply changing the sda1 and scl1 to sda2 and scl2 or just sda & scl…any luck?
From [the github page of the explorable, only I2C_SDA/I2C_SCL and I2C1_SDA/I2C1_SCL are defined. When I try I2C_SDA/I2C_SCL, the result is -1 lux. I2C2_SDA1/I2C2_SCL returns a “not declared in this scope error”.
From the Arduino IDE, I2C_SCL is:
enumerator I2C_SCL
Type: enum PinName
Value = 5
I2C
I2C_SCL = AM_BSP_QWIIC_I2C_SCL_PIN
Whilst I2C1_SCL is:
enumerator I2C1_SCL
Type: enum PinName
Value = 8
I2C
I2C1_SCL = D17
So I think the docs is right.](Arduino_Apollo3/variants/LoRa_THING_PLUS_expLoRaBLE/variant.h at main · sparkfun/Arduino_Apollo3 · GitHub)
I had a chat here, and here are some thoughts:
'The problem is the library for that sensor. It’s not actually using the Wire library to implement the I2C protocol. Instead, it is bit-banging the data. Additionally, the customer shouldn’t have to declare the I2C pins, unless they aren’t using the default pins for the board. (Based on that library they only need to define the EN pin.)
-
They should try the example again, only defining the EN
pin.
-
Otherwise, the library specifies what MCUs it is compatible with here: https://github.com/DFRobot/DFRobot_B_LU … patibility
-
If the issue persists, my guess is that the timing functions used for the bit-banging isn’t compatible with the Apollo3 Arduino core.’
So, there are a couple ideas to try, or just leave it hooked up to the Uno (this is what I would do lol)
Okay, thank you for the reply!