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

    I2C accelerometer model MMA7455

    Scheduled Pinned Locked Moved Getting Started
    lopyi2csensormma7455i2c bus error
    25 Posts 4 Posters 10.6k Views 4 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.
    • P Offline
      pablocaviglia
      last edited by

      Hi all!
      This time i'm trying to make work the accelerometer MMA7455

      0_1494344082870_upload-b8043c17-228c-497a-9182-695ac65bf3cb

      The MMA7455 schematics are this:
      http://www.geeetech.com/Documents/MMA7455_Schematic Download PDF .pdf

      And the specs of the sensor (ADXL345) that carries the MMA7455 is this:
      https://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf

      I've been trying to do every kind of things to make this little chip work, but no success at all. Almost always getting OSError: I2C bus error

      I'd like to start with a very basic test i'm doing, reading from the DEVID registry of the ADXL345 sensor.

      0_1494345719413_upload-ae54b940-8871-440e-9e99-1672df3bf1cd

      What i get after doing that is:
      0_1494344310595_upload-1fd36691-126a-4e29-9945-fd37c4fd6df1

      Based on the sensor documentation i think that my previous code is fine:
      An alternate I2C address of 0x53 (followed by the R/W bit) can
      be chosen by grounding the SDO/ALT ADDRESS pin (Pin 12).
      This translates to 0xA6 for a write and 0xA7 for a read

      If someone understands what's happening please share that precious knowledge.
      I still dont understand what [59, 60, 61] means by the way...

      L 2 Replies Last reply Reply Quote 1
      • L Offline
        livius @pablocaviglia
        last edited by

        @pablocaviglia
        It is important how do you connect it. Especially CS pin
        0_1494360003092_upload-ba218988-75c7-483f-976d-d1dfe27dd584
        And address pin low or high
        [59, 60, 61] mean that you have 3 "devices" with address decimal 59, 60, 61 (3B,3C,3D)

        think about people first, then computers

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

          @livius CS must be pulled low, to VSS, not high to VDD.

          L 1 Reply Last reply Reply Quote 0
          • L Offline
            livius @robert-hh
            last edited by

            @robert-hh
            in documentation is

            With CS tied high to VDD I/O, the ADXL345 is in I2C mode

            think about people first, then computers

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

              @livius Ok, got it.That's an unusual use of CS. The module which is used here has an internal pull-up for CS, as far as I recall.

              1 Reply Last reply Reply Quote 0
              • J Offline
                jmarcelino
                last edited by

                Correct address for that board (SDO pulled high) is the alternate address: 0x1D

                P 1 Reply Last reply Reply Quote 0
                • P Offline
                  pablocaviglia
                  last edited by

                  Thx all for your interest. I've not get home yet, i'll do some tests based on what you said once there.
                  Anyway before leaving i took a picture of the current connections of the chip. Let me show you how does it looks now:

                  0_1494375152719_IMG_20170509_210815.jpg

                  UP

                  GND -> GND
                  VCC -> 5V

                  DOWN

                  CS -> 5v
                  SDO ->GND
                  SDA SCL -> both to idem on pycom

                  Hope it helps to deduce something!

                  L 1 Reply Last reply Reply Quote 0
                  • P Offline
                    pablocaviglia @jmarcelino
                    last edited by

                    @jmarcelino yes, but i have sdo pulled down

                    1 Reply Last reply Reply Quote 0
                    • L Offline
                      livius @pablocaviglia
                      last edited by livius

                      @pablocaviglia
                      Why 5V?
                      in documentation is
                      Supply voltage range: 2.0 V to 3.6 V

                      and all Pycom boards are 3V3. 5V can crash your Lopy.

                      And about other connections
                      Where do you conect your SDA, SCL. Which pins on Lopy?
                      You use default initialization then i suppose P9 - SDA, P10-SCL?

                      think about people first, then computers

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

                        @livius said in I2C accelerometer model MMA7455:

                        Why 5V?

                        The module has an internal 3.3V regulator RT9161.

                        L 1 Reply Last reply Reply Quote 0
                        • L Offline
                          livius @robert-hh
                          last edited by livius

                          @robert-hh said in I2C accelerometer model MMA7455:

                          RT9161

                          Ah - i see now i ommit this on the first link with schematic

                          Then two things @pablocaviglia
                          Where do you conect your SDA, SCL. Which pins on Lopy?
                          You use default initialization of i2c then i suppose P9 - SDA, P10-SCL?

                          I see on schematic that there is pull up resistor already on i2c
                          This is better picture of it
                          alt text

                          think about people first, then computers

                          P 1 Reply Last reply Reply Quote 1
                          • J Offline
                            jmarcelino
                            last edited by jmarcelino

                            If you look at the the schematic the CS pin on the board shouldn't be connected to 5V. It's comes from 3.3V.

                            The chip pin is not made for that and also you're connecting the 5V supply to a regulated 3.3V via the 4.7K pull up...

                            P 1 Reply Last reply Reply Quote 1
                            • P Offline
                              pablocaviglia @livius
                              last edited by

                              @livius
                              Yes, just using the default initialization, P9 - SDA, P10-SCL

                              1 Reply Last reply Reply Quote 0
                              • P Offline
                                pablocaviglia @jmarcelino
                                last edited by

                                @jmarcelino
                                Very good point man! I've pulled up P23 on pycom to get 3.3v, then i plugged CS and SDO in there, and things got changed a lot.

                                0_1494417293941_upload-146110d1-9c50-4f53-b0d9-cb65b330b5c0

                                And i got this when running:

                                0_1494417319063_upload-d5491b18-5240-479c-be46-b806ea45183c

                                Much much better, no I2C Bus Error anymore.
                                Just to be sure i tried to pull down the pin P23 to verify if it stops working, and it does stop effectively.
                                Also another very good thing is that based on documentation, the slave port to start using is '1D', and now i'm effectively getting 29 (1D) while scaning ports, instead of 59,60,61.

                                <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
                                0_1494417470711_upload-1a252864-b47f-4516-8e90-8e2130984be5 <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

                                There's something that i dont understand from that document section. It says that the 0x1D followed by the R/W bit translates to 0X3A for write and 0x3B for read.... what does that mean?

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

                                  @pablocaviglia The I2C address is located in bits 1..7. Bit 0 is the R/W bit.
                                  0x3a (58) is 0x1d (29) * 2, and 0x3b simply adds 1 in bit 0.

                                  P 1 Reply Last reply Reply Quote 0
                                  • P Offline
                                    pablocaviglia @robert-hh
                                    last edited by

                                    @robert-hh So you say that the slave address would change from read to write.
                                    If i want to read/write it would be:

                                    i2c.readfrom_mem(0x3B, 0x0, 1)
                                    i2c.writeto_mem(0x3A, 0x0, value)

                                    Is that what you mean?

                                    robert-hhR L 2 Replies Last reply Reply Quote 0
                                    • robert-hhR Offline
                                      robert-hh @pablocaviglia
                                      last edited by robert-hh

                                      @pablocaviglia No. It's just the way it has to be coded at the physical interface, not the API you are using. Setting the R/W bit is done by the underlying functions. All you have to do is use the address 29 in the call of python methods.

                                      P 1 Reply Last reply Reply Quote 0
                                      • L Offline
                                        livius @pablocaviglia
                                        last edited by

                                        @pablocaviglia
                                        to not starting from scratch try adapt this
                                        https://github.com/alexismeneses/py-adxl345/blob/master/lib/adxl345/base.py

                                        think about people first, then computers

                                        P 1 Reply Last reply Reply Quote 1
                                        • P Offline
                                          pablocaviglia @robert-hh
                                          last edited by

                                          @robert-hh :+1:

                                          1 Reply Last reply Reply Quote 1
                                          • P Offline
                                            pablocaviglia @livius
                                            last edited by

                                            @livius
                                            I've checked that code, really nice!
                                            I'm not receiving the i2c bus error anymore, but based on docs, when querying the the DEVID registry i should get this:

                                            0_1494429732216_upload-6ccf28b7-12b5-46a2-9911-a3d16f775972

                                            My code does this:
                                            0_1494429760886_upload-8fc5d034-dac6-44b6-b937-d560865dc5bf

                                            And i got this:

                                            0_1494429775086_upload-315fda75-be65-4c03-82e3-93d294e22b3e

                                            PD: By the way, how do i earn reputation points in this forum? I can only send 1 message each 10 minutes... boring!

                                            1 Reply Last reply Reply Quote 2

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

                                            Pycom on Twitter

                                            Pycom