{"id":25560027,"url":"https://github.com/styropyr0/reading-from-bmp180-without-library","last_synced_at":"2025-10-24T06:10:55.629Z","repository":{"id":266998621,"uuid":"899984802","full_name":"styropyr0/Reading-from-BMP180-without-library","owner":"styropyr0","description":"This project is perfect for all the tech nerds and DIY enthusiasts  out there who love to dive deep into the workings of the BMP180 sensor.  Forget the dedicated library—here, we go old school and read the data  straight from the registers.","archived":false,"fork":false,"pushed_at":"2024-12-07T15:04:26.000Z","size":576,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-07T16:17:21.727Z","etag":null,"topics":["arduino","arduino-ide","arduino-sketch","arduino-uno","barometer","bmp180","bmp280","i2c","iot","pressure-sensor","sensor"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/styropyr0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-07T14:56:18.000Z","updated_at":"2024-12-07T15:06:09.000Z","dependencies_parsed_at":"2024-12-07T16:17:25.653Z","dependency_job_id":"e32e42b8-bb84-4929-ab03-86df48606fea","html_url":"https://github.com/styropyr0/Reading-from-BMP180-without-library","commit_stats":null,"previous_names":["styropyr0/reading-from-bmp180-without-library"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FReading-from-BMP180-without-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FReading-from-BMP180-without-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FReading-from-BMP180-without-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FReading-from-BMP180-without-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styropyr0","download_url":"https://codeload.github.com/styropyr0/Reading-from-BMP180-without-library/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239881744,"owners_count":19712633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-ide","arduino-sketch","arduino-uno","barometer","bmp180","bmp280","i2c","iot","pressure-sensor","sensor"],"created_at":"2025-02-20T17:28:54.305Z","updated_at":"2025-10-24T06:10:55.533Z","avatar_url":"https://github.com/styropyr0.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BMP180 Sensor Data Reading Project\n\nHey there, tech nerds and DIY wizards! This project is your golden ticket to dive deep into the guts of the BMP180 sensor. We're going old-school and bypassing the dedicated library, reading data straight from the registers like true hackers. Ready to unlock the mysteries of temperature and pressure readings? Let's get cracking!\n\n## Overview\n\nThis project lets you read and understand data from the BMP180 sensor without using the BMP180 library. We're talking raw, unfiltered data straight from the sensor. Perfect for those who want to get their hands dirty and learn the ins and outs of I2C communication.\n\n## Features\n\n- **Direct Register Reading**: Skip the library and get your data straight from the source.\n- **Temperature Calculation**: Turn raw data into actual temperature readings.\n- **Pressure Calculation**: Convert raw pressure data and even calculate altitude.\n- **Educational**: Ideal for learning how to communicate with sensors and process data.\n\n## Components\n\n- **BMP180 Sensor**: The star of the show, a digital barometric pressure sensor.\n- **Arduino Board**: Any board that supports I2C will do.\n- **Wiring**: Connect the sensor to the Arduino using the I2C interface.\n\n## Setup and Usage\n\n1. **Wiring**:\n   - Connect the SDA and SCL pins of the BMP180 to the corresponding pins on the Arduino.\n   - VCC to 3.3V and GND to GND.\n\n2. **Code Breakdown**:\n\n### 1. Include Libraries and Define Variables\n```cpp\n#include \u003cWire.h\u003e\n\nuint8_t DAT[22] = { /* Calibration data addresses */ };\nshort _AC1, _AC2, _AC3, _B1, _B2, _MB, _MC, _MD;\nshort _AC4, _AC5, _AC6;\nlong B5, UT, UP, T;\n```\n- **Wire.h**: Library for I2C communication.\n- **DAT array**: Holds calibration data addresses.\n- **Calibration Variables**: Stores necessary calibration values.\n- **Measurement Variables**: Temporary storage for raw and calculated data.\n\n### 2. Setup Function\n```cpp\nvoid setup() {\n    Wire.begin();\n    Serial.begin(9600);\n    delay(100);\n\n    for (int i = 0; i \u003c 22; i++)\n        DAT[i] = readData(DAT[i]);\n\n    shiftVal(DAT[0], DAT[1], \u0026_AC1, 0);\n    // Repeat for other calibration values...\n}\n```\n- **Wire.begin()**: Starts I2C communication.\n- **Serial.begin(9600)**: Sets up serial communication.\n- **Calibration Data Reading**: Reads and stores calibration values from the sensor.\n\n### 3. Read Data Function\n```cpp\nuint16_t readData(int REG_ADDR) {\n    Wire.beginTransmission(0x77);\n    Wire.write(REG_ADDR);\n    Wire.endTransmission(false);\n    Wire.requestFrom(0x77, 1);\n    return Wire.read();\n}\n```\n- **readData()**: Reads a byte of data from the sensor's register.\n\n### 4. Shift Value Function\n```cpp\nvoid shiftVal(uint8_t V1, uint8_t V2, short *store, int isAbs) {\n    *store = static_cast\u003cint16_t\u003e((int16_t(V1) \u003c\u003c 8) | V2);\n    if (isAbs)\n        *store = (uint16_t(V1) \u003c\u003c 8) | V2;\n}\n```\n- **shiftVal()**: Combines two 8-bit values into a 16-bit value.\n\n### 5. Read Uncompensated Temperature\n```cpp\nvoid readUT() {\n    Wire.beginTransmission(0x77);\n    Wire.write(0xF4);\n    Wire.write(0x2E);\n    Wire.endTransmission(false);\n    delayMicroseconds(4500);\n\n    Wire.beginTransmission(0x77);\n    Wire.write(0xF6);\n    Wire.endTransmission(false);\n    Wire.requestFrom(0x77, 2);\n    UT = static_cast\u003cuint16_t\u003e((uint16_t(Wire.read()) \u003c\u003c 8) | Wire.read());\n}\n```\n- **readUT()**: Grabs the raw temperature data from the sensor.\n\n### 6. Calculate Temperature\n```cpp\nvoid temp() {\n    long x1 = (UT - _AC6) * (_AC5 / pow(2, 15));\n    long x2 = _MC * pow(2, 11) / (x1 + _MD);\n    B5 = x1 + x2;\n    T = (B5 + 8) / pow(2, 4);\n    Serial.print(\"Temperature: \");\n    Serial.print(float(T) / 10.4);\n    Serial.println(\"C\");\n}\n```\n- **temp()**: Converts raw temperature data into actual temperature readings.\n\n### 7. Read Uncompensated Pressure\n```cpp\nvoid readUP(short oss) {\n    Wire.beginTransmission(0x77);\n    Wire.write(0xF4);\n    Wire.write(0x34 | (oss \u003c\u003c 6));\n    Wire.endTransmission(false);\n    delay(70);\n\n    UP = 0;\n    Wire.beginTransmission(0x77);\n    Wire.write(0xF6);\n    Wire.endTransmission(false);\n    Wire.requestFrom(0x77, 3);\n    for (int i = 0; i \u003c 3; i++) {\n        UP \u003c\u003c= 8;\n        UP |= Wire.read();\n    }\n    UP \u003e\u003e= (8 - oss);\n}\n```\n- **readUP()**: Grabs the raw pressure data from the sensor.\n\n### 8. Calculate Pressure and Altitude\n```cpp\nvoid pressure(short oss) {\n    long B6 = B5 - 4000;\n    long X1 = (_B2 * (B6 * B6 / pow(2, 12))) / pow(2, 11);\n    long X2 = _AC2 * B6 / pow(2, 11);\n    long X3 = X1 + X2;\n    long B3 = ((((_AC1 * 4) + X3) \u003c\u003c oss) + 2) / 4;\n    X1 = _AC3 * B6 / pow(2, 13);\n    X2 = (_B1 * (B6 * B6 / pow(2, 12))) / pow(2, 16);\n    X3 = ((X1 + X2) + 2) / pow(2, 2);\n    unsigned long B4 = _AC4 * (unsigned long)(X3 + 32768) / pow(2, 15);\n    unsigned long B7 = ((unsigned long)UP - B3) * (50000 \u003e\u003e oss);\n    long p = 0;\n    if (B7 \u003c 0x80000000)\n        p = (B7 * 2) / B4;\n    else\n        p = (B7 / B4) * 2;\n    X1 = pow((p / pow(2, 8)), 2);\n    X1 = (X1 * 3038) / pow(2, 16);\n    X2 = (-7357 * p) / pow(2, 16);\n    p = p + (X1 + X2 + 3791) / pow(2, 4);\n    Serial.print(\"Pressure: \");\n    Serial.print(p);\n    Serial.print(\"Pa\");\n    Serial.print(\"\\tAltitude: \");\n    double alt1 = 44330.0 * (1 - pow(((double)p / 101325.0), 1.0 / 5.255));\n    Serial.print(alt1);\n    Serial.println(\"m\");\n}\n```\n- **pressure()**: Turns raw pressure data into actual pressure readings and calculates altitude.\n\n### 9. Main Loop\n```cpp\nvoid loop() {\n    readUT();\n    readUP(3);\n    temp();\n    pressure(3);\n    delay(1000);\n}\n```\n- **loop()**: Continuously reads temperature and pressure data, calculates the actual values, and prints them every second.\n\n## Author\n\n- **Saurav Sajeev**\n- Email: sauravsajeev202@gmail.com\n\n## License\n\nThis project is open-source and available under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Freading-from-bmp180-without-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyropyr0%2Freading-from-bmp180-without-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Freading-from-bmp180-without-library/lists"}