<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Help with Tempurature from ds18b20 on oled please?]]></title><description><![CDATA[<p dir="auto">I have a python app to take the temperature reading from a DS18B20 sensor and display it on a 0.96" Oled display. My only problem is I can't for the life of me figure out how to write the code to convert the temp from C. to F. I have the formula, just don't know where to use it. I have tried a few things and they don't work.</p>
<p dir="auto">I am including my code below. Thanks for any help...</p>
<p dir="auto">[code]<br />
#!/usr/bin/env python<br />
import os<br />
import glob<br />
import time<br />
from OmegaExpansion import oledExp<br />
base_dir = '/sys/bus/w1/devices/'<br />
device_folder = glob.glob(base_dir + '28*')[0]<br />
device_file = device_folder + '/w1_slave'</p>
<p dir="auto">def read_temp_raw():<br />
f = open(device_file, 'r')<br />
lines = f.readlines()<br />
f.close()<br />
return lines</p>
<p dir="auto">def read_temp():<br />
lines = read_temp_raw()<br />
while lines[0].strip()[-3:] != 'YES':<br />
time.sleep(0.2)<br />
lines = read_temp_raw()<br />
equals_pos = lines[1].find('t=')<br />
if equals_pos != -1:<br />
temp_string = lines[1][equals_pos+2:]<br />
temp_c = float(temp_string)/ 1000.0</p>
<pre><code>	return temp_c
</code></pre>
<p dir="auto">status = oledExp.driverInit();<br />
status = oledExp.setDisplayMode(0);<br />
status = oledExp.scrollStop();</p>
<p dir="auto">status = oledExp.write(time.strftime("%Y-%m-%d %X")+ "                       Temp:"+ str(read_temp())+" C");<br />
[/code]</p>
]]></description><link>http://community.onion.io/topic/631/help-with-tempurature-from-ds18b20-on-oled-please</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 20:58:02 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/631.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Mar 2016 21:40:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Help with Tempurature from ds18b20 on oled please? on Thu, 17 Mar 2016 21:40:37 GMT]]></title><description><![CDATA[<p dir="auto">I have a python app to take the temperature reading from a DS18B20 sensor and display it on a 0.96" Oled display. My only problem is I can't for the life of me figure out how to write the code to convert the temp from C. to F. I have the formula, just don't know where to use it. I have tried a few things and they don't work.</p>
<p dir="auto">I am including my code below. Thanks for any help...</p>
<p dir="auto">[code]<br />
#!/usr/bin/env python<br />
import os<br />
import glob<br />
import time<br />
from OmegaExpansion import oledExp<br />
base_dir = '/sys/bus/w1/devices/'<br />
device_folder = glob.glob(base_dir + '28*')[0]<br />
device_file = device_folder + '/w1_slave'</p>
<p dir="auto">def read_temp_raw():<br />
f = open(device_file, 'r')<br />
lines = f.readlines()<br />
f.close()<br />
return lines</p>
<p dir="auto">def read_temp():<br />
lines = read_temp_raw()<br />
while lines[0].strip()[-3:] != 'YES':<br />
time.sleep(0.2)<br />
lines = read_temp_raw()<br />
equals_pos = lines[1].find('t=')<br />
if equals_pos != -1:<br />
temp_string = lines[1][equals_pos+2:]<br />
temp_c = float(temp_string)/ 1000.0</p>
<pre><code>	return temp_c
</code></pre>
<p dir="auto">status = oledExp.driverInit();<br />
status = oledExp.setDisplayMode(0);<br />
status = oledExp.scrollStop();</p>
<p dir="auto">status = oledExp.write(time.strftime("%Y-%m-%d %X")+ "                       Temp:"+ str(read_temp())+" C");<br />
[/code]</p>
]]></description><link>http://community.onion.io/post/4616</link><guid isPermaLink="true">http://community.onion.io/post/4616</guid><dc:creator><![CDATA[Daniel Wright]]></dc:creator><pubDate>Thu, 17 Mar 2016 21:40:37 GMT</pubDate></item><item><title><![CDATA[Reply to Help with Tempurature from ds18b20 on oled please? on Fri, 18 Mar 2016 14:36:23 GMT]]></title><description><![CDATA[<p dir="auto">temp_f = (( temp_c * 9) / 5)  + 32<br />
return temp_f</p>
]]></description><link>http://community.onion.io/post/4622</link><guid isPermaLink="true">http://community.onion.io/post/4622</guid><dc:creator><![CDATA[mark doutre]]></dc:creator><pubDate>Fri, 18 Mar 2016 14:36:23 GMT</pubDate></item><item><title><![CDATA[Reply to Help with Tempurature from ds18b20 on oled please? on Sun, 20 Mar 2016 02:58:41 GMT]]></title><description><![CDATA[<p dir="auto">I see.... Use that instead of the return temp_c.?.?<br />
Didn't think of that one. I'll give it a shot.<br />
Thanks.</p>
]]></description><link>http://community.onion.io/post/4639</link><guid isPermaLink="true">http://community.onion.io/post/4639</guid><dc:creator><![CDATA[Daniel Wright]]></dc:creator><pubDate>Sun, 20 Mar 2016 02:58:41 GMT</pubDate></item></channel></rss>