<?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>Multiple DS18B20 Temp sensors interfacing with Raspberry Pi</title><link>/products/raspberry-pi/raspberrypi_projects/b/blog/posts/multiple-ds18b20-temp-sensors-interfacing-with-raspberry-pi</link><description>Interfacing Nine DS18B20 Temperature sensors with Raspberry Pi and Displaying sensor data Using Python

I have gone through some tutorials for interfacing the DS18B20, In those, They have given the explanation of how to interface the DS18B20 using Ar</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Multiple DS18B20 Temp sensors interfacing with Raspberry Pi</title><link>https://community.element14.com/products/raspberry-pi/raspberrypi_projects/b/blog/posts/multiple-ds18b20-temp-sensors-interfacing-with-raspberry-pi</link><pubDate>Thu, 11 May 2023 14:01:10 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:ba9be7c5-bebb-4f86-8e46-00e6bcdfc693</guid><dc:creator>laluha</dc:creator><slash:comments>3</slash:comments><description>&lt;p&gt;Hi&amp;nbsp;&lt;a title="vinayyn" href="/members/vinayyn"&gt;vinayyn&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Very nice presentation.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think your code works, but here is what works for me.:&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:c568c337-0584-48b4-a58e-9995d4670dda:type=text&amp;text=import%20os%0D%0Aimport%20glob%0D%0Aimport%20time%0D%0A%0D%0A%23%20These%20%20lines%20mount%20the%20device%3A%0D%0Aos.system%28%27modprobe%20w1-gpio%27%29%0D%0Aos.system%28%27modprobe%20w1-therm%27%29%0D%0A%20%0D%0Abase_dir%20%3D%20%27%2Fsys%2Fbus%2Fw1%2Fdevices%2F%27%0D%0A%23%20Get%20all%20the%20filenames%20begin%20with%2028%20in%20the%20path%20base_dir.%0D%0Adevice_folders%20%3D%20glob.glob%28base_dir%20%2B%20%2728%2A%27%29%0D%0A%0D%0A%23%20print%20device_folders%0D%0A%0D%0Adef%20read_temp_raw%28device_file%29%3A%0D%0A%20%20%20%20f%20%3D%20open%28device_file%2C%20%27r%27%29%0D%0A%20%20%20%20lines%20%3D%20f.readlines%28%29%0D%0A%20%20%20%20%23print%28device_file%2C%20lines%29%0D%0A%20%20%20%20f.close%28%29%0D%0A%20%20%20%20return%20lines%0D%0A%0D%0Adef%20read_temp%28device_file%29%3A%0D%0A%20%20%20%20maxAttempts%20%3D%203%0D%0A%20%20%20%20while%20True%3A%0D%0A%09temp%20%3D%20try_temp%28device_file%29%0D%0A%20%20%20%20%20%20%20%20if%20temp%20%21%3D%20-99.0%3A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20temp%0D%0A%20%20%20%20%20%20%20%20maxAttempts%20-%3D%201%0D%0A%20%20%20%20%20%20%20%20if%20maxAttempts%20%3C%3D%200%3A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20temp%0D%0A%0D%0A%0D%0Adef%20try_temp%28device_file%29%3A%0D%0A%20%20%20%20temp_c%20%3D%20-99.0%0D%0A%20%20%20%20lines%20%3D%20read_temp_raw%28device_file%2B%27%2Fw1_slave%27%29%0D%0A%20%20%20%20if%20len%28lines%29%20%3D%3D%202%3A%0D%0A%20%20%20%20%20%20%20%20if%20lines%5B0%5D.strip%28%29%5B-3%3A%5D%20%3D%3D%20%27YES%27%3A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20equals_pos%20%3D%20lines%5B1%5D.find%28%27t%3D%27%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20temp_string%20%3D%20lines%5B1%5D%5Bequals_pos%2B2%3A%5D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20temp_c%20%3D%20float%28temp_string%29%20%2F%201000.0%0D%0A%20%20%20%20return%20temp_c%0D%0A%0D%0Afor%20folder%20in%20device_folders%3A%0D%0A%20%20%20%20tc%20%3D%20read_temp%28folder%29%0D%0A%20%20%20%20tf%20%3D%20tc%20%2A%209.0%20%2F%205.0%20%2B%2032.0%0D%0A%20%20%20%20print%20%27%25s%20%253.3f%20deg%20C%20%20%253.3f%20deg%20F%27%20%25%20%28folder%2C%20tc%2C%20tf%29%0D%0A%0D%0A%0D%0A]&lt;/p&gt;
&lt;p&gt;;-)&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24190&amp;AppID=84&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Multiple DS18B20 Temp sensors interfacing with Raspberry Pi</title><link>https://community.element14.com/products/raspberry-pi/raspberrypi_projects/b/blog/posts/multiple-ds18b20-temp-sensors-interfacing-with-raspberry-pi</link><pubDate>Wed, 10 Aug 2022 18:12:24 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:ba9be7c5-bebb-4f86-8e46-00e6bcdfc693</guid><dc:creator>Tinkermik</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;great work&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24190&amp;AppID=84&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>