calebbrewer
Member since Dec 2017 • Last active Jan 2020Most recent activity
-
- 20 comments
- 5,198 views
-
@allObjects haha! That was my thought too. I can read temp and pressure accurately if I leave out altitude, and that is what I really need. When I get a chance I will dig a bit more into the module (https://github.com/espruino/EspruinoDocsĀ/blob/master/devices/MPL3115A2.js).
Thanks for all the help. If anyone has any other ideas that would be great.
-
-
Am I to understand then, that only accurate data is obtained when L14-L17 are commented out?
That is correct.I made the interval 10s and added as much as a 2s timeout between the different reading with the same results.
I am not using any pull-ups on the i2c connection.
Everything is grounded.I tried reordering the functions and got some different results. I found that it doesn't matter where the temp reading is, but it can't read altitude and pressure (no matter which callback is first), or one of them will come up with crazy numbers. Also, the first reading is always off.
I am under the impression that the sensor uses the pressure and temp to estimate the altitude.
-
I am using a MDBT42Q breakout. It is on a breadboard. The MDBT42Q and the MPL3115A2 are powered with 5v. The screen does work. I was getting the same readings when it wasn't in the mix. The MPL3115A2 is from Adafruit.
I have refactored my code to this (with the same result):
var i2c = new I2C(); I2C1.setup({scl: D20, sda: D22}); i2c.setup({sda:D30,scl:D29}); var mpl = require("MPL3115A2").connect(i2c); var lcd = require("HD44780").connectI2C(I2C1, 0x3F); lcd.setCursor(0, 0); lcd.print("Starting..."); const onInit = ()=> { setInterval(() => { mpl.getPressure(function(x) { console.log("Pressure "+x+" pa"); mpl.getAltitude(function(x) { console.log("Altitude "+x+" m"); mpl.getTemperature(function(x) { console.log("Temperature "+x+" C"); }); }); }); }, 5000); }; setTimeout(onInit, 3000);
Per @allObjects I changed it so that I was only reading pressure. When I do that, the readings are 100066, and that is really close to the Arduino.
-
I am delaying the code. Here is what I have. There is also a display hooked up.
var i2c = new I2C(); I2C1.setup({scl: D20, sda: D22}); i2c.setup({sda:D30,scl:D29}); var mpl = require("MPL3115A2").connect(i2c); var lcd = require("HD44780").connectI2C(I2C1, 0x3F); lcd.setCursor(0, 0); lcd.print("Starting..."); setTimeout(() => { setInterval(() => { mpl.getPressure(function(x) { console.log("Pressure "+x+" pa"); mpl.getAltitude(function(x) { console.log("Altitude "+x+" m"); mpl.getTemperature(function(x) { console.log("Temperature "+x+" C"); }); }); }); }, 5000); }, 1000);
-
I am getting some odd reading from this sensor using the Espruino module (https://www.espruino.com/MPL3115A2).
When I run the example code, I get these reading:
Pressure 442.25 pa Altitude 110.125 m Temperature 17.6875 C
If I run the sam sensor hooked to an Arduino board, I get these readings:
100158.25 P 97.50 M 15.69 C
The Arduino readings seem to be correct.
Any ideas?
-
Right. What I meant was that I thought I tried 0x3F for the address using hardware I2C (without var i2c = new I2C();).
I realized the var names were different when using i2c = new I2C(); and changed them. This resulted in no errors, but the screen did not work. This of course was because the address was wrong.
That looks sweet! I'll look into i. Thanks