Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

library for talking to the MPL115A2 #54

Closed
wants to merge 2 commits into from

Conversation

asciipip
Copy link

@asciipip asciipip commented Aug 7, 2013

I wrote a library for the MPL115A2. I thought it might be nice to get the code into the upstream repo.

My code is released under a CC0 waiver (http://creativecommons.org/publicdomain/zero/1.0/), so you can do whatever you'd like with it.

@tdicola
Copy link
Contributor

tdicola commented Jul 27, 2014

Thanks for submitting the pull request and apologies it wasn't looked at sooner. I gave it a quick try with a demo that calls getPT every second, but am getting a lot of noisey values back with temperature values varying wildy.

Code I'm using to test:

# Example of using the MPL115A2 pressure & temperature sensor.
# Connect MPL115A2 VDD to Pi 3.3V
# Connect MPL115A2 GND to Pi ground
# Connect MPL115A2 SCL to Pi I2C SCL
# Connect MPL115A2 SDA to Pi I2C SDA
import time

import Adafruit_MPL115A2 as MPL


# Create sensor with default I2C address of 0x60.
sensor = MPL.MPL115A2()

print 'Press Ctrl-C to quit.'
while True:
        # Grab a reading for pressure and temp.
        pressure, temp = sensor.getPT()
        # Print results.
        print 'Pressure', pressure, 'Temperature', temp
        # Sleep for a second.
        time.sleep(1.0)

Example of some of the output:

Press Ctrl-C to quit.
Pressure 226.507758881 Temperature -25.6542056075
Pressure 226.507758881 Temperature -25.6542056075
Pressure 71.0096603976 Temperature 117.897196262
Pressure 87.0214914332 Temperature 117.897196262
Pressure 164.670689576 Temperature -25.6542056075
Pressure 164.670689576 Temperature -25.6542056075
Pressure 149.160369145 Temperature 70.046728972
Pressure 79.0155759154 Temperature 117.897196262
Pressure 156.731341457 Temperature 22.1962616822
Pressure 149.160369145 Temperature 70.046728972
Pressure 257.426293534 Temperature -25.6542056075
Pressure 79.0155759154 Temperature 117.897196262
Pressure 102.230003457 Temperature 70.046728972

To rule out a sensor issue I wired the same sensor up to an Arduino and see consistently good values with temps around 22C as expected.

I'll come back later to look closer at the code. Perhaps the conversion from register value to numeric value isn't working as expected and causing the incorrect values to be returned.

@asciipip
Copy link
Author

Ha! And I didn't notice this reply for three months.

My code's working stably for me (of course; I wouldn't have sent the pull request otherwise). I'll see if I can spend some time on it soon and see what might be going wrong.

@improti
Copy link

improti commented Oct 10, 2015

We are talking MPL3115A2 here, aren't we? In the opposite to MPL115A2 as stated in title and issue. Any news/progress here?

@asciipip
Copy link
Author

What I have is an MPL115A2. I ordered it from here: https://www.adafruit.com/products/992

@improti
Copy link

improti commented Oct 15, 2015

Yeah, MPL115A2 is different to MPL3115A2. Thx for pointing that out. There does not seem to be raspi-code around for the latter. Will see that I get my stuff uploaded, I at least have it running "somehow" ...

But it seems the Adafruit repository is not really getting much love, is it? Your request is from 2013, you got a reaction in 2014, and I think we might have 2015 now?

@asciipip
Copy link
Author

@tdicola This code still works (apparently) correctly for me on my MPL115A2, which is wired exactly the way you describe yours. Can you update to my latest code, rerun your tests with the MPL115A2 class's debug parameter set to True, and tell me what its output is? I'd like to see what you're getting from the sensor's registers.

@unic8s
Copy link

unic8s commented Dec 3, 2015

@asciiphil I tested your code today. I used a very plain and clean setup for testing but I got the same problems which @tdicola got.

This is the output of the temperature values:

22.0093457944
-25.8411214953
-25.8411214953
22.1962616822
-25.6542056075
22.1962616822
117.897196262
22.1962616822
22.1962616822
22.1962616822
70.046728972
-25.6542056075
117.710280374
69.8598130841
22.0093457944
22.0093457944
22.0093457944
-25.8411214953
117.710280374

@asciipip
Copy link
Author

asciipip commented Dec 4, 2015

@unic8s Can you initialize the MPL115A2 class with debug=True and tell me what that prints out? I want to see what actual values the class is getting over the I2C bus.

@neshaman
Copy link

Hi, I'm new to Pi world, but is there the library for the MPL3115A2 ?

Thanks

@neshaman
Copy link

@ladyada
Copy link
Member

ladyada commented Sep 30, 2019

This library has been deprecated in favor of our python3 Blinka library. We have replaced all of the libraries that use this repo with CircuitPython libraries that are Python3 compatible, and support a wide variety of single board/linux computers!

Visit https://circuitpython.org/blinka for more information

CircuitPython has support for almost 200 different drivers, and a as well as FT232H support for Mac/Win/Linux!

@ladyada ladyada closed this Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants