-->
Page 1 of 1

BMP180+nodeMCU output problems

PostPosted: Mon May 02, 2016 1:10 pm
by mat117
hello, i am a beginner with esp8266, but i can use pretty well arduino. so I installed the board on my arduino IDE, uploaded the blink example and it works well. So i connected a bmp180 sensor(witch i want to use for a simple IOT weather station).
SDA=> D1 pin
SCL=> D2 pin
VCC=>3w pin
GND=GND
and i wrote this code (taken from the original code used for arduino)
Code: Select all#include <Wire.h>
#include <BMP180.h>
#define SDAPIN  04
#define SCLPIN  05
// Store an instance of the BMP180 sensor.
BMP180 barometer;
// We are going to use the on board LED for an indicator.


// Store the current sea level pressure at your location in Pascals.
float seaLevelPressure = 101325;

void setup()
{
  // We start the serial library to output our messages.
  Serial.begin(9600);
  // We start the I2C on the Arduino for communication with the BMP180 sensor.
 Wire.begin();
  // Set up the Indicator LED.
  //pinMode(LED_BUILTIN, OUTPUT);
  // We create an instance of our BMP180 sensor.
  barometer = BMP180();
  // We check to see if we can connect to the sensor.
  if(barometer.EnsureConnected())
  {
    Serial.println("Connected to BMP180."); // Output we are connected to the computer.
    //digitalWrite(LED_BUILTIN, HIGH); // Set our LED.
   
     // When we have connected, we reset the device to ensure a clean start.
    barometer.SoftReset();
    // Now we initialize the sensor and pull the calibration data.
    barometer.Initialize();
  }
  else
  {
    Serial.println("No sensor found.");
    //digitalWrite(LED_BUILTIN, LOW); // Set our LED.
  }
}

void loop()
{
  if(barometer.IsConnected)
  {
    // Retrive the current pressure in Pascals.
    long currentPressure = barometer.GetPressure();
   
    // Print out the Pressure.
    Serial.print("Pressure: ");
    Serial.print(currentPressure);
    Serial.print(" Pa");
   
    // Retrive the current altitude (in meters). Current Sea Level Pressure is required for this.
    float altitude = barometer.GetAltitude(seaLevelPressure);
   
    // Print out the Altitude.
    Serial.print("\tAltitude: ");
    Serial.print(altitude);
    Serial.print(" m");
   
    // Retrive the current temperature in degrees celcius.
    float currentTemperature = barometer.GetTemperature();
   
    // Print out the Temperature
    Serial.print("\tTemperature: ");
    Serial.print(currentTemperature);
    Serial.write(176);
    Serial.print("C");
   
    Serial.println(); // Start a new line.
    delay(1000); // Show new results every second.
  }
}

and the serial outputs:
Image
this outputs are absolutely fake, so i need to know where i'am failing because with arduino the same code works well :shock:
thanks for support