Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Lopy doesn't send data via LoRa while using SPI and I2C sensor

    Scheduled Pinned Locked Moved LoPy
    7 Posts 3 Posters 473 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      gaet
      last edited by

      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.py

      thanks in advance

      robert-hhR 1 Reply Last reply Reply Quote 0
      • E Offline
        Eric73
        last edited by

        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 ?)

        1 Reply Last reply Reply Quote 0
        • G Offline
          gaet
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @gaet
            last edited by

            @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)

            G 1 Reply Last reply Reply Quote 0
            • G Offline
              gaet @robert-hh
              last edited by

              @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

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @gaet
                last edited by

                @gaet P6 is used for the communication to the Lora module. See: https://docs.pycom.io/gitbook/assets/lopy4-pinout.pdf

                G 1 Reply Last reply Reply Quote 0
                • G Offline
                  gaet @robert-hh
                  last edited by

                  @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 ! ;)

                  1 Reply Last reply Reply Quote 0

                  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
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom