{"id":35016831,"url":"https://github.com/tonybaltovski/ros2_linux_hardware","last_synced_at":"2026-04-25T13:33:51.756Z","repository":{"id":77651384,"uuid":"246225998","full_name":"tonybaltovski/ros2_linux_hardware","owner":"tonybaltovski","description":"ROS 2 linux hardware interface, hardware devices and hardware and ","archived":false,"fork":false,"pushed_at":"2026-03-28T02:33:06.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-28T08:38:06.966Z","etag":null,"topics":["i2c","lcm1602","raspberry-pi","ros2"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonybaltovski.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-03-10T06:36:22.000Z","updated_at":"2025-04-29T18:48:26.000Z","dependencies_parsed_at":"2023-02-27T14:30:37.311Z","dependency_job_id":null,"html_url":"https://github.com/tonybaltovski/ros2_linux_hardware","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tonybaltovski/ros2_linux_hardware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybaltovski%2Fros2_linux_hardware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybaltovski%2Fros2_linux_hardware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybaltovski%2Fros2_linux_hardware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybaltovski%2Fros2_linux_hardware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonybaltovski","download_url":"https://codeload.github.com/tonybaltovski/ros2_linux_hardware/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybaltovski%2Fros2_linux_hardware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32264427,"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":["i2c","lcm1602","raspberry-pi","ros2"],"created_at":"2025-12-27T05:23:53.913Z","updated_at":"2026-04-25T13:33:51.743Z","avatar_url":"https://github.com/tonybaltovski.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ros2_linux_hardware\n\nROS 2 packages for interacting with I2C hardware on Linux (tested on Raspberry Pi 4).\n\n## Packages\n\n| Package | Description |\n|---------|-------------|\n| `linux_i2c_interface` | Thread-safe C++ wrapper around the Linux I2C `/dev` interface. |\n| `linux_i2c_devices` | Device drivers built on the interface — LCM1602 LCD, SSD1306 OLED, and PCA9685 PWM controller. |\n| `linux_i2c_demos` | Example ROS 2 nodes that use the device drivers. |\n\n## Supported Devices\n\n- **LCM1602** — HD44780-compatible character LCD via PCF8574 I2C expander (default address `0x27`)\n- **SSD1306** — 128×64 monochrome OLED display (default address `0x3C`)\n- **PCA9685** — 16-channel, 12-bit PWM/LED controller (default address `0x40`)\n\n## Raspberry Pi 4 Setup (Ubuntu Server + ROS 2 Jazzy)\n\n### 1. Flash Ubuntu Server\n\n1. Download [Ubuntu Server 24.04 LTS (64-bit)](https://ubuntu.com/download/raspberry-pi) for Raspberry Pi.\n2. Flash the image to a microSD card using the [Raspberry Pi Imager](https://www.raspberrypi.com/software/) or `dd`.\n3. Boot the Pi and complete first-login setup (default user `ubuntu`, password `ubuntu`).\n\n### 2. Enable I2C\n\nThe Raspberry Pi's I2C bus is disabled by default. Enable it by adding a device-tree overlay:\n\n```bash\n# Edit the firmware config\nsudo nano /boot/firmware/config.txt\n```\n\nAdd (or uncomment) the following line under `[all]`:\n\n```\ndtparam=i2c_arm=on\n```\n\nThen reboot:\n\n```bash\nsudo reboot\n```\n\nAfter reboot, verify the bus exists:\n\n```bash\nls /dev/i2c-*\n# Expected: /dev/i2c-1\n```\n\n### 3. Install I2C Tools and Libraries\n\n```bash\nsudo apt update\nsudo apt install -y i2c-tools libi2c-dev\n```\n\nThese are ROS deps but are needed prior to look for devices on the I2C bus.\n\nGrant your user permission to access the I2C bus without `sudo`:\n\n```bash\nsudo usermod -aG i2c $USER\n```\n\nLog out and back in (or reboot) for the group change to take effect.\n\nA udev rule is included in [`linux_i2c_interface/debian/udev`](linux_i2c_interface/debian/udev).\nWhen building from source, install it manually:\n\n```bash\nsudo cp linux_i2c_interface/debian/udev /etc/udev/rules.d/60-linux-i2c-interface.rules\nsudo udevadm control --reload-rules \u0026\u0026 sudo udevadm trigger\n```\n\nScan for connected devices to verify your wiring:\n\n```bash\ni2cdetect -y 1\n```\n\nYou should see the addresses of any connected devices (e.g. `27` for the LCD, `40` for the PCA9685).\n\n### 4. Create a Workspace and Build\n\n```bash\nmkdir -p ~/ros2_ws/src\ncd ~/ros2_ws/src\ngit clone https://github.com/tonybaltovski/ros2_linux_hardware.git\n\n# Install any missing rosdep dependencies\nsudo rosdep init  # only needed once\nrosdep update\nrosdep install --from-paths . --ignore-src -y\n\n# Build\ncd ~/ros2_ws\ncolcon build --symlink-install\nsource install/setup.bash\n```\n\n### 5. Wiring\n\n#### LCM1602 LCD (I2C address 0x27)\n\n| LCD Pin | Pi Pin     |\n|---------|------------|\n| GND     | GND (Pin 6) |\n| VCC     | 5V (Pin 2)  |\n| SDA     | GPIO 2 / SDA1 (Pin 3) |\n| SCL     | GPIO 3 / SCL1 (Pin 5) |\n\n#### SSD1306 OLED (I2C address 0x3C)\n\n| OLED Pin | Pi Pin     |\n|----------|------------|\n| GND      | GND (Pin 6) |\n| VCC      | 3.3V (Pin 1) |\n| SDA      | GPIO 2 / SDA1 (Pin 3) |\n| SCL      | GPIO 3 / SCL1 (Pin 5) |\n\n#### PCA9685 PWM Board (I2C address 0x40)\n\n| PCA9685 Pin | Pi Pin     |\n|-------------|------------|\n| GND         | GND (Pin 6) |\n| VCC         | 3.3V (Pin 1) |\n| SDA         | GPIO 2 / SDA1 (Pin 3) |\n| SCL         | GPIO 3 / SCL1 (Pin 5) |\n| V+          | External servo power supply (5–6V) |\n\n\u003e **Note:** The PCA9685 V+ terminal is for the servo power rail and must be connected\n\u003e to an external supply — do **not** power servos from the Pi's 5V pin.\n\n## Running the Demos\n\n### Screen — Display String Messages\n\nA single node supports both the LCM1602 LCD and SSD1306 OLED, selected via the\n`display_type` parameter.\n\n**LCM1602 LCD (default):**\n\n```bash\nros2 run linux_i2c_demos screen_from_str_topic\n```\n\n**SSD1306 OLED:**\n\n```bash\nros2 run linux_i2c_demos screen_from_str_topic --ros-args -p display_type:=ssd1306\n```\n\nParameters:\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `display_type` | `lcm1602` | `lcm1602` or `ssd1306` |\n| `i2c_bus` | `1` | I2C bus number |\n| `device_id` | `0x27` (lcm1602) / `0x3C` (ssd1306) | 7-bit I2C address |\n| `rows` | `4` | Number of LCD rows (lcm1602 only) |\n| `columns` | `20` | Number of LCD columns (lcm1602 only) |\n\nPublish a message to the display:\n\n```bash\nros2 topic pub /screen_from_str_topic/input std_msgs/msg/String \"{data: 'Hello, Pi!'}\"\n```\n\n### Screen — Display ROS Log Output\n\n```bash\nros2 run linux_i2c_demos screen_rosout_logger\n```\n\nUses the same `display_type`, `i2c_bus`, `device_id`, `rows`, and `columns`\nparameters as the string-topic node above.  An additional parameter controls the\nminimum severity:\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `min_logger_level` | `20` (INFO) | Minimum `rcl_interfaces/Log` level to display |\n\nAll log messages at or above the configured level from any node will scroll\nupward on the screen.\n\n### PCA9685 — Servo Control\n\n```bash\nros2 run linux_i2c_demos pca9685_servo_control\n```\n\nParameters (set via `--ros-args -p`):\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `i2c_bus` | `1` | I2C bus number |\n| `device_id` | `0x40` | PCA9685 I2C address |\n| `pwm_frequency` | `50.0` | PWM frequency in Hz |\n\nSend servo duty-cycle commands (one value per channel, 0.0–1.0):\n\n```bash\n# Centre a servo on channel 0 (1.5 ms pulse at 50 Hz ≈ 0.075 duty cycle)\nros2 topic pub /pca9685_servo_control/servo_commands \\\n  std_msgs/msg/Float64MultiArray \"{data: [0.075]}\"\n\n# Drive channels 0, 1, and 2 to different positions\nros2 topic pub /pca9685_servo_control/servo_commands \\\n  std_msgs/msg/Float64MultiArray \"{data: [0.025, 0.075, 0.125]}\"\n```\n\nFor standard hobby servos at 50 Hz:\n- **~0.025** (0.5 ms) → full left\n- **~0.075** (1.5 ms) → centre\n- **~0.125** (2.5 ms) → full right\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| `Could not open: /dev/i2c-1` | Ensure I2C is enabled in `/boot/firmware/config.txt` and reboot. |\n| `Permission denied` on `/dev/i2c-1` | Add your user to the `i2c` group: `sudo usermod -aG i2c $USER` and re-login. |\n| `i2cdetect` shows no devices | Check wiring — SDA/SCL may be swapped, or the device may need a pull-up resistor. |\n| SSD1306 screen is blank after init | Ensure you call `display()` (the node does this automatically via `print_msg`). Verify address with `i2cdetect`. |\n| `Failed to set device` | Verify the device address with `i2cdetect -y 1` and update the `device_id` parameter. |\n| PCA9685 servos don't move | Ensure external power is connected to the V+ terminal on the PCA9685 board. |\n\n## License\n\nApache 2.0 — see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonybaltovski%2Fros2_linux_hardware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonybaltovski%2Fros2_linux_hardware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonybaltovski%2Fros2_linux_hardware/lists"}