{"id":19728750,"url":"https://github.com/swharden/ftdisharp","last_synced_at":"2026-03-05T18:04:09.180Z","repository":{"id":65572910,"uuid":"592554626","full_name":"swharden/FtdiSharp","owner":"swharden","description":"A .NET library for interfacing FTDI USB controller ICs","archived":false,"fork":false,"pushed_at":"2024-11-15T23:42:26.000Z","size":4408,"stargazers_count":38,"open_issues_count":2,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-26T14:12:59.579Z","etag":null,"topics":["fifo","ftdi","i2c","serial","spi","uart","usart","usb"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/FtdiSharp/","language":"C#","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/swharden.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":"2023-01-24T01:09:45.000Z","updated_at":"2025-07-10T01:39:08.000Z","dependencies_parsed_at":"2025-01-02T17:16:05.593Z","dependency_job_id":null,"html_url":"https://github.com/swharden/FtdiSharp","commit_stats":{"total_commits":99,"total_committers":1,"mean_commits":99.0,"dds":0.0,"last_synced_commit":"3130a05a07489b2d4ab0dd4d19f235a151f72de1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/swharden/FtdiSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2FFtdiSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2FFtdiSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2FFtdiSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2FFtdiSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swharden","download_url":"https://codeload.github.com/swharden/FtdiSharp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2FFtdiSharp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269803680,"owners_count":24477647,"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-10T02:00:08.965Z","response_time":71,"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":["fifo","ftdi","i2c","serial","spi","uart","usart","usb"],"created_at":"2024-11-12T00:07:37.641Z","updated_at":"2026-03-05T18:04:09.156Z","avatar_url":"https://github.com/swharden.png","language":"C#","readme":"# FtdiSharp\n\n[![CI](https://github.com/swharden/FtdiSharp/actions/workflows/ci.yaml/badge.svg)](https://github.com/swharden/FtdiSharp/actions/workflows/ci.yaml)\n\n**FtdiSharp is a .NET interface for FTDI USB controllers** that provides high-level tools for advanced communication protocols (I²C, SPI, and GPIO) and also supplies a copy of FTDI's official DLL wrapper to provide low-level control for advanced users.\n\n### Communicate _Directly_ With Sensors\n\nFtdiSharp aims to simplify the process of interfacing directly with sensors which communicate using I2C or SPI for FTDI chips which support these advanced protocols. **No microcontroller is required!** Connect your sensor directly to a compatible FTDI device and you can use FtdiSharp to easily control it and make readings. Pair FtdiSharp with with [ScottPlot](https://scottplot.net) to create real-time data visualization applications with only a few lines of code.\n\n![](https://raw.githubusercontent.com/swharden/FtdiSharp/main/dev/screenshots/i2c-connections.png)\n\n![](https://raw.githubusercontent.com/swharden/FtdiSharp/main/dev/screenshots/lm75a.png)\n\n### Intended Audience\n\n**Do not use FtdiSharp if your project only requires a USB serial port.** FtdiSharp is intended for applications which seek to use advanced communication protocols beyond serial UART and provide FTDI-specific actions like reading/writing chip serial numbers. If your project only requires a USB serial port, use [`System.IO.Ports`](https://learn.microsoft.com/en-us/dotnet/api/system.io.ports) which is simpler and officially supported on all operating systems.\n\n### Low-Level Driver Access\n\n**FtdiSharp provides access FTDI's FTD2XX_NET official DLL wrapper for advanced users.** FTDI's official source code has been refactored to break it into smaller files, improve XML documentation, and utilize modern language features. FtdiSharp targets .NET Framework 4.6.2 and .NET 6 so it can be used in .NET Framework and .NET Core environments.\n\n### Demo Application\n\n**This project comes with a demo app that shows how to directly interface several common sensors.** The FT232H can communicate directly with sensors using SPI and I²C, so no microcontroller is required. Unlike FTDI's official code samples (thousands of lines of spaghetti code, often in Visual Basic) the demo application in this project aims to demonstrate common I²C, SPI, and GPIO functionality with minimal complexity.\n\n![](https://raw.githubusercontent.com/swharden/FtdiSharp/main/dev/screenshots/demo.png)\n\nThe demo shows how to use FtdiSharp to interact with common sensors:\n* [LM75A](https://www.ti.com/lit/ds/symlink/lm75a.pdf) I²C temperature sensor and thermal watchdog\n* [BMP280](https://cdn-shop.adafruit.com/datasheets/BST-BMP280-DS001-11.pdf) I²C pressure sensor (0.02 PSI sensitivity)\n* [LIS3DH](https://www.st.com/resource/en/datasheet/cd00274221.pdf) I²C 3-axis accelerometer\n* [ADS1115](https://www.ti.com/lit/ds/symlink/ads1115.pdf) I²C 4-channel 16-bit ADC (860 samples per second)\n* [BH1750](https://www.mouser.com/datasheet/2/348/bh1750fvi-e-186247.pdf) I²C 16-bit ambient light sensor\n* [MCP3201](http://ww1.microchip.com/downloads/en/devicedoc/21290f.pdf) SPI 12-bit ADC (100k samples per second)\n* [HX710](https://image.micros.com.pl/_dane_techniczne_auto/uphx710b%20smd.pdf) SPI 21-bit ADC (40 samples per second)\n* [MCP3008](https://cdn-shop.adafruit.com/datasheets/MCP3008.pdf) SPI 4-channel 10-bit ADC (200k samples per second)\n* [ADS1220](https://www.ti.com/lit/ds/symlink/ads1220.pdf) SPI 4-channel 24-bit ADC (2k samples per second)\n\n![](https://raw.githubusercontent.com/swharden/FtdiSharp/main/dev/screenshots/adc-graph.gif)\n\n### USB Interactions Limit Update Rate\n\nWhile sensors may support thousands of reads per second, limitations of the USB protocol restrict how frequently FtdiSharp can request data updates from connected devices. The strategy demonstrated on this page is best for applications which only require updates a few times per second. Applications which require high-speed repeated measurements or precise timing should not interface a FTDI controller directly to their sensor, but instead use a high-speed microcontroller to manage the interaction.\n\n## Quickstart\n\n```cs\n// Show all USB FTDI devices attached to the system\nforeach (FtdiDevice device in FtdiDevices.Scan())\n    Console.WriteLine(device);\n```\n\n## SPI Protocol\n\nHigh level functions simplify communication with SPI devices for FTDI chips which support it (e.g., FT232H).\n\n### FT232H SPI Pinout\n\n* SCK: D0\n* MOSI: D1\n* MISO: D2\n* CS: D3\n\n### Interact with SPI Devices\n\nThis code reads voltage from a [MCP3201 ADC](https://www.mouser.com/pdfDocs/21290c-28774.pdf)\n\n```cs\n// Use the first USB FTDI device found\nFtdiDevice device = FtdiDevices.Scan().First();\nFtdiSharp.Protocols.SPI spi = new(device);\n\n// Pull the cable select line low and read two bytes\nspi.CsLow();\nbyte[] bytes = spi.ReadBytes(2);\nspi.CsHigh();\n\n// Calculate the 14-bit reading according to the datasheet\nbyte b1 = (byte)(bytes[0] \u0026 0b00011111);\nbyte b2 = (byte)(bytes[1] \u0026 0b11111110);\nint value = ((b1 \u003c\u003c 8) + b2) \u003e\u003e 1;\n```\n\n## I²C Protocol\n\nHigh level functions simplify communication with I2C devices for FTDI chips which support it (e.g., FT232H).\n\n### FT232H I²C Pinout\n\n* SCL: D0\n* SDA: D1 and D2 tied together\n\n### Scan for I²C Devices\n```cs\n// Use the first USB FTDI device found\nFtdiDevice device = FtdiDevices.Scan().First();\n\n// Create an I2C protocol communicator\nFtdiSharp.Protocols.I2C i2c = new(device);\n\n// Show all the I2C addresses in use\nforeach (byte address in i2c.Scan())\n    Console.WriteLine(address);\n```\n\n### Interact with an I²C Device\n\nThis code reads luminosity from a [BH1750 light sensor](https://www.mouser.com/datasheet/2/348/Rohm_11162017_ROHMS34826-1-1279292.pdf)\n\n```cs\n// Use the first USB FTDI device found\nFtdiDevice device = FtdiDevices.Scan().First();\nFtdiSharp.Protocols.I2C i2c = new(device);\n\n// Enter continuous sensor mode\nbyte address = 0x23;\nbyte config = 0b00010000;\ni2c.Write(address, config);\n\n// Read light intensity as two bytes\nbyte[] bytes = i2c.Read(address, 2);\n\n// Convert the two bytes to lumens according to the datasheet\ndouble value = (bytes[0] * 256 + bytes[1]) / 1.2;\n```\n\n## GPIO Protocol\n\nPins of a FT232H may be used as general purpose I/O (GPIO) controlled by software.\n\n```cs\n// Use the first USB FTDI device found\nFtdiDevice device = FtdiDevices.Scan().First();\nFtdiSharp.Protocols.GPIO gpio = new(device);\n\n// Set pin states\nbyte direction = 0b11110000; // make D4-D7 outputs\nbyte value = 0b10100000; // make D7 and D5 high\ngpio.Set(direction, value);\n\n// Read pin states\nbyte reading = gpio.Read();\n```\n\n## Additional Resources\n\n* [Adafruit FT232H Breakout Board](https://www.adafruit.com/product/2264)\n\n* Microsoft's [System.IO.Ports](https://learn.microsoft.com/en-us/dotnet/api/system.io.ports) should be used for applications which only seek to interface with a USB serial adapter.\n\n* Microsoft has a [dotnet/iot repository](https://github.com/dotnet/iot) with lots of useful code and information about protocols and common devices, including [FT232H](https://github.com/dotnet/iot/tree/main/src/devices/Ft232H). I considered using this project but I found support for FT232H to be incomplete, incorrectly documented, and buggy. They have an [impressive number of devices](https://github.com/dotnet/iot/tree/main/src/devices) though, and it seems this library is being actively developed so I hope it will be more useful in the future.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswharden%2Fftdisharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswharden%2Fftdisharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswharden%2Fftdisharp/lists"}