The Guy knows tech
Published

How to Interface BMP180 module with Esp8266 & iotguru.cloud

In this IOT(internet of things) based project, I will explain how can we connect BMP180 sensor module, with esp8266 and this microcontroller

IntermediateFull instructions provided1 hour3,871
How to Interface BMP180 module with Esp8266 & iotguru.cloud

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
MyOctopus i2c Barometric Air Pressure Sensor BMP280
MyOctopus i2c Barometric Air Pressure Sensor BMP280
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

BMP180_Esp8266_IOTGURU.cloud

Code

How to Interface BMP180 module with Esp8266 and send the data to IOTGuru.cloud

C/C++
#include <IoTGuru.h>
#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

#define ALTITUDE 1655.0 // Altitude of SparkFun's HQ in Boulder, CO. in meters


#ifdef ESP8266
  #include <ESP8266WiFi.h>
#endif

#ifdef ESP32
  #include <WiFi.h>
#endif

const char* ssid      = "Ethical_Hacker";
const char* password  = "744967asd";

WiFiClient client;

String userShortId    = "vJ_xvVtGMU0X8gAQdYQR6g";
String deviceShortId  = "k66t8u55q3co6WgAfAQR6g";
String deviceKey      = "jgBjclUapy763Kf4131KlQ";
IoTGuru iotGuru = IoTGuru(userShortId, deviceShortId, deviceKey);

String nodeShortId    = "vDaDKchX82OttzWAfAQR6g";
String nodeShortId2    = "vDaDKchX82NdxEpAfAQR6g";
String fieldName      = "altitude";
String fieldName2      = "temperature";


void setup() {
  
    Serial.begin(115200);
    delay(10);

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(50);
        Serial.print(".");
    }
    Serial.println("");

    /**
     * Set the callback function.
     */
    iotGuru.setCallback(&callback);
    /**
     * Set the debug printer (optional).
     */
    iotGuru.setDebugPrinter(&Serial);
    /**
     * Set the network client.
     */
    iotGuru.setNetworkClient(&client);
     if (pressure.begin())
    Serial.println("BMP180 init success");
    

}

volatile unsigned long nextSendUptime = 0;

void loop() {
      char status;
  double T;

  // Loop here getting pressure readings every 10 seconds.

  // If you want sea-level-compensated pressure, as used in weather reports,
  // you will need to know the altitude at which your measurements are taken.
  // We're using a constant called ALTITUDE in this sketch:
  
  Serial.println();
  Serial.print("provided altitude: ");
  Serial.print(ALTITUDE,0);
  Serial.print(" meters, ");

  
  // If you want to measure altitude, and not pressure, you will instead need
  // to provide a known baseline pressure. This is shown at the end of the sketch.

  // You must first get a temperature measurement to perform a pressure reading.
  
  // Start a temperature measurement:
  // If request is successful, the number of ms to wait is returned.
  // If request is unsuccessful, 0 is returned.

  status = pressure.startTemperature();
  if (status != 0)
  {
    // Wait for the measurement to complete:
    delay(status);

    // Retrieve the completed temperature measurement:
    // Note that the measurement is stored in the variable T.
    // Function returns 1 if successful, 0 if failure.

    status = pressure.getTemperature(T);
    if (status != 0)
    {
      // Print out the measurement:
      Serial.print("temperature: ");
      Serial.print(T,2);
      Serial.print(" deg C, ");



  delay(5000);  // Pause for 5 seconds.
}
  }
    iotGuru.loop();

    if (nextSendUptime < millis()) {
        nextSendUptime = millis() + 60000;
        iotGuru.sendMqttValue(nodeShortId, fieldName, ALTITUDE);
        iotGuru.sendMqttValue(nodeShortId2, fieldName2, T);
    
        
        
    }
}

void callback(const char* nodeShortId, const char* fieldName, const char* message) {
    Serial.print(nodeShortId);Serial.print(" - ");Serial.print(fieldName);Serial.print(": ");Serial.println(message);
    }

Credits

The Guy knows tech

The Guy knows tech

2 projects • 3 followers
I have experience in the field of Software, Computer Systems, I have been working on different projects, App & Developing Hardware Solutions
Thanks to iotguru.cloud.

Comments