<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><description>Table of Contents

 Introduction 
 Quick Overview 
 How Does it Work? 
 I2C Registers Overview 

 Reading and Writing Registers 
 Application Mode Pages 


 USB UART Interface 
 Browser Based App 
 Summary 



Introduction
Time-of-Flight sensors are fascinating</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Mon, 16 Dec 2024 05:14:31 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>shabaz</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I was thinking about applications. I think I have a genuine use-case; I wish to make a gesture sensor to remove the need for a cord switch in the bathroom (I&amp;#39;m renovating that, so it&amp;#39;s the perfect time). Maybe swipe up to turn on the lights. I&amp;#39;ll definitely need a cover glass! And maybe even warm the glass a little bit (e.g. from the internal electronics naturally running warm) to prevent condensation on the surface.&lt;/p&gt;
&lt;p&gt;It is possible to buy non-contact switches (some look very basic!), but this would still be an interesting challenge, and if it fails, I can always swap out to a ready-made switch.&lt;/p&gt;
&lt;p&gt;The 8x8 array seems great for (relatively speaking) high-res sensing of the environment, but not so great for fast gesture sensing, because of the four separate sub-captures which need to be meshed. Each sub-capture occurs at a slightly different time of course, so you&amp;#39;re not getting an 8x8 snapshot at a single precise time, but rather it is blurred in time.&lt;/p&gt;
&lt;p&gt;Reading some more, I decided there&amp;#39;s no need for such granularity for the simple gestures I&amp;#39;m thinking of. I&amp;#39;d rather reduce the number of pixels (&amp;quot;zones&amp;quot; in ams OSRAM terminology).&lt;/p&gt;
&lt;p&gt;According to the user docs, it is possible to switch the TMF8828 into a different mode where it behaves like a TMF8820 or TMF8821 device, to run in 3x3 or 4x4 modes (which are single snapshots, with no meshing). I wasn&amp;#39;t sure if that meant uploading different firmware into the microcontroller inside the TMF8828 device, but I found the latest firmware files (Intel Hex format), and spent some time converting them into C arrays that the Pi Pico can automatically push to the TMF8828 RAM on startup each time. And initially failed miserably, I thought I had damaged the TMF8828 by using the TMF8820/21 firmware!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But, it turned out I had made mistakes in the Intel Hex to C array conversion. Once I fixed that, I ran it, and now I&amp;#39;m in a very fast (I believe 30 Hz) mode with a 3x3 array, which I think will be more than sufficient for the gestures I&amp;#39;m thinking of. The web app now shows the grid very smoothly.&lt;/p&gt;
&lt;p&gt;Next step: try to implement a simple gesture detection in code! I&amp;#39;m going to aim for it to detect a vertical swipe from up to 50 cm away, just for want of a hopefully achievable goal.&lt;/p&gt;
&lt;p&gt;Maybe this could be useful for others too, if they wish to operate some electronics in kitchen/bathroom etc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;All ideas/suggestions/cautions welcome, since I&amp;#39;m just brainstorming currently.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Sun, 15 Dec 2024 20:44:55 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>DAB</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Very interesting post.&lt;/p&gt;
&lt;p&gt;Well done.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Thu, 12 Dec 2024 11:25:07 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>michaelkellett</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Great blog. And an interesting part.&lt;/p&gt;
&lt;p&gt;MK&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Wed, 11 Dec 2024 15:19:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>genebren</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Great blog on a highly interesting subject.&amp;nbsp; I have completed a few designs utilizing a PIR detector for motion sensing.&amp;nbsp; I can see where a Time-Of-Flight sensor might be a huge improvement.&amp;nbsp; I will have to consider using this sort of sensor on my next project and requires motion or environment sensing.&amp;nbsp; Thanks for sharing.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Wed, 11 Dec 2024 15:14:51 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>shabaz</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Speeding up the rate ended up being quite simple. I modified the Pi Pico code by adding the following to the main.c file (can&amp;#39;t add a hyperlink! &lt;a id="" href="https://github.com/shabaz123/TMF8828/blob/main/tmf8828_experiment_board/main.c" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/shabaz123/TMF8828/blob/main/tmf8828_experiment_board/main.c&lt;/a&gt;&amp;nbsp;) (it is obvious by inspection where to place this, around line 875):&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;if &lt;/span&gt;(strcmp(token, &lt;span&gt;&amp;quot;F&amp;quot;&lt;/span&gt;) == &lt;span&gt;0&lt;/span&gt;) { &lt;span&gt;// Fast mode&lt;br /&gt;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;tmf8828Configure( &lt;span&gt;TMF8828_A&lt;/span&gt;, configPeriod[&lt;span&gt;0&lt;/span&gt;], configKiloIter[&lt;span&gt;0&lt;/span&gt;],(&lt;span&gt;uint8_t&lt;/span&gt;) dumpHistogramOn );&lt;br /&gt;    &lt;span&gt;PRINT_STR&lt;/span&gt;(&lt;span&gt;&amp;quot;#Conf Fast&amp;quot;&lt;/span&gt;); &lt;span&gt;PRINT_LN&lt;/span&gt;();&lt;br /&gt;    token_progress = &lt;span&gt;TOKEN_PROGRESS_NONE&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;return &lt;/span&gt;&lt;span&gt;TOKEN_RESULT_LINE_COMPLETE&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span&gt;if &lt;/span&gt;(strcmp(token, &lt;span&gt;&amp;quot;S&amp;quot;&lt;/span&gt;) == &lt;span&gt;0&lt;/span&gt;) { &lt;span&gt;// Slow mode&lt;br /&gt;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;tmf8828Configure( &lt;span&gt;TMF8828_A&lt;/span&gt;, configPeriod[&lt;span&gt;2&lt;/span&gt;], configKiloIter[&lt;span&gt;2&lt;/span&gt;],(&lt;span&gt;uint8_t&lt;/span&gt;) dumpHistogramOn );&lt;br /&gt;    &lt;span&gt;PRINT_STR&lt;/span&gt;(&lt;span&gt;&amp;quot;#Conf Slow&amp;quot;&lt;/span&gt;); &lt;span&gt;PRINT_LN&lt;/span&gt;();&lt;br /&gt;    token_progress = &lt;span&gt;TOKEN_PROGRESS_NONE&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;return &lt;/span&gt;&lt;span&gt;TOKEN_RESULT_LINE_COMPLETE&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span&gt;if &lt;/span&gt;(strcmp(token, &lt;span&gt;&amp;quot;M&amp;quot;&lt;/span&gt;) == &lt;span&gt;0&lt;/span&gt;) { &lt;span&gt;// Medium speed mode&lt;br /&gt;&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;tmf8828Configure( &lt;span&gt;TMF8828_A&lt;/span&gt;, configPeriod[&lt;span&gt;1&lt;/span&gt;], configKiloIter[&lt;span&gt;1&lt;/span&gt;],(&lt;span&gt;uint8_t&lt;/span&gt;) dumpHistogramOn );&lt;br /&gt;    &lt;span&gt;PRINT_STR&lt;/span&gt;(&lt;span&gt;&amp;quot;#Conf Medium&amp;quot;&lt;/span&gt;); &lt;span&gt;PRINT_LN&lt;/span&gt;();&lt;br /&gt;    token_progress = &lt;span&gt;TOKEN_PROGRESS_NONE&lt;/span&gt;;&lt;br /&gt;    &lt;span&gt;return &lt;/span&gt;&lt;span&gt;TOKEN_RESULT_LINE_COMPLETE&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Then, in the JavaScript code app.js file (&amp;nbsp;&lt;a id="" href="https://github.com/shabaz123/TMF8828/blob/main/tmf8828_viewer/js/app.js" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/shabaz123/TMF8828/blob/main/tmf8828_viewer/js/app.js&lt;/a&gt;&amp;nbsp;), I added:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;Send&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;F&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;); &lt;/span&gt;&lt;span&gt;// set to the fast configuration&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;just before the line:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;deviceInitialized&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span&gt;&lt;span&gt;near line 244, in the function:&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;btnStart&amp;#39;&lt;/span&gt;&lt;span&gt;).&lt;/span&gt;&lt;span&gt;addEventListener&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;#39;click&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;function&lt;/span&gt;&lt;span&gt;() {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;Now it&amp;#39;s more responsive.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Time-of-Flight Imaging: Low-cost sensing with ams/OSRAM TMF8828 and Pi Pico</title><link>https://community.element14.com/technologies/sensor-technology/b/blog/posts/time-of-flight-imaging-low-cost-sensing-with-ams-osram-tmf8828-and-pi-pico</link><pubDate>Wed, 11 Dec 2024 09:11:04 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e2230f2c-0eff-40eb-8c23-af79001c4b41</guid><dc:creator>obones</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Thanks for this very detailed run through, the device looks quite capable!&lt;br /&gt;What I&amp;#39;m wondering though, is how you get to have a PCB manufactured for 2$, I have looked at various options and for a delivery to France, I&amp;#39;m always at 20/30&amp;euro; for PCBs.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28601&amp;AppID=17&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>