As the title says... Chat on...

User avatar
By willwach
#42110 I'm trying to use the BMP085-Module from the following page:
http://nodemcu.readthedocs.org/en/dev/e ... es/bmp085/

sda on 1, scl on2

My code:
Code: Select allfunction readBmp(sdaPin, sclPin)
bmp085.init(sdaPin, sclPin)

local t = bmp085.temperature(1)
print(string.format("Temperature: %s.%s degrees C", t / 10, t % 10))

local p = bmp085.pressure(1)
print(string.format("Pressure: %s.%s mbar", p / 100, p % 100))
end


It always leads to:
Temperature: -13.2 degrees C
Pressure: -306.27 mbar

If I remove the BMP085 Module, its the same.
What am I doing wrong?

Or is this the result if the module is broken?
Could you tell me, how the module should react if nothing is connected to i2c?
Maybe its the default behavier if nothing is connected to answer with these values?

Would be nice if someone could help me.
User avatar
By jankop
#42254 What ESP8266 module you use?
What BMP085 module you use? The module with source 3V3 or without its?
Which pins ESP8266 are connected to BMP085 ?
What version of Lua you use?
What is your whole program?
Answer me , and I 'll tell you what you're doing wrong.
Probably you wrong define ports.

Here is my test code BMP_INTER.lua
Code: Select allsdaPin=4   -- GPIO2 connect to SDA BMP180
sclPin=3   -- GPIO0 connect to SCL BMP180
function readBmp(sdaPin, sclPin)
bmp085.init(sdaPin, sclPin)
local t = bmp085.temperature(1)
print(string.format("%.1f",t/10))
local p = bmp085.pressure(1)
print(string.format("%.1f",p/100))
end
readBmp(sdaPin, sclPin)


And here is response
Code: Select allnode.restart()

NodeMCU custom build by frightanic.com
   branch: master
   commit: c8037568571edb5c568c2f8231e4f8ce0683b883
   SSL: false
   modules: bit,bmp085,file,gpio,i2c,net,node,tmr,uart,wifi
 build    built on: 2016-03-02 17:37
 powered by Lua 5.1.4 on SDK 1.4.0
lua: cannot open init.lua
>
dofile(BMP_INTER.lua)  2. březen 2016  19:31:36

dofile("BMP_INTER.lua")
21.8
978.4
>
User avatar
By willwach
#42672 Many thanks for your answer.

But it seams really simple.

The following is the answer when noting is connected.
Temperature: -13.2 degrees C
Pressure: -306.27 mbar

Its really the default behavier if nothing is connected.
I tried with an other module and it worked. Then i found out, that the former module was not soldered correctly.
Now it works with both modules.

Is it possible to document this behavior?