{"id":22071496,"url":"https://github.com/zonque/gas-tally","last_synced_at":"2026-04-25T16:34:53.524Z","repository":{"id":66926916,"uuid":"517299224","full_name":"zonque/gas-tally","owner":"zonque","description":"ESP8266 based gas meter monitor","archived":false,"fork":false,"pushed_at":"2022-08-02T21:31:53.000Z","size":832,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T19:17:08.656Z","etag":null,"topics":["energy-monitor","esp8266","gas-sensor","iot","magnetometer"],"latest_commit_sha":null,"homepage":"","language":"C++","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/zonque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-07-24T11:03:03.000Z","updated_at":"2024-11-04T08:48:27.000Z","dependencies_parsed_at":"2023-02-23T04:30:28.990Z","dependency_job_id":null,"html_url":"https://github.com/zonque/gas-tally","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zonque/gas-tally","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonque%2Fgas-tally","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonque%2Fgas-tally/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonque%2Fgas-tally/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonque%2Fgas-tally/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonque","download_url":"https://codeload.github.com/zonque/gas-tally/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonque%2Fgas-tally/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32269462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["energy-monitor","esp8266","gas-sensor","iot","magnetometer"],"created_at":"2024-11-30T20:31:52.385Z","updated_at":"2026-04-25T16:34:53.508Z","avatar_url":"https://github.com/zonque.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gas Tally\n\nA little project to keep track of gas usage and log it to [InfluxDB](https://www.influxdata.com/) for vizualisation.\n\nIt's built with a D1 mini board, featuring an ESP8266 and an HMC5883 magnet sensor chip, connected via I2C.\n\n## Monitoring\n\nGas meters such as the the one pictured below have a small magnet in the last (rightmost) ring which\ncan be detected using a magnet sensor.\n\n![meter](https://raw.githubusercontent.com/zonque/gas-tally/main/images/meter.jpg)\n\n## Hardware wiring\n\nA D1 mini module (ESP8266 based) was used and connected to an HMC5883 breakout board. Other ESP8266 derivates might also work.\nConnect the I2C lines (SDA and SCL) and supply the HMC5883 board with +3.3v and GND. The DRDY pin can be left unconnected.\n\n![wiring schematics](https://github.com/zonque/gas-tally/blob/main/images/wiring.png)\n\nThe sensor is then mounted underneath the gas meter. Duct tape is your friend :)\n\n![installed](https://github.com/zonque/gas-tally/blob/main/images/installed.jpg)\n\n## Firmware details\n\nThe firmware will do the following upon startup:\n\n* Initialize the HMC5883\n* Connect to the configured Wifi\n* Set the local time using NTP\n* Connect to InfluxDB\n\nIt will then periodically (once per second) read out the sensor values and print them to the serial console.\n\nThe Z axis of the magnet sensor is further evaluated, assuming that the sensor is mounted flat on the bottom of the gas meter.\n\nFor the purposes of debouncing, its value will have to drop below the configured `MAGNET_THRESHOLD_LOW` value,\nand then rise above `MAGNET_THRESHOLD_HIGH` again.\n\nThis event signifies a full turnaround of the measured ring. A data point is now logged to InfluxDB with a fixed value as\nconfigured in `DATA_POINT_VALUE`.\n\n## Compiling\n\nYou will need to have [PlatformIO](https://platformio.org/) set up in order to satisfy the dependency libraries and compile the firmware.\n\nCopy `include/config.h.template` to `include/config.h` and add your configuration to the variables documented in that file.\n\n## Influx\n\nThe easiest way to get started is to use [InfluxDB's hosted cloud service](https://cloud2.influxdata.com/signup).\n\nUse InfluxDB queries to make use of the data. Note that the data represents multiple data points with the same value each,\nso you need to select the `sum` aggregation to plot meaningful graphs.\n\nFor instance, use the following query:\n\n```\nfrom(bucket: \"gas-tally\")\n  |\u003e range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |\u003e filter(fn: (r) =\u003e r[\"_measurement\"] == \"usage\")\n  |\u003e filter(fn: (r) =\u003e r[\"_field\"] == \"m3\")\n  |\u003e filter(fn: (r) =\u003e r[\"sensor-id\"] == \"sensor-1\")\n  |\u003e aggregateWindow(every: 5m, fn: sum, createEmpty: true)\n  |\u003e yield(name: \"sum\")\n```\n\nHere's an example of the plot that resulted from the query above:\n\n![influx graph example](https://github.com/zonque/gas-tally/blob/main/images/influx.png)\n\n## Homeassistant\n\n[HomeAssistant](https://home-assistant.io) as support for Influx queries built-in. Here's an example config to display the measurements of your meter for the last hour, day and week:\n\n```\n- platform: influxdb\n  api_version: 2\n  ssl: true\n  host: XXX\n  port: 443\n  token: XXX\n  organization: XXX\n  bucket: gas-tally\n  queries_flux:\n    - range_start: -7d\n      name: Gas usage in the last 7 days\n      query: \u003e\n        filter(fn: (r) =\u003e r[\"_measurement\"] == \"usage\")\n        |\u003e filter(fn: (r) =\u003e r[\"sensor-id\"] == \"my-sensor\")\n        |\u003e filter(fn: (r) =\u003e r[\"_field\"] == \"m3\")\n        |\u003e aggregateWindow(every: inf, fn: sum)\n        |\u003e cumulativeSum()\n      value_template: \"{{ value|float(0)|round(2) }} m^3\"\n    - range_start: -24h\n      name: Gas usage in the last 24h\n      query: \u003e\n        filter(fn: (r) =\u003e r[\"_measurement\"] == \"usage\")\n        |\u003e filter(fn: (r) =\u003e r[\"sensor-id\"] == \"my-sensor\")\n        |\u003e filter(fn: (r) =\u003e r[\"_field\"] == \"m3\")\n        |\u003e aggregateWindow(every: inf, fn: sum)\n        |\u003e cumulativeSum()\n      value_template: \"{{ value|float(0)|round(2) }} m^3\"\n    - range_start: -1h\n      name: Gas usage in the last hour\n      query: \u003e\n        filter(fn: (r) =\u003e r[\"_measurement\"] == \"usage\")\n        |\u003e filter(fn: (r) =\u003e r[\"sensor-id\"] == \"my-sensor\")\n        |\u003e filter(fn: (r) =\u003e r[\"_field\"] == \"m3\")\n        |\u003e aggregateWindow(every: inf, fn: sum)\n        |\u003e cumulativeSum()\n      value_template: \"{{ value|float(0)|round(2) }} m^3\"\n```\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonque%2Fgas-tally","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonque%2Fgas-tally","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonque%2Fgas-tally/lists"}