<?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>BeagleBone Web Server - Temperature Sensor</title><link>/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><description>Table of Contents Setup LED Blinking MySQL Installation Temperature Sensor IntroductionIn the previous articles, we set up the BeagleBone to have a MySQL database and a web server . We also wrote a simple web site to control the LEDs on the BeagleBon</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Tue, 04 Aug 2015 02:28:41 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>Former Member</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;i like it.... would you tell me how to use DHT11 humidity sensor instead of &lt;span&gt;MCP9701E.... ??&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Wed, 23 Jul 2014 06:40:26 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>Former Member</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;what if i want to use temp. sensor of LM35DZ?&lt;/p&gt;&lt;p&gt;i just changing MCP9701E.cpp file name to LM35DZ.cpp?&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Sun, 29 Dec 2013 11:34:50 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>Former Member</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This is for BBB and Ubuntu:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;-I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient&lt;/p&gt;&lt;p&gt;also path to AIN1 in tempmeas.cpp:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;// Initialize the temperature sensor&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCP9701E sensor(&amp;quot;/sys/devices/ocp.2/helper.14/AIN1&amp;quot;);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;g++ tempmeas_initial.cpp -o tempmeas_initial -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient&lt;/p&gt;&lt;p&gt;g++ tempmeas.cpp MCP9701E.cpp -o tempmeas -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient&lt;/p&gt;&lt;p&gt;or like this:&lt;/p&gt;&lt;p&gt;g++ tempmeas.cpp MCP9701E.cpp -o tempmeas `mysql_config --cflags --libs`&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;check adafruit for BBIO library:&lt;/p&gt;&lt;p&gt;&lt;a class="jive-link-external-small" href="http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/using-the-bbio-library" rel="nofollow ugc noopener" target="_blank" title="http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/using-the-bbio-library"&gt;Using the Adafruit_BBIO Library | Setting up IO Python Library on BeagleBone Black | Adafruit Learning System&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I&amp;#39;m using TMP 36 analog temperature sensor; here is nice tutorial on adafruit:&lt;/p&gt;&lt;p&gt;&lt;a class="jive-link-external-small" href="http://learn.adafruit.com/measuring-temperature-with-a-beaglebone-black/overview" rel="nofollow ugc noopener" target="_blank" title="http://learn.adafruit.com/measuring-temperature-with-a-beaglebone-black/overview"&gt;Overview | Measuring Temperature with a BeagleBone Black | Adafruit Learning System&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I modified python script so it will insert data in TempDB database, so basically this scrip will replace tempmeas:&lt;/p&gt;&lt;p&gt;&lt;span&gt;temp.py:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;#!/usr/bin/env python&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;import time&lt;/span&gt;&lt;/p&gt;&lt;p&gt;import MySQLdb&lt;/p&gt;&lt;p&gt;&lt;span&gt;import Adafruit_BBIO.ADC as ADC&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;# Sensor&lt;/span&gt;&lt;/p&gt;&lt;p&gt;sensor_pin = &amp;#39;P9_40&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;# Setup&lt;/span&gt;&lt;/p&gt;&lt;p&gt;ADC.setup()&lt;/p&gt;&lt;p&gt;while True:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reading = ADC.read(sensor_pin)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; millivolts = reading * 1800&amp;nbsp; # 1.8V reference = 1800 mV&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_c = (millivolts - 500) / 10&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; now = time.strftime(&amp;quot;%Y-%m-%d&amp;quot; &amp;quot; &amp;quot; &amp;quot;%X&amp;quot;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; db = MySQLdb.connect(host=&amp;quot;127.0.0.1&amp;quot;,user=&amp;quot;bone&amp;quot;,passwd=&amp;quot;bone&amp;quot;,db=&amp;quot;TempDB&amp;quot;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur=db.cursor()&lt;/p&gt;&lt;p&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql=&amp;quot;INSERT INTO TempMeas (MeasTime, Temp) VALUES (&amp;#39;%s&amp;#39;, &amp;#39;%s&amp;#39;)&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.execute(sql % (now, temp_c))&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; db.commit()&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; db.close()&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; time.sleep(60)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;To run script use: python temp.py, and put it in cron so it will run on startup.&lt;/p&gt;&lt;p&gt;Also you can add: &amp;lt;meta http-equiv=&amp;quot;refresh&amp;quot; content=&amp;quot;60&amp;quot; &amp;gt; inside head tag in temp.php so it will auto refresh every 60 seconds.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span&gt;Thanks again for this tutorial, really like it..&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Sat, 28 Dec 2013 01:40:31 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>Former Member</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;I&amp;#39;m new to Linux and the BeagleBone Black, and your tutorials have helped me get up and running with the BBB much more quickly. Thanks a ton. I did run in to several issues on the way that were huge headaches for me until I figured them out. The biggest thing I ran into in this part was compiling. For some reason I could not get it to compile the way you did. I had to compile the objects individually first to get it to work. This is what I did: &lt;/p&gt;&lt;p&gt;g++ -c &lt;span&gt;MCP9701E&lt;/span&gt;.cpp&lt;/p&gt;&lt;p&gt;g++ -c &lt;span&gt;tempmeas&lt;/span&gt;.cpp -I/usr/include/mysql -lmysqlclient&lt;/p&gt;&lt;p&gt;g++ -o &lt;span&gt;tempmeas &lt;span&gt;tempmeas&lt;/span&gt;&lt;/span&gt;.o &lt;span&gt;MCP9701E&lt;/span&gt;.o -I/usr/include/mysql -lmysqlclient&lt;/p&gt;&lt;p&gt;I have no idea why I had to do this. &lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Sun, 22 Dec 2013 18:48:47 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>Former Member</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;great tutorial.. &lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: BeagleBone Web Server - Temperature Sensor</title><link>https://community.element14.com/products/devtools/single-board-computers/next-genbeaglebone/b/blog/posts/beaglebone-web-server---temperature-sensor</link><pubDate>Sun, 24 Nov 2013 21:37:08 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3000794-1508-4bc5-a73e-6dcbe2a98567</guid><dc:creator>DAB</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Hi Shawn,&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks for your excellent example.&amp;nbsp; I have added this to my list of things to do, but right now my queue is over loaded, so it might take some time before I can try this myself.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;DAB&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=16601&amp;AppID=80&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>