{"id":15637200,"url":"https://github.com/tenderlove/uart","last_synced_at":"2025-08-24T06:38:20.504Z","repository":{"id":55070768,"uuid":"117595667","full_name":"tenderlove/uart","owner":"tenderlove","description":"Simple serial / UART interface for Ruby","archived":false,"fork":false,"pushed_at":"2024-03-25T19:22:59.000Z","size":9,"stargazers_count":115,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-01T11:54:54.993Z","etag":null,"topics":["ruby","serial-communication","serialport","uart"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/tenderlove.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":"2018-01-15T21:09:07.000Z","updated_at":"2025-07-22T11:42:23.000Z","dependencies_parsed_at":"2024-10-23T04:06:14.933Z","dependency_job_id":null,"html_url":"https://github.com/tenderlove/uart","commit_stats":{"total_commits":7,"total_committers":4,"mean_commits":1.75,"dds":0.5714285714285714,"last_synced_commit":"d3facf9c93dd4705d9e1af86096f6d113b3b2a45"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tenderlove/uart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenderlove%2Fuart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenderlove%2Fuart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenderlove%2Fuart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenderlove%2Fuart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tenderlove","download_url":"https://codeload.github.com/tenderlove/uart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tenderlove%2Fuart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271808993,"owners_count":24825627,"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-08-24T02:00:11.135Z","response_time":111,"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":["ruby","serial-communication","serialport","uart"],"created_at":"2024-10-03T11:10:44.549Z","updated_at":"2025-08-24T06:38:20.479Z","avatar_url":"https://github.com/tenderlove.png","language":"Ruby","readme":"# UART\n\n* https://github.com/tenderlove/uart\n\n## DESCRIPTION:\n\nUART is a simple wrapper around the ruby-termios gem that gives you an easy\ninterface for setting up a UART or serial connection.  This gem is written in\npure Ruby.  This gem relies on ruby-termios to provide bindings to the termios\nsystem call, but uses those bindings to set up a serial connection in pure Ruby.\n\n## FEATURES/PROBLEMS:\n\n* No C code\n* No FFI code\n* Seems to work\n\n## SYNOPSIS:\n\nHere is an example of writing to an LCD screen over UART.  The speed is 9600,\n8 data bits, no parity, and one stop bit:\n\n```ruby\nrequire 'uart'\n\nUART.open '/dev/tty.usbserial-00000000' do |serial|\n  str = 'Hello World!'\n  serial.write [0x8A, 0xA8, 0x00, 0x00, str.bytesize].pack 'C5'\n  serial.write str.b\n  p serial.read(4).unpack('C4').map { |x| x.to_s(16) }\nend\n```\n\nMHZ-19B CO2 sensor for Raspberry Pi\n* http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf\n```ruby\nrequire 'uart'\n\na = UART.open('/dev/ttyAMA0') { |s| s.write(\"\\xFF\\x01\\x86\\x00\\x00\\x00\\x00\\x00\\x79\"); s.read(9).unpack('C9')}\n{ temp: a[4] - 40, co2: a[2] * 256 + a[3] } if 256 - a[1..7].reduce(\u0026:+)%256 == a[8]\n```\n\nPlantower Particle Sensor\n* https://cdn-shop.adafruit.com/product-files/3686/plantower-pms5003-manual_v2-3.pdf\n```ruby\nrequire 'uart'\nrequire 'io/wait'\n\nclass Sample \u003c Struct.new(:time,\n                          :pm1_0_standard, :pm2_5_standard, :pm10_standard,\n                          :pm1_0_env,      :pm2_5_env,\n                          :concentration_unit,\n                          :particle_03um,   :particle_05um,   :particle_10um,\n                          :particle_25um,   :particle_50um,   :particle_100um)\nend\n\nuart = UART.open ARGV[0], 9600, '8N1'\n\np Sample.members # header\n\nloop do\n  uart.wait_readable\n  start1, start2 = uart.read(2).bytes\n\n  # According to the data sheet, packets always start with 0x42 and 0x4d\n  unless start1 == 0x42 \u0026\u0026 start2 == 0x4d\n    # skip a sample\n    uart.read\n    next\n  end\n\n  length = uart.read(2).unpack('n').first\n  data = uart.read(length)\n  crc  = 0x42 + 0x4d + 28 + data.bytes.first(26).inject(:+)\n  data = data.unpack('n14')\n\n  next unless crc == data.last # crc failure\n\n  p Sample.new(Time.now.utc, *data.first(12)).to_a\nend\n```\n\n[Flipper Zero client](https://gist.github.com/knowtheory/1fd9e05a48c182177c7ad73e8bfaa4cf) (thanks to Ted Han!!)\n\n```ruby\nrequire 'uart'\n\n# find your flipper zero device handle: https://docs.flipper.net/development/cli#rnDLl\nfname = ARGV.shift # provide the path to your flipper zero\nraise \"Please specify a device to open\" if fname.nil?\nraise \"Couldn't find #{fname}\" unless File.exist?(fname)\n\n# open the flipper and specify the correct baud\nUART.open fname, 115200 do |flipper|\n    # read \u0026 print the Flipper Zero terminal art\n    puts flipper.read\n\n    # input command, or \"help\" if no command is supplied\n    message = ARGV.join(\" \") || \"help\"\n    flipper.write \"#{message}\\r\\n\" # flipper cli uses \\r\\n to terminate lines.\n    # read \u0026 print message output\n    puts flipper.read\nend\n```\n\n## REQUIREMENTS:\n\n* ruby-termios\n\n## INSTALL:\n\n* `gem install uart`\n\n## LICENSE:\n\n(The MIT License)\n\nCopyright (c) Aaron Patterson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenderlove%2Fuart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftenderlove%2Fuart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftenderlove%2Fuart/lists"}