{"id":15020677,"url":"https://github.com/fivdi/bme280","last_synced_at":"2025-09-21T23:31:29.346Z","repository":{"id":35138447,"uuid":"211725580","full_name":"fivdi/bme280","owner":"fivdi","description":"Node.js I2C driver for the BME280 humidity, pressure and temperature sensor","archived":false,"fork":false,"pushed_at":"2022-03-20T02:04:09.000Z","size":360,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T03:31:17.431Z","etag":null,"topics":["beaglebone","beaglebone-black","bme280","humidity","i2c","iot","javascript","nodejs","pressure","raspberry-pi","sensor","temperature"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivdi.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-29T20:59:58.000Z","updated_at":"2024-09-26T00:58:25.000Z","dependencies_parsed_at":"2022-08-08T05:16:06.345Z","dependency_job_id":null,"html_url":"https://github.com/fivdi/bme280","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Fbme280","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Fbme280/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Fbme280/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivdi%2Fbme280/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivdi","download_url":"https://codeload.github.com/fivdi/bme280/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233806278,"owners_count":18733187,"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":["beaglebone","beaglebone-black","bme280","humidity","i2c","iot","javascript","nodejs","pressure","raspberry-pi","sensor","temperature"],"created_at":"2024-09-24T19:55:25.581Z","updated_at":"2025-09-21T23:31:24.023Z","avatar_url":"https://github.com/fivdi.png","language":"JavaScript","readme":"[![Build Status](https://app.travis-ci.com/fivdi/bme280.svg?branch=master)](https://app.travis-ci.com/github/fivdi/bme280)\n[![npm Version](http://img.shields.io/npm/v/bme280.svg)](https://www.npmjs.com/package/bme280)\n[![Downloads Per Month](http://img.shields.io/npm/dm/bme280.svg)](https://www.npmjs.com/package/bme280)\n\n# bme280\n\nNode.js I2C driver for the BME280 humidity, pressure and temperature sensor on\nLinux boards like the Raspberry Pi or BeagleBone.\n\nSupports Node.js versions 10, 12, 14, 15 and 16.\n\n## Contents\n\n * [Features](#features)\n * [Installation](#installation)\n * [Usage](#usage)\n * [API](#api)\n * [Related Packages](#related-packages)\n\n## Features\n\n * Easy humidity, pressure and temperature sensing\n * Normal and forced mode\n * Oversampling\n * Filtering\n * Standby period\n * Promise based asynchronous API\n\n## Installation\n\n```\nnpm install bme280\n```\n\n## Usage\n\n#### Circuit\n\n![](doc/bme280-pi.png)\n\n#### Report the Humidity, Pressure and Temperature\n```js\nconst bme280 = require('bme280');\n\nbme280.open().then(async sensor =\u003e {\n  console.log(await sensor.read());\n  await sensor.close();\n}).catch(console.log);\n\n```\n\nSample output:\n```js\n{\n  temperature: 22.80022401222959,\n  pressure: 990.4595757059205,\n  humidity: 51.50271664115457\n}\n```\n\n#### Report the Humidity, Pressure and Temperature Once per Second in Forced Mode\n```js\nconst bme280 = require('bme280');\n\nconst delay = millis =\u003e new Promise(resolve =\u003e setTimeout(resolve, millis));\n\nconst forcedRead = async sensor =\u003e {\n  await sensor.triggerForcedMeasurement();\n  await delay(sensor.maximumMeasurementTime());\n  console.log(await sensor.read());\n}\n\nbme280.open({forcedMode: true}).then(sensor =\u003e {\n  setInterval(_ =\u003e {\n    forcedRead(sensor).catch(console.log);\n  }, 1000);\n}).catch(console.log);\n```\n\n#### Configure the BME280 Using Options When Invoking `open`\nHere the BME280 is configured to run using oversampling and filtering\noptions recommended for indoor navigation by the BME280 datasheet.\n\n```js\nconst bme280 = require('bme280');\n\nconst format = number =\u003e (Math.round(number * 100) / 100).toFixed(2);\nconst delay = millis =\u003e new Promise(resolve =\u003e setTimeout(resolve, millis));\n\nconst reportContinuous = async _ =\u003e {\n  const sensor = await bme280.open({\n    i2cBusNumber: 1,\n    i2cAddress: 0x77,\n    humidityOversampling: bme280.OVERSAMPLE.X1,\n    pressureOversampling: bme280.OVERSAMPLE.X16,\n    temperatureOversampling: bme280.OVERSAMPLE.X2,\n    filterCoefficient: bme280.FILTER.F16\n  });\n\n  for (let i = 1; i \u003c= 250; ++i) {\n    const reading = await sensor.read();\n    console.log(\n      `${i} ` +\n      `${format(reading.temperature)}°C, ` +\n      `${format(reading.pressure)} hPa, ` +\n      `${format(reading.humidity)}%`\n    );\n    await delay(sensor.typicalMeasurementTime()); // 40 milliseconds, 25Hz\n  }\n\n  await sensor.close();\n};\n\nreportContinuous().catch(console.log);\n```\n\nSample output:\n```\n1 23.57°C, 988.07 hPa, 50.16%\n2 23.57°C, 988.07 hPa, 50.15%\n3 23.57°C, 988.07 hPa, 50.19%\n4 23.57°C, 988.07 hPa, 50.17%\n5 23.57°C, 988.06 hPa, 50.19%\n6 23.57°C, 988.06 hPa, 50.17%\n...\n```\n## API\n\n- [Functions](#functions)\n- [Class Bme280](#class-bme280)\n- [Enum OVERSAMPLE](#enum-oversample)\n- [Enum FILTER](#enum-filter)\n- [Enum STANDBY](#enum-standby)\n\n### Functions\n\n- [open([options])](#openoptions)\n\n#### open([options])\nReturns a Promise that will be resolved with a Bme280 object on success, or\nwill be rejected if an error occurs.\n\nThe default behavior of open is to configure the BME280 on I2C bus 1 at\naddress 0x77 to run in normal mode. The oversampling defaults for humidity,\npressure and temperature are OVERSAMPLE.X1 and the default filterCoefficient\nis FILTER.OFF. The default standby period in normal mode is STANDBY.MS_0_5 for\n0.5 milliseconds. Options are available for overriding these defaults.\n\nIf desired, the BME280 can be configured to run in forced mode rather than in\nnormal mode by setting option forcedMode to true.\n\nNormal mode comprises an automated perpetual cycling between an active\nmeasurement period and an inactive standby period. If the BME280 is configured\nto run in normal mode, open waits (asynchronously) until the BME280 has\ncompleted its first measurement before resolving. This makes it possible to\ninvoke the read method immediately after invoking open to get the first\nreading.\n\nIn forced mode each measurement must be explicitly triggered. If the BME280 is\nconfigured to run forced mode, open will not trigger a measurement. It is the\nresponsibility of the application to trigger each measurement and to wait for\nthe measurement to complete before invoking read to get the reading.\n\nThe following options are supported:\n- i2cBusNumber - integer, I2C bus number, optional, default 1\n- i2cAddress - integer, BME280 I2C address, optional, default 0x77\n- humidityOversampling - one of the [OVERSAMPLE](#enum-oversample) enum\nvalues, controls oversampling of humidity data, optional, default\nOVERSAMPLE.X1\n- pressureOversampling - one of the [OVERSAMPLE](#enum-oversample) enum\nvalues, controls oversampling of pressure data, optional, default\nOVERSAMPLE.X1\n- temperatureOversampling - one of the [OVERSAMPLE](#enum-oversample) enum\nvalues, controls oversampling of temperature data, optional, default\nOVERSAMPLE.X1\n- filterCoefficient - one of the [FILTER](#enum-filter) enum values, slows\ndown the response to the sensor inputs, optional, default FILTER.OFF\n- standby - one of the [STANDBY](#enum-standby) enum values, controls the\ninactive standby period in normal mode, optional, default STANDBY.MS_0_5 for\n0.5 milliseconds\n- forcedMode - boolean, true to run the BME280 in forced mode, false to run\nthe BME280 in normal mode, optional, default false\n\n### Class Bme280\n\n- [read()](#read)\n- [triggerForcedMeasurement()](#triggerForcedMeasurement)\n- [typicalMeasurementTime()](#typicalmeasurementtime)\n- [maximumMeasurementTime()](#maximummeasurementtime)\n- [close()](#close)\n\n#### read()\nReturns a Promise that will be resolved with an object containing the last\nsensor reading on success, or will be rejected if an error occurs.\n\nAn object containing a sensor reading has the following properties:\n- humidity - number, relative humidity in percent\n- pressure - number, pressure in hectopascal (1 hPa = 1 millibar)\n- temperature - number, temperature in degrees Celsius\n\n#### triggerForcedMeasurement()\nReturns a Promise that will be resolved with no arguments once the BME280 has\nbeen triggered to perform a forced measurement, or will be rejected if an\nerror occurs.\n\ntriggerForcedMeasurement should only be called in forced mode.\n\nCalling triggerForcedMeasurement will only trigger the BME280 to perform a\nforced measurement. It will not wait for that measurement to complete. It is\nthe responsibility of the application to wait for the measurement to complete\nbefore invoking read to get the reading.\n\n#### typicalMeasurementTime()\nReturns the typical measurement time in milliseconds.\n\nThe typical measurement time depends on the selected values for humidity,\npressure and temperature oversampling.\n\nIf OVERSAMPLE.X1 (the default) is used for humidity, pressure and temperature\noversampling, the typical measurement time is 8 milliseconds.\n\nIf OVERSAMPLE.X16 is used for humidity, pressure and temperature oversampling,\nthe typical measurement time is 98 milliseconds.\n\n#### maximumMeasurementTime()\nReturns the maximum measurement time in milliseconds.\n\nThe maximum measurement time depends on the selected values for humidity,\npressure and temperature oversampling.\n\nIf OVERSAMPLE.X1 (the default) is used for humidity, pressure and temperature\noversampling, the maximum measurement time is 10 milliseconds.\n\nIf OVERSAMPLE.X16 is used for humidity, pressure and temperature oversampling,\nthe maximum measurement time is 113 milliseconds.\n\n#### close()\nReturns a Promise that will be resolved with no arguments once the underlying\nresources have been released, or will be rejected if an error occurs while\nclosing.\n\n### Enum OVERSAMPLE\n\nControls oversampling of sensor data.\n\n- **SKIPPED** - Measurement skipped. The corresponding property in a sensor\nreading object will be undefined.\n- **X1** - Oversampling × 1\n- **X2** - Oversampling × 2\n- **X4** - Oversampling × 4\n- **X8** - Oversampling × 8\n- **X16** - Oversampling × 16\n\n### Enum FILTER\n\nThe filter is used to slow down the response to the sensor inputs.\n\n- **OFF** - Filter off\n- **F2** - Filter coefficient = 2\n- **F4** - Filter coefficient = 4\n- **F8** - Filter coefficient = 8\n- **F16** - Filter coefficient = 16\n\n### Enum STANDBY\n\nControls the inactive standby period in normal mode.\n\n- **MS_0_5** - 0.5 milliseconds\n- **MS_62_5** - 62.5 milliseconds\n- **MS_125** - 125 milliseconds\n- **MS_250** - 250 milliseconds\n- **MS_500** - 500 milliseconds\n- **MS_1000** - 1000 milliseconds\n- **MS_10** - 10 milliseconds\n- **MS_20** - 20 milliseconds\n\n## Related Packages\n\n- [i2c-bus](https://github.com/fivdi/i2c-bus) - I2C serial bus access\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivdi%2Fbme280","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivdi%2Fbme280","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivdi%2Fbme280/lists"}