{"id":16977367,"url":"https://github.com/mryslab/pymata_rh","last_synced_at":"2026-04-04T06:07:36.024Z","repository":{"id":62581624,"uuid":"268871949","full_name":"MrYsLab/pymata_rh","owner":"MrYsLab","description":"Python API Library for RoboHat MM1","archived":false,"fork":false,"pushed_at":"2021-04-29T15:35:10.000Z","size":5637,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T20:49:53.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrYsLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-02T17:57:24.000Z","updated_at":"2023-05-08T20:29:46.000Z","dependencies_parsed_at":"2022-11-03T21:21:26.769Z","dependency_job_id":null,"html_url":"https://github.com/MrYsLab/pymata_rh","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpymata_rh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpymata_rh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpymata_rh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrYsLab%2Fpymata_rh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrYsLab","download_url":"https://codeload.github.com/MrYsLab/pymata_rh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248504757,"owners_count":21115203,"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":[],"created_at":"2024-10-14T01:28:48.195Z","updated_at":"2026-04-04T06:07:35.997Z","avatar_url":"https://github.com/MrYsLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is pymata_rh? \n\n[Pymata_rh](https://github.com/MrYsLab/pymata_rh) is a Python 3 (Version 3.7 or above)  [Application Programming \nInterface (API).](https://htmlpreview.github.io/?https://github.com/MrYsLab/pymata_rh/blob/master/html/pymata_rh/index.html)\nIt is Windows, macOS and, Linux compatible, allowing you to easily create Python scripts to control and monitor the \n[Robo HAT MM1.](https://www.roboticsmasters.co/pages/robo-hat-mm1/)\n\n## Robot HAT MM1 Pin Names To Pin Number Map And Supported Pin Modes\n\n**MM1 Pin Name**|**Digital / Analog Pin #**|**Digital Input**|**Digital Output**|**PWM**|**Analog Input**\n:-----:|:-----:|:-----:|:-----:|:-----:|:-----:\nServo1|2|Yes|Yes|Yes|No\nServo2|3|Yes|Yes|Yes|No\nServo3|4|Yes|Yes|No|No\nServo4|5|Yes|Yes|No|No\nServo5|6|Yes|Yes|Yes|No\nServo6|7|Yes|Yes|Yes|No\nServo7|8|Yes|Yes|Yes|No\nServo8|9|Yes|Yes|Yes|No\nNeoPixel |11|Yes|Yes|Yes|No      \nLED      | 13|No|Yes|No|No\nRCC1     | 14 / A0 |Yes|Yes|No|Yes\nRCC2     | 15 / A1 |Yes|Yes|No|Yes\nRCC3     | 16 / A2 |Yes|Yes|No|Yes\nRCC4     | 17 / A3 |Yes|Yes|No|Yes\n\n### NOTES:\n* All digital pins support digital input pull-up mode.\n* All analog input pins may be configured as digital inputs or outputs as well.\n* Currently, there is no library support provided within pymata_rh to control NeoPixels. However, the pin may be used as a digital pin.\n\n## API Support\nThe API not only supports the pins and modes listed above, but the pymata_rh API also\nprovides support for:\n\n* Servo motors.\n* The onboard INA219 current, shunt, and power monitor.\n* The onboard MPU9250 nine-axis motion tracking device.\n* External i2c devices. \n* DHT 11 and 22 temperature sensors.\n* HC-SR04 sonar distance sensors.\n\n**NOTE: ** You may need to connect a power supply that provides adequate current capacity for your application.\n\n**A Demo GUI is included**. After installing pymata-rh, open a terminal window and type: rhdemo\n\nUse the GUI to control the RoboHAT without writing one line of code!\n\n![](https://github.com/MrYsLab/pymata_rh/blob/master/docs/images/tkgui.png)\n\n## Implemented Using The Firmata Protocol\n\nThe API is implemented using the\n [Firmata protocol](https://github.com/firmata/protocol) in conjunction with FirmataExpress,\ncustom firmware you install on the Robo HAT MM1.\nCommunication between the Python script and the Robo HAT MM1 is accomplished over a serial link at 115200 baud.\n\n\n### A [User's Guide is available,](https://mryslab.github.io/pymata_rh/index.html) containing an annotated API as well as links to working examples.\n\n\n## Major features\n\n* **Fully documented \u003ca href=\"https://htmlpreview.github.io/?https://github.com/MrYsLab/pymata_rh/blob/master/html/pymata_rh/index.html\" target=\"_blank\"\u003eintuitive API\u003c/a\u003e**\n\n\n* **Python 3.7+ compatible.**\n\n* **Set the pin mode and go!**\n\n* **Data change events may be associated with a callback function, or each pin can be polled for its last event change.**\n\n    * **Each data change event is time-stamped and logged.**\n\n\nHere is an example that demonstrates receiving asynchronous digital pin state data change notifications for pin 2 using\n callback notifications.\n\nThe API is quite simple to use. Here are the steps involved in creating a simple application.\n\n1. Set a pin mode for the pin and register a callback function.\n2. Have your application sit in a loop waiting for notifications.\n    \nWhen pymata_rh executes the callback method you specified, the data parameter is populated with \na list of items that describe the change event, including a time-stamp.\n\n\n```python\nfrom pymata_rh import pymata_rh\nimport time\n\nclass DigitalInput:\n    \"\"\"\n    Set a pin for digital input and received all data changes\n    in the callback method\n    \"\"\"\n    def __init__(self, pin):\n        \"\"\"\n        Set a pin as a digital input\n        :param pin: digital pin number\n        \"\"\"\n\n        # Indices into the callback report data\n        self.CB_PIN_MODE = 0\n        self.CB_PIN = 1\n        self.CB_VALUE = 2\n        self.CB_TIME = 3\n\n        # Instantiate this class with the pymata_rh API\n        self.device = pymata_rh.PymataRh()\n\n        # Set the pin mode and specify the callback method.\n        self.device.set_pin_mode_digital_input(pin, callback=self.the_callback)\n\n        # Keep the program running and wait for callback events.\n        while True:\n            try:\n                time.sleep(1)\n            # If user hits Control-C, exit cleanly.\n            except KeyboardInterrupt:\n                self.device.shutdown()\n\n    def the_callback(self, data):\n        \"\"\"\n        A callback function to report data changes.\n        This will print the pin number, its reported value\n        the pin type (digital, analog, etc.) and\n        the date and time when the change occurred\n\n        :param data: [pin, current reported value, pin_mode, timestamp]\n        \"\"\"\n        # Convert the date stamp to readable format\n        date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data[self.CB_TIME]))\n\n        # Print the pin, current value and time and date of the pin change event.\n        print(f'Pin: {data[self.CB_PIN]} Value: {data[self.CB_VALUE]} Time Stamp: {date}')\n\nif __name__ == '__main__':\n    # Monitor Pin 2 For Digital Input changes\n    DigitalInput(2)\n\n```\n\nSample console output as input change events occur:\n```bash\nPin: 2 Value: 0 Time Stamp: 2020-03-10 13:26:22\nPin: 2 Value: 1 Time Stamp: 2020-03-10 13:26:27\n```\n\n\n\nThis project was developed with [Pycharm](https://www.jetbrains.com/pycharm/?from=pymata4) ![logo](https://github.com/MrYsLab/python_banyan/blob/master/images/icon_PyCharm.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmryslab%2Fpymata_rh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmryslab%2Fpymata_rh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmryslab%2Fpymata_rh/lists"}