{"id":16607578,"url":"https://github.com/ho-ro/openmetra","last_synced_at":"2025-10-11T10:46:35.064Z","repository":{"id":154716508,"uuid":"454902869","full_name":"Ho-Ro/OpenMetra","owner":"Ho-Ro","description":"Remote control for multimeter Gossen METRAHit 29S via BD232 serial interface","archived":false,"fork":false,"pushed_at":"2022-10-17T20:26:51.000Z","size":186,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T04:07:49.543Z","etag":null,"topics":["gossen","metrahit","multimeter","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ho-Ro.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-02-02T19:06:24.000Z","updated_at":"2022-02-16T08:35:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d3f436c-6d29-46b8-9e69-2c6e153fc8d0","html_url":"https://github.com/Ho-Ro/OpenMetra","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ho-Ro/OpenMetra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FOpenMetra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FOpenMetra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FOpenMetra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FOpenMetra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ho-Ro","download_url":"https://codeload.github.com/Ho-Ro/OpenMetra/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ho-Ro%2FOpenMetra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006867,"owners_count":26084208,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["gossen","metrahit","multimeter","python"],"created_at":"2024-10-12T01:23:12.528Z","updated_at":"2025-10-11T10:46:35.031Z","avatar_url":"https://github.com/Ho-Ro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenMetra\n\n![METRAHit 29s](METRAHit29s.png)\n![BD232](BD232.png)\n![MetraPlot result](temperature_256x192.png)\n\nReceives data from a multimeter Gossen METRAHit 29S via BD232 serial interface.\n\nTested with FTDI and similar RS232 USB serial interfaces to \"/dev/ttyUSB0\" (linux).\n\nShould also work for Windows with e.g. serial_device=\"COM8\".\n\nActivate the transmission on the instrument with: 'SEt v SEnd \u003c-/ OFF v on \u003c-/',\nor at switch-on by depressing **DATA/CLEAR** and **ON** button together.\nRate of data beeing sent can be set in the meter's menu with the item 'rAtE'.\n\n\n## Hardware\n\nGet [info and documents](https://www.gossenmetrawatt.com/english/produkte/metrahit29s.htm)\nfrom [gossenmetrawatt.com](https://www.gossenmetrawatt.com/).\n\n\n## Software\n\nAccess to the multimeter and decoding of the received data is done in the OpenMetra class.\nJust add the directory `openmetra` to your project and you're done.\nSwitch the meter to transmit mode (press **DATA/CLEAR** and **ON** together) and retrieve the data with this simple program:\n\n```python\n#!/usr/bin/python\n\nimport sys\n\nfrom openmetra import OpenMetra\n\nwith OpenMetra() as mh: # open connection to '/dev/ttyUSB0', the serial path can be an optional parameter\n    if mh is None:      # could not connect\n        print( 'connect error', file=sys.stderr)\n        sys.exit()\n    while True:                             # run forever, stop with ^C\n        try:\n            print( mh.get_measurement() )   # print numeric value\n        except KeyboardInterrupt:           # ^C pressed, stop measurement\n            print()\n            break                           # exit\n```\n\nThe provided program [Metra](https://github.com/Ho-Ro/OpenMetra/blob/main/Metra)\nallows to customize the received date with some options:\n\n````\nusage: Metra [-h] [-c] [-d SERIAL_DEVICE] [-f] [-g] [-n NUMBER] [-o] [-O] [-r RATE]\n             [-s SECONDS] [-t] [-T TIMEOUT] [-u] [-U] [-v] [-V]\n\nGet data from Gossen METRAHit 29S\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -c, --csv             create csv (together with -t and/or -u)\n  -d SERIAL_DEVICE, --device SERIAL_DEVICE\n                        device path of serial interface, default is \"/dev/ttyUSB0\"\n  -f, --format_values   print formatted values (instead of as shown on meter)\n  -g, --german          use comma as decimal separator, semicolon as field separator\n  -n NUMBER, --number NUMBER\n                        get NUMBER measurement values\n  -o, --on-off          switch meter on, select send mode and rate and switch off after\n                        measurement\n  -O, --overload        print OL values as \"None\" instead of skipping\n  -r RATE, --rate RATE  select index for measurement rate: 0:50ms, 1:0.1s, 2:0.2s, 3:0.5s,\n                        4:1s, 5:2s, 6:5s, 7:10s, 8:20s, 9:30s, 10:1min, 11:2min, 12:5min,\n                        13:10min, default: 4 (1s)\n  -s SECONDS, --seconds SECONDS\n                        measure for a duration of SECONDS\n  -t, --timestamp       print timestamp for each value\n  -T TIMEOUT, --timeout TIMEOUT\n                        set timeout for serial port\n  -u, --unit            print unit of measured value\n  -U, --unit_long       print unit of measured value with explanation, e.g. AC, DC, etc\n  -v, --version         show openmetra version\n  -V                    increase verbosity\n````\n\nThe program [MetraPlot](https://github.com/Ho-Ro/OpenMetra/blob/main/MetraPlot)\ndisplays the measured data nicely:\n\n````\nusage: MetraPlot [-h] [-t TITLE] [-f FIRST_SAMPLE] [-l LAST_SAMPLE] [-V] [infile]\n\nPlot data - e.g. received from Gossen METRAHit 29S via program 'Metra'\n\npositional arguments:\n  infile                read measurement data from optional infile, use stdin otherwise\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -t TITLE, --title TITLE\n                        set the title of the plot, default is 'MetraPlot'\n  -f FIRST_SAMPLE, --first_sample FIRST_SAMPLE\n                        first sample to display\n  -l LAST_SAMPLE, --last_sample LAST_SAMPLE\n                        last sample to display\n  -V                    increase verbosity\n````\n\n![MetraPlot result](temperature_640x480.png)\n\nThe program [MetraSwitch](https://github.com/Ho-Ro/OpenMetra/blob/main/MetraSwitch)\nswitches the instrument on and selects send mode or selects the measurement function or switches the intrument off:\n\n````\nusage: MetraSwitch [-h] [-d DEVICE] [--off | --function FUNCTION | --rate RATE | --set_rtc]\n                   [-v] [-V]\n\nGossen METRAHit 29S: switch off or select function or select data rate or set RTC time and\ndate. Without specifying an action the meter is just switched on.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -d DEVICE, --device DEVICE\n                        device path of serial interface, default is \"/dev/ttyUSB0\"\n  --off                 switch the device off\n  --function FUNCTION   select measurement function: 1:V_DC, 2:V_ACDC, 3:V_AC, 4:mA_DC,\n                        5:mA_ACDC, 6:A_DC, 7:A_ACDC, 8:Ohm, 9:F, 10:dB, 11:Hz_Uacdc,\n                        12:Hz_Uac, 17:Ohm buzzer, 18:Temp, 22:pulseW, 23TRMS_mains,\n                        24:Counter, 25:Events_Uacdc, 26:Events_Uac\n  --rate RATE           select index of measurement rate: 0:50ms, 1:0.1s, 2:0.2s, 3:0.5s,\n                        4:1s, 5:2s, 6:5s, 7:10s, 8:20s, 9:30s, 10:1min, 11:2min, 12:5min,\n                        13:10min\n  --set_rtc             set meter RTC time and date from local time\n  -v, --version         show openmetra version\n  -V                    increase verbosity\n````\n\n\n### Building and Installing a Debian Package\n\nThe provided [Makefile](https://github.com/Ho-Ro/OpenMetra/blob/main/Makefile) allows to build a Debian package,\njust type `make`. `make distclean` removes all created data to prepare for a new clean build.\nYou need to install python3-stdeb, the Python to Debian source package conversion plugins for distutils.\nAfter success the package is available as `openmetra_*_all.deb`.\nYou can do a clean install (as root) with `dpkg -i openmetra_*_all.deb`, the python module `openmetra` is put into\nthe python3 library path, the scripts `Metra*` are copied into `/usr/bin`. `dpkg -P openhantek` does a clean uninstall.\nIt is also possible to build an (experimental) rpm package with `make rpm` as `openmetra-*.noarch.rpm`.\n\n## Protocol Definition:\n\nThe instrument sends the data blocks with 9600 Bd, 8 bits + Start + Stop bit (only lower 6 bits are used).\n\n### Fast Mode\n\nTM1a) Measured data with fast rate (rate 50 ms, V_DC, A_DC only)\n````\n-----------------------------------------------\n|Byte| Output unit Bit0..Bit3       |Bit5|Bit4|\n|----|------------------------------|----|----|\n|  1 | Measuring range, sign        |  0 |  1 |\n|  2 | Units                        |  1 |  1 |\n|  3 | Tens                         |  1 |  1 |\n|  4 | Hundreds                     |  1 |  1 |\n|  5 | Thousands                    |  1 |  1 |\n|  6 | TenThousands                 |  1 |  1 |\n-----------------------------------------------\n````\n\nTM1b) Instruments setting with fast rate (sent at lower rate of ~ 500 ms)\n````\n-----------------------------------------------\n|Byte| Output unit Bit0..Bit3       |Bit5|Bit4|\n|----|------------------------------|----|----|\n|  1 | Device code, 1110 is 29s     |  0 |  0 |\n|  2 | Curr. type, meas. variable 1 |  1 |  1 |\n|  3 | Special character 1          |  1 |  1 |\n|  4 | Special character 2          |  1 |  1 |\n|  5 | Measuring range, sign 1      |  1 |  1 |\n-----------------------------------------------\n````\n\n### Slow Mode\n\nTM2) Ranges: V AC, V AC+DC, I AC+DC, Ohm, Ohm with buzzer, F, Hz , Temp., dB,\nV-diode, V-diode with buzzer, Events, Counter, Mains analysis and Power.\nAlso V DC, A DC and functions when send interval \u003e50 ms.\n````\n-----------------------------------------------\n|Byte| Output unit Bit0..Bit3       |Bit5|Bit4|\n|----|------------------------------|----|----|\n|  1 | Device code, 1110 is 29s     |  0 |  0 |\n|  2 | Curr. type, meas. variable 1 |  1 |  1 |\n|  3 | Special character 1          |  1 |  1 |\n|  4 | Special character 2          |  1 |  1 |\n|  5 | Measuring range, sign        |  1 |  1 |\n|  6 | Units                        |  1 |  1 |\n|  7 | Tens                         |  1 |  1 |\n|  8 | Hundreds                     |  1 |  1 |\n|  9 | Thousands                    |  1 |  1 |\n| 10 | TenThousands                 |  1 |  1 |\n| 11 | HundredThousands             |  1 |  1 |\n| 12 | Curr. type, meas. variable 2 |  1 |  1 |\n| 13 | Send interval                |  1 |  1 |\n-----------------------------------------------\n````\n29S: In case of power measurement there are sent 3 of these blocks\nwith delay 200 ms in order power - W, voltage - V, current - A.\n\n### Function Encoding\n\nThe meter's function is transmitted in `Current type measuring variable 1` (fast mode)\nor `Current type measuring variable 1` and `Current type measuring variable 2` for slow mode.\nThes values were verified with my METRAHit 29s:\nTM3b) Measurement function encoding (also TF)\n````\n-------------------------------------------------\n| Function  | Variable2 | Variable1 |   Index   |\n|-----------+-----------+-----------+-----------|\n|    -      |   0000    |   0000    |      0    |\n|  V DC     |   0000    |   0001    |      1    |\n|  V ACDC   |   0000    |   0010    |      2    |\n|  V AC     |   0000    |   0011    |      3    |\n| mA DC     |   0000    |   0100    |      4    |\n| mA ACDC   |   0000    |   0101    |      5    |\n|  A DC     |   0000    |   0110    |      6    |\n|  A ACDC   |   0000    |   0111    |      7    |\n|-----------+-----------+-----------+-----------|\n|  kOhm     |   0000    |   1000    |      8    |\n|  Farad    |   0000    |   1001    |      9    |\n|  dBV      |   0000    |   1010    |     10    |\n|  Hz UACDC |   0000    |   1011    |     11    |\n|  Hz UAC   |   0000    |   1100    |     12    |\n|  W (mA)   |   0000    |   1101    |     13    |\n|  W (A)    |   0000    |   1110    |     14    |\n|  Diode    |   0000    |   1111    |     15    |\n|-----------+-----------+-----------+-----------|\n| Dio buzz  |   0001    |   0000    |     16    |\n| kOhm buzz |   0001    |   0001    |     17    |\n|  Temp     |   0001    |   0010    |     18    |\n|    -      |   0001    |   0011    |     19    |\n|    -      |   0001    |   0100    |     20    |\n|    -      |   0001    |   0101    |     21    |\n|    -      |   0001    |   0110    |     22    |\n|    -      |   0001    |   0111    |     23    |\n|-----------+-----------+-----------+-----------|\n|    -      |   0001    |   1000    |     24    |\n|    -      |   0001    |   1001    |     25    |\n|    -      |   0001    |   1010    |     26    |\n| mA (W)    |   0001    |   1011    |     27    |\n|  A (W)    |   0001    |   1100    |     28    |\n|  V (W)    |   0001    |   1101    |     29    |\n|  V DC     |   0001    |   1110    |     30    |\n|  V DC     |   0001    |   1111    |     31    |\n-------------------------------------------------\n````\n\n- See also:\nhttps://www.mikrocontroller.net/attachment/22868/22SM-29S_Interface_Protocol1.pdf\nand\nhttps://github.com/sigrokproject/libsigrok/blob/master/src/hardware/gmc-mh-1x-2x/protocol.c\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-ro%2Fopenmetra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fho-ro%2Fopenmetra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fho-ro%2Fopenmetra/lists"}