<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>raspberry pi &#8211; Farlock.org</title>
	<atom:link href="https://www.farlock.org/tag/raspberry-pi-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.farlock.org</link>
	<description>What you want to hack today?</description>
	<lastBuildDate>Mon, 27 Apr 2015 16:20:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0</generator>
	<item>
		<title>Raspberry Web Analog Data Logger</title>
		<link>https://www.farlock.org/raspberry-pi/raspberry-web-analog-data-logger/</link>
					<comments>https://www.farlock.org/raspberry-pi/raspberry-web-analog-data-logger/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 27 Apr 2015 16:06:19 +0000</pubDate>
				<category><![CDATA[ADC]]></category>
		<category><![CDATA[Raspberry PI]]></category>
		<category><![CDATA[adc]]></category>
		<category><![CDATA[analog input]]></category>
		<category><![CDATA[Custard PI 3]]></category>
		<category><![CDATA[data logger]]></category>
		<category><![CDATA[MCP3008]]></category>
		<category><![CDATA[MCP3208]]></category>
		<category><![CDATA[raspberry pi]]></category>
		<guid isPermaLink="false">http://www.farlock.org/?p=229</guid>

					<description><![CDATA[<p>On this post I&#8217;ll explain you how to grab analog data from an 8-channel, 12 bit ADC. The ADC used is the Custard-PI 3 http://www.sf-innovations.co.uk/custard-pi-3.html . You can buy it directly from them on that page.</p> <p>I use it to log value from different type of sensors. As you know ADC for raspberry can read [...]]]></description>
										<content:encoded><![CDATA[<p>On this post I&#8217;ll explain you how to grab analog data from an 8-channel, 12 bit ADC. The ADC used is the Custard-PI 3 <a href="http://www.sf-innovations.co.uk/custard-pi-3.html" target="_blank">http://www.sf-innovations.co.uk/custard-pi-3.html</a> . You can buy it directly from them on that page.</p>
<p>I use it to log value from different type of sensors. As you know ADC for raspberry can read only voltage from 0 to 2.5V (or higher with partitor) but lot of industrial sensors are based on 4-20mA range.</p>
<p><a href="http://www.farlock.org/wp-content/uploads/2015/04/graph.png"><img loading="lazy" class=" size-medium wp-image-238 aligncenter" src="http://www.farlock.org/wp-content/uploads/2015/04/graph-300x190.png" alt="graph" width="300" height="190" srcset="https://www.farlock.org/wp-content/uploads/2015/04/graph-300x190.png 300w, https://www.farlock.org/wp-content/uploads/2015/04/graph-1024x649.png 1024w, https://www.farlock.org/wp-content/uploads/2015/04/graph-150x95.png 150w, https://www.farlock.org/wp-content/uploads/2015/04/graph-400x253.png 400w, https://www.farlock.org/wp-content/uploads/2015/04/graph.png 1283w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>With this scripts you will be able to obtain a CSV and graph of the real value with only some easy configuration. You just need to know what&#8217;s the range of your sensor (ex: 0-100°C), what&#8217;s the range of output value of the sensor (ex: 4-20 mA), what does ADC read when the output value is at minimum and at the maximum. To obtain this last values we need only a simple more step.</p>
<p><a href="http://www.farlock.org/wp-content/uploads/2015/04/home.png"><img loading="lazy" class=" size-medium wp-image-239 aligncenter" src="http://www.farlock.org/wp-content/uploads/2015/04/home-282x300.png" alt="home" width="282" height="300" srcset="https://www.farlock.org/wp-content/uploads/2015/04/home-282x300.png 282w, https://www.farlock.org/wp-content/uploads/2015/04/home-141x150.png 141w, https://www.farlock.org/wp-content/uploads/2015/04/home-400x425.png 400w, https://www.farlock.org/wp-content/uploads/2015/04/home.png 708w" sizes="(max-width: 282px) 100vw, 282px" /></a></p>
<p>The setup is very easy, you just need to connect the board to raspberry, power it on, copy the software on it and everything is done. Let&#8217;s go step by step:</p>
<ol>
<li>Connect the board to raspberry and power it on.</li>
<li>Connect to PI with ssh, update it and install apache with php:<br />
# <span style="color: #000080;">sudo apt-get update &amp;&amp; apt-get upgrade</span># <span style="color: #000080;">sudo apt-get install libapache2-mod-php5</span></li>
<li>Download the tarball and extract it on root ( / ) directory.<br />
<blockquote><p><span style="color: #000080;"> cd /tmp</span><br />
<span style="color: #000080;">wget http://www.farlock.org/wp-content/uploads/2015/04/adc_grabber.tar </span><br />
<span style="color: #000080;">cd / </span><br />
<span style="color: #000080;">tar xvf /tmp/adc_grabber.tar</span></p></blockquote>
</li>
<li>It will extract two files in /etc/init.d and /etc/default ; these are needed for startup at boot.<br />
It will extract the cpi3adc.py file in /usr/local/bin and the directory cpi3adc in /usr/local/lib (this contains two included file). Every web page is extracted on /var/www/adc</li>
<li>We need four more steps manually:<br />
<blockquote><p>Edit sudoers file with command:<br />
# <span style="color: #000080;">sudo visudo</span><br />
and add this line at the end:<br />
<span style="color: #800080;">www-data ALL=(ALL) NOPASSWD: ALL</span><br />
add user www-data to group pi with this:<br />
# <span style="color: #000080;">sudo adduser www-data pi</span><br />
Enable startup of the logger on boot:<br />
# <span style="color: #000080;">sudo update-rc.d cpi3adc defaults</span><br />
And finally edit /etc/apache2/sites-enabled/000-default, find the paragraph starting with:<br />
<span style="color: #800080;">&lt;Directory /var/www&gt;</span><br />
and add these lines inside it:<br />
<span style="color: #800080;">Options +ExecCGI</span><br />
<span style="color: #800080;">AddHandler cgi-script .cgi .pl</span><br />
<span style="color: #800080;">RedirectMatch ^/$ /adc/</span></p></blockquote>
</li>
<li>Via web browser connect to your raspberry (you need to know the ip address, ex: 192.168.1.110):<br />
http://192.168.1.100/adc</li>
<li>On this page you can set up global parameters or different ones for each channel (in case you have different sensors).<br />
In my example I have a thermometer with range 0° &#8211; 100°C and output of 4 &#8211; 20 mA.<br />
I have connected it to channel 1 with 100 ohm resistor, look at this image to have an idea:<img loading="lazy" class="alignnone" src="http://www.industrologic.com/4-20ma.gif" alt="" width="328" height="200" /><br />
The problem now is that the resistor is not usually perfect and we need to make some adjustment.</li>
<li>I disconnect my sensor and i connect to analog input a current generator, I set it with 4mA and i click on &#8220;Leggi Valori Attuali&#8221;, this is the result:<br />
<blockquote><p>CANALE &#8211; Volt Ingresso &#8211; Valore Ingresso Puro &#8211; Ingresso  mA &#8211; Valore Calcolato °C<br />
<strong>CH 1</strong> &#8211; Voltage 0.40 &#8211; <strong>Value 655</strong> &#8211; In 4.00 mA &#8211; 0.00 °C<br />
CH 2 &#8211; Voltage 0.08 &#8211; Value 131 &#8211; In 0.80 mA &#8211; -20.05 °C<br />
CH 3 &#8211; Voltage 0.05 &#8211; Value 81 &#8211; In 0.50 mA &#8211; -21.96 °C<br />
CH 4 &#8211; Voltage 0.03 &#8211; Value 43 &#8211; In 0.26 mA &#8211; -23.41 °C<br />
CH 5 &#8211; Voltage 0.01 &#8211; Value 21 &#8211; In 0.13 mV &#8211; -12.13 V<br />
CH 6 &#8211; Voltage 0.01 &#8211; Value 15 &#8211; In 0.09 mA &#8211; -24.48 °C<br />
CH 7 &#8211; Voltage 0.01 &#8211; Value 11 &#8211; In 0.07 mA &#8211; -24.64 °C<br />
CH 8 &#8211; Voltage 0.00 &#8211; Value 7 &#8211; In 0.04 mA &#8211; -24.79 °C</p></blockquote>
<p>Our interest is for the second line (channel 1) and the second field (value), this is the value that ADC reads with an input of 4mA and our resistor.<br />
Now the same thing setting the generator to 20mA, change the generator and press F5 to reload the page, this is the output:</p>
<blockquote><p>CANALE &#8211; Volt Ingresso &#8211; Valore Ingresso Puro &#8211; Ingresso  mA &#8211; Valore Calcolato °C<br />
CH 1 &#8211; Voltage 2.00 &#8211; Value 3269 &#8211; In 20.0 mA &#8211; 100.00 °C</p></blockquote>
<p>The second value is 3269, this is the ADC reading with 20mA.</li>
<li>Now on the homepage you can set the value needed. And you need how to obtain the value for the third column (ADC).</li>
<li>When everything is done you can press &#8220;Salva Valori&#8221;, and then you can start the logger with &#8220;Avvia&#8221;.</li>
<li>If you want to start automatically the logger at boot check &#8220;Avvia automaticamente&#8221; and press &#8220;Salva Valori&#8221;.</li>
<li>The logger grab the data every seconds setted in &#8220;Intervallo in secondi per letture&#8221;, and calculate the average every &#8220;Nr di valori per media&#8221; setted.</li>
<li>You can see the graph in realtime clicking on &#8220;Visualizza Grafico&#8221;, and download CSV clicking on &#8220;Download CSV&#8221;.</li>
</ol>
<p>Download scripts: <a href="http://www.farlock.org/wp-content/uploads/2015/04/adc_grabber.tar">adc_grabber</a></p>
<p>Thanks to:<br />
http://www.sf-innovations.co.uk/custard-pi-3.html<br />
https://chrisbaume.wordpress.com/2013/02/10/beer-monitoring/<br />
http://dygraphs.com/</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.farlock.org/raspberry-pi/raspberry-web-analog-data-logger/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
