{"id":15043636,"url":"https://github.com/cgxeiji/max3010x","last_synced_at":"2026-01-27T21:14:48.116Z","repository":{"id":53165355,"uuid":"292497568","full_name":"cgxeiji/max3010x","owner":"cgxeiji","description":"Go library to use the MAX3010x family of sensors for heart rate and SpO2 readings.","archived":false,"fork":false,"pushed_at":"2021-04-15T07:05:33.000Z","size":1809,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T18:30:23.357Z","etag":null,"topics":["go","golang","heart-rate","max30102","raspberry-pi","spo2"],"latest_commit_sha":null,"homepage":"","language":"Go","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/cgxeiji.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}},"created_at":"2020-09-03T07:25:03.000Z","updated_at":"2022-06-27T03:23:28.000Z","dependencies_parsed_at":"2022-09-26T18:31:28.752Z","dependency_job_id":null,"html_url":"https://github.com/cgxeiji/max3010x","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fmax3010x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fmax3010x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fmax3010x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgxeiji%2Fmax3010x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgxeiji","download_url":"https://codeload.github.com/cgxeiji/max3010x/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245858884,"owners_count":20684062,"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":["go","golang","heart-rate","max30102","raspberry-pi","spo2"],"created_at":"2024-09-24T20:49:22.007Z","updated_at":"2026-01-27T21:14:48.064Z","avatar_url":"https://github.com/cgxeiji.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# max3010x\n\n[![Version](https://img.shields.io/github/v/tag/cgxeiji/max3010x?sort=semver)](https://github.com/cgxeiji/max3010x/releases)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/cgxeiji/max3010x)](https://pkg.go.dev/github.com/cgxeiji/max3010x)\n[![License](https://img.shields.io/github/license/cgxeiji/max3010x)](https://github.com/cgxeiji/max3010x/blob/master/LICENSE)\n![Go version](https://img.shields.io/github/go-mod/go-version/cgxeiji/max3010x)\n\nGo library to use the MAX3010x sensor for heart rate and SpO2 readings. Uses\n[periph.io](https://periph.io/) to handle I2C communication with the sensor.\n\n| :bangbang: | **This library has only been tested with a `MAX30102` on a `Raspberry Pi 4`. If you have a `MAX30100`, please help me with testing.** |\n| :---: | :--- |\n\n\n## TL;DR\n\nYou can download and build this test program:\n\n```sh\n$ go get github.com/cgxeiji/max3010x/max3010x\n$ max3010x\n```\n\n![demo.gif](./max3010x/demo.gif)\n\n## How to use?\n\nIt is as simple as:\n\n```go\nfunc main() {\n    sensor, err := max3010x.New()\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer sensor.Close()\n\n    // Detect the heart rate\n    hr, err := sensor.HeartRate()\n    if errors.Is(err, max3010x.ErrNotDetected) {\n        hr = 0\n    } else if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(\"Heart rate:\", hr)\n\n    // Detect the SpO2 level\n    spO2, err := sensor.SpO2()\n    if errors.Is(err, max3010x.ErrNotDetected) {\n        spO2 = 0\n    } else if err != nil {\n        log.Fatal(err)\n    }\n    fmt.Println(\"SpO2:\", spO2)\n}\n```\n\nTrying to read the heart rate or SpO2 values when the sensor is not in contact\nwith a person will return a `max3010x.ErrNotDetected` error. You are free to\nhandle this however you like.\n\n### Low-level interface\n\nIf you need to access specific functions of each sensor, or want to work with\nraw data, you can cast the `sensor` to the specific `device`:\n\n```go\nfunc main() {\n    sensor, err := max3010x.New()\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    defer sensor.Close()\n    device, err := sensor.ToMax30102()\n    if errors.Is(err, max3010x.ErrWrongDevice) {\n        fmt.Println(\"device is not MAX30102\")\n        return\n    } else if err != nil {\n        log.Fatal(err)\n    }\n\n    // Get the values for the IR and red LEDs.\n    ir, red, err := device.IRRed()\n    if err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n## Any questions or feedback?\n\n[Issues](https://github.com/cgxeiji/max3010x/issues/new) and\n[pull-requests](https://github.com/cgxeiji/max3010x/pulls) are welcomed!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgxeiji%2Fmax3010x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgxeiji%2Fmax3010x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgxeiji%2Fmax3010x/lists"}