🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    DLIGHT - read from microPython

    Scheduled Pinned Locked Moved Modules
    3 Posts 2 Posters 3.5k Views
    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.
    • F Offline
      forestial
      last edited by

      I have an ATOM S3 Lite with a DLIGHT connected to the Grove interface. DLIGHT is the "Ambient Light Unit" with a light sensor of some kind. I have the UIFlow v2 on the ATOM, so microPython is working. I want to read the values from the DLIGHT sensor.
      I have code like the following:

       import machine
       i2c = machine.SoftI2C(scl=machine.Pin(32), sda=machine.Pin(26))
       i2c.scan()
       i2c.readfrom(35, 2)
      

      the scan() function returns [35] so I presume it is connecting successfully.
      But the readfrom() always returns b'\x00\x00' no matter what brightness the light is on the sensor.
      Is there something else I need to do, to initialize the DLIGHT?
      Or do I need to pass 'freq' or other parameters when I create the i2c object?

      teastainT 1 Reply Last reply Reply Quote 0
      • teastainT Offline
        teastain @forestial
        last edited by teastain

        If this:
        https://docs.m5stack.com/en/core/AtomS3 Lite
        is your unit, maybe try pins scl 1 and sda 2 ?
        Works (on Arduino IDE, anyway), for me!
        -Terry

        Cheers, Terry!

        100% M5Stack addict with several drawers full of product!

        1 Reply Last reply Reply Quote 1
        • F Offline
          forestial
          last edited by

          Actually I mis-identified my module, it's ATOM LITE not ATOM S3 LITE on closer inspection (the names of these things can be confusing). I got the pin numbers scl 32 and sda 26 from the legend on the device itself, and I think they must be correct since it is able to reply with the [35] from the scan() function.

          I tried looking at the Arduino code from GitHub to see if it does some kind of initialization of the DLIGHT before reading, but I can't figure it out.

          Anyway thanks for replying Terry.

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