{"id":15293194,"url":"https://github.com/ams-osram/tmf8806_driver_arduino","last_synced_at":"2026-05-01T01:32:09.363Z","repository":{"id":257802719,"uuid":"852093198","full_name":"ams-OSRAM/tmf8806_driver_arduino","owner":"ams-OSRAM","description":"TMF8806 Arduino Driver","archived":false,"fork":false,"pushed_at":"2025-01-09T08:48:24.000Z","size":985,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T09:52:08.140Z","etag":null,"topics":["arduino","driver","tmf8806"],"latest_commit_sha":null,"homepage":"","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/ams-OSRAM.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":"2024-09-04T08:01:31.000Z","updated_at":"2025-01-09T08:45:46.000Z","dependencies_parsed_at":"2024-09-27T14:43:23.165Z","dependency_job_id":"8daf8e1d-d55f-4924-860c-6110b4456ace","html_url":"https://github.com/ams-OSRAM/tmf8806_driver_arduino","commit_stats":null,"previous_names":["ams-osram/tmf8806_driver_arduino"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ams-OSRAM%2Ftmf8806_driver_arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ams-OSRAM%2Ftmf8806_driver_arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ams-OSRAM%2Ftmf8806_driver_arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ams-OSRAM%2Ftmf8806_driver_arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ams-OSRAM","download_url":"https://codeload.github.com/ams-OSRAM/tmf8806_driver_arduino/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236239219,"owners_count":19117150,"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":["arduino","driver","tmf8806"],"created_at":"2024-09-30T16:44:59.240Z","updated_at":"2026-05-01T01:32:09.311Z","avatar_url":"https://github.com/ams-OSRAM.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TMF8806 (Time-of-flight) Arduino Uno driver  \n\nThis is a simple universal driver to show the capabilies of the time-of-flight device TMF8806. \n\n## Requirements  \n\n- an Arduino Uno R3 board \n- an ams TMF8806 Arduino Shield Board [TMF8806_EVM_EB_SHIELD](https://ams-osram.com/search?q=tmf8806)\n- a USB B cable\n- the [Arduino IDE](https://www.arduino.cc/en/software) to compile and download the Arduino Uno example application\n\n\n## Files  \n\nThe arduino project in the folder: **tmf8806_app** is a very simple single character command line interpreter listening/printing on UART\nIt contains the following files:\n\n- **tmf8806_app.ino** - the arduino specific wrapper for the application\n- **tmf8806_app.h** and **tmf8806_app.cpp** - the TMF8806 command line application\n- **tmf8806.h** and **tmf8806.cpp** - the TMF8806 driver \n- **tmf8806_shim.h** and **tmf8806_shim.cpp** - a shim to abstract the arduino specific I2C, UART and GPIO functions\n- **tmf8806_image.h** and **tmf8806_image.c** - the TMF8806 firmware that is downloaded by the driver as a c-struct\n\nYou can use application interrupt driven. For this you need to set the following define to 1: **USE_INTERRUPT_TO_TRIGGER_READ**\n\n### Porting to another MCU\n\nTo port the driver and application to another platform you need to adapt the following files:\n- **tmf8806_a.ino** - the arduino specific wrapper for the application, replace this with the requirements for your selected platform\n- **tmf8806_shim.h** and **tmf8806_shim.cpp** - a shim to abstract the arduino specific I2C, UART and GPIO functions\n\n## UART and command line interpreter  \n\nThe project listens and talks on the UART. Baud rate is 115200, 8-bit, no parity, 1 stop bit.\n\nThe command line interpreter uses single characters followed by ENTER as input commands. \nFor interfacing with a zeromq server the command line interpreter also supports complex command strings with binary payload.\n\nUART commands (single character)\n\n- a ... dump registers\n- c ... toggle configuration\n- d ... disable device\n- e ... enable device\n- f ... factory calibration\n- h ... help\n- i ... I2C address change\n- m ... start measure\n- p ... power down\n- r ... remote control mode\n- s ... stop measure\n- t ... switch persistence and thresholds\n- w ... wakeup\n- x ... clock correction on/off\n- z ... histogram dump\n- + ... log level+\n- - ... log level-\n\nUART commands (binary payload)\n\n- b\\x30\u003ctmf8806FactoryCalibData data\u003e .. set arbitrary factory calibration data\n- b\\x31\u003ctmf8806MeasureCmd data\u003e       .. set arbitrary configuration\n- b\\x32\u003cpers,loThres,hiThres\u003e         .. set arbitrary persistence / threshold\n\n## Command line interpreter application  \n\nThe command line interpreter application mimics a simple host application. It allows the user to switch between 2 pre-defined configurations:  \n\n- Configuration 0: Period 33 ms, KiloIterations = 400\n- Configuration 1: single shot mode, KiloIterations = 100\n\nYou can modify the configurations (e.g. choose different period or KiloIterations) in the application source file, recompile and download your own configuration application to the Arduino. \n\n## Examples  \n\n### Power up device  \n\nBefore the device can be used the host must power the device. The arduino uno setup function will pull the enable line to the TMF8806 low. I.e. the TMF8806 will be powered down.\n\nEnter the character\n\n- e  \n\nfollowed by ENTER to enable the device. If necessary the driver will automatically download the the firmware patch file to the TMF8806 RAM. The arduino uno will publish the FW version in the terminal:  \n\ne.g. version 192.4.11.0\n\n### Power up device and do measurements  \n\nType the following commands on UART:\n\n- e \n- m \n\nThe header for the results looks like this:  \n \\#Obj,i2c_slave_address,result_number,reliability,measured_distance,corrected_distance,sys_clock,temperature,reference_hits,object_hits,crosstalk\n\nYou will see measurement result records on the UART for the default configuration.  \n\n\\#Obj,65,165,63,295,295,735639833,27,69216,27384,829\n\\#Obj,65,166,63,295,295,735796255,27,69243,27459,830\n\\#Obj,65,167,63,294,294,735951813,27,69362,27297,799\n\n# Factory calibration  \n\nFactory calibration must be done for each device. \n\nThe simplest way is to do a live factory calibration. I.e. do the following steps:\n1. Connect your Arduino Uno and tmf8806 to the PC via USB\n2. Start a terminal program \n3. Configure and connect the terminal program to the arduino uno\n4. Make sure you have a cover glass on top of the TMF8806. This is needed for the crosstalk.\n5. Make sure there is no object in front of the TMF8806 within 40 cm.\n6. Enter the following commands in your terminal console:  \n    - e \n    - f  \n7. The application reports the calibration data: e.g. #Cal,0x2,0x0,0x0,0xA,0xB0,0xBE,0xBD,0x7C,0xF5,0xF0,0xF3,0xF7,0x7,0x4\n8. If the application does not send the calibration data the calibration has failed. Check your cover glass and check if there is no object (within 40cm) in the field-of-view of the sensor.\n\nTo use the obtained factory calibration data as default add this code to the sketch:\n\n```\nstatic const uint8_t deviceFactoryCalibration[sizeof(tmf8806FactoryCalibData)] = \n{\n  0x2,0x0,0x0,0xA,0xB0,0xBE,0xBD,0x7C,0xF5,0xF0,0xF3,0xF7,0x7,0x4\n};\n\nvoid tmf8806Initialise ( tmf8806Driver * driver, uint8_t logLevel )\n{\n  tmf8806ResetClockCorrection( driver );\n  driver-\u003ei2cSlaveAddress = TMF8806_SLAVE_ADDR;\n  driver-\u003eclkCorrectionEnable = 1;                  // default is on\n  driver-\u003elogLevel = logLevel;\n  driver-\u003emeasureConfig = defaultConfig;\n  // driver-\u003efactoryCalib = defaultFactoryCalib;\n  tmf8806DeserializeFactoryCalibration(deviceFactoryCalibration,\u0026(driver-\u003efactoryCalib));\n  driver-\u003estateData = defaultStateData;\n  driver-\u003einfo = tmf8806DriverInfoReset;\n  driver-\u003edevice = tmf8806DeviceInfoReset;\n}\n```\n\nPut the device calibration data into the array **deviceFactoryCalibration** and replace the assignment of the default factory \ncalibration with a call to deserialize the calibration data from that array.\n\n## Crosstalk readout\n\nThe application reports the crosstalk with each measurement result. E.g.:\n\n\\#Obj,65,167,63,294,294,735951813,27,69362,27297,799\n\nThe crosstalk is the last field in the line.\n\n## I2C slave address changing\n\nSend the command \"i\" to the application to change the sensor I2C address. The application will report the new I2C address. E.g.: Addr=0x42\n\n# Histogram dumping  \n\nThe device can also dump histograms. The order the Arduino Uno driver reports these histograms is exactly the same as the TMF8806 reports them on I2C.  \n\nThere are five different types of histograms available  \n\n- electrical calibration histograms (ID=1)\n- proximity histograms (ID=2)\n- distance histograms (ID=4)\n- pileup-corrected distance histograms (ID=8)\n- summed histogram (ID=16)\n\nType \"z\" and ENTER until you have the desired value for histogram dumping. E.g if the application sends:\n\nHistogram is 4\n\ndistance histograms are configured for dumping. The application dumps ALL histograms if:\n\nHistogram is 31\n\nFor all histograms, the first number after the marker (e.g. #TG7) will give the channel this histogram contains.\n\nThere are always 10 histograms reported. \n\n- Number  0 == TDC0, Channel0\n- Number  1 == TDC0, Channel1\n- ... \n- Number  9 == TDC4, Channel0\n- Number 10 == TDC0, Channel1\n \nThe header for the raw histograms looks like this:  \n\\#\u003chistogram_type\u003e,bin_0,bin_1,...,bin_127\n\nLine Tag  | Histogram Type\n----------|-----------------------\n  \\#CI    | electrical calibration\n  \\#PT    | proximity\n  \\#TG    | distance\n  \\#TGPUC | pileup-corrected distance\n  \\#SUM   | summed\n\n## Remote Control Mode\n\nThis is a new operation mode for the TMF8806 VCSEL (laser diode) to act as an infrared LED controlled \nby the input signal on GPIO1. GPIO1 == LO -\u003e VCSEL OFF, GPIO1 == HI -\u003e VCSEL ON. \nThis function requires firmware patch 4.14.1.x or newer. It does not work with standard ROM firmware.\nTo exit the remote control mode send the command \"s\" (stop measure).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fams-osram%2Ftmf8806_driver_arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fams-osram%2Ftmf8806_driver_arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fams-osram%2Ftmf8806_driver_arduino/lists"}