Lopy doesn't send data via LoRa while using SPI and I2C sensor
-
Hello guys,
I'm trying to do a prototype that would send data of 2 sensors to another lopy. The two sensors are, pressure sensor BME280 (I²C) and accelerometre LSM9DS0 (SPI). The LoRa Raw connection between the 2 lopy4 works fine (I've tested it with many projects already). Sending data via LoRa works fine when I only use 1 sensor. But if I connect both the sensors and instanciate SPI Bus and I2C Bus, I only receive empty buffers.Did anyone manage to use SPI and I2C at the same time ?
Here is a look at my main.py
If I uncomment the code under "#-------------BME280" it doesn't work anymore, just by instanciating the I²C.
I'm not using the same clock for SPI and I2C as I saw on an other topic that it didn't work.
main.pythanks in advance
-
Check if LSM9DS0 CS_G and CS_XM are correctly driven to 0 only when you need to communicate with the component , as lopy4 spi pin 38,22,18 is used by sx1272 chip to work properly (this chip is used for Lora/Sigfox) you must ensure that LSM9DS0 CS_G and CS_XM must be set to '1' when you want to use radio.
(where is the source of "lsm9ds0" library you used ?) -
Yes the chip select are set to 0 when used and then set back to 1, you can see it in the function writeregistre() and readRegistre() in the lsm9ds0.py library file that I wrote (except for all the registre address)
I entache the library :
lsm9ds0.py -
@gaet I do not see your BME280 code, but if you do not specify a pin for SCL, I2C and SPI use both P10 for clock, which is different. (SPI: mode OUT, quiet state low, I2C: mode OPEN_DRAIN, quiet mode high)
-
@robert-hh Hi Robert,
I don't use the same clock pins for SPI and I2C. You can see it in the code I didn't share yet in the bme280.py library here :
bme280.py -
@gaet P6 is used for the communication to the Lora module. See: https://docs.pycom.io/gitbook/assets/lopy4-pinout.pdf
-
@robert-hh Ho boy, you might be right, I test it with an other pin and come back to you if I still have problems ! ;)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login