<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://nearbus.xyz/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Temperature_Monitor</id>
		<title>Temperature Monitor - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://nearbus.xyz/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Temperature_Monitor"/>
		<link rel="alternate" type="text/html" href="https://nearbus.xyz/mediawiki/index.php?title=Temperature_Monitor&amp;action=history"/>
		<updated>2026-05-15T14:09:20Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://nearbus.xyz/mediawiki/index.php?title=Temperature_Monitor&amp;diff=134&amp;oldid=prev</id>
		<title>Nearwiki: Created page with &quot;This example shows how to implement a simple real time temperature monitor in JavaScript for a mobile device. This implementation require an Xively account (www.xively.com) in...&quot;</title>
		<link rel="alternate" type="text/html" href="https://nearbus.xyz/mediawiki/index.php?title=Temperature_Monitor&amp;diff=134&amp;oldid=prev"/>
				<updated>2018-03-29T20:57:00Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;This example shows how to implement a simple real time temperature monitor in JavaScript for a mobile device. This implementation require an Xively account (www.xively.com) in...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This example shows how to implement a simple real time temperature monitor in JavaScript for a mobile device. This implementation require an Xively account (www.xively.com) in order to get the historical data sequence in a chart format. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:temp_chart.png|160px]]&lt;br /&gt;
&lt;br /&gt;
smartphone interface example&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Note:''' Indeed this example can be used to display any analog value that you can sensing from  any on the Arduino's Analog inputs (A0 to A3). We use a LM35 temperature sensor merely as application example. &lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===Xively Configuration (Cosm)===&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
This screen allows you send to Cosm (www.xively.com) the values received from or transmitted to the remote device over each channel.&lt;br /&gt;
&lt;br /&gt;
[[File:temp_chart_xively.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Stream ID: ''' This field allows you to set the Xvely's (Cosm) datastream where you want to send the signal.&lt;br /&gt;
&lt;br /&gt;
* '''IN / OUT:''' This option allows you to indicate if you want to send a readed value (input) from the remote device or the written value (output) to the remote device for each channel.&lt;br /&gt;
&lt;br /&gt;
* '''Constant and Offset:''' The main advantage of this feature is that it allows you to apply a basic transfer function to your signal before sending it to Xively (Cosm):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     f(x) = x * K + offset&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''ON: ''' This option allows you to turn on or off the data feed to Xively (Cosm).&lt;br /&gt;
&lt;br /&gt;
* '''Xively Feed and API Key:''' This option allows you to configure the required parameters to connect succesfully to www.xively.com.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Configuring the Manual Mode===&lt;br /&gt;
&lt;br /&gt;
In order to get samples from the sensor in a continous way, you should configure the '''ADC_INPUT''' service in manual mode for the selected channel (the port in which the sensor will be connected). In this example we will use the Channel 0 (pin 3 in an Arduino platform). The following picture shows this configuration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Manual_mode_xively.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Javascript Code===&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
The following code will allow you to display the sensed temperature in a graphical way from a mobile device or desktop computer. In order to run this example, download the following file in you mobile device or computer and execute it. Double click onto the downloaded &amp;quot;html&amp;quot; file in order to run it on your default browser.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 This example is intended to use an LM35 linear temperature sensor but you can use any sensor that you want (you only should change&lt;br /&gt;
 conversion factor). In this example a conversion factor of  (5000 / 1023) / 10 ) is used because the (10bits) ADC Internal reference&lt;br /&gt;
 is fixed at 5000mV and the LM35 internal constant is 10mV/ºC.&lt;br /&gt;
 &lt;br /&gt;
 Note that the Xively transfer function '''does not affect''' the value read with the ADC_INPUT service.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 '''Download:''' TemperatureChart_v01.zip [http://www.nearbus.net/downloads/js_apps/TemperatureChart_v01.zip]&lt;br /&gt;
 &lt;br /&gt;
 In order to run this example you should edit it (eg. notepad) and replace the following parameters:&lt;br /&gt;
 var device_id  = &amp;quot;NB100xxx&amp;quot;;		// You NearBus Device ID&lt;br /&gt;
 var user       = &amp;quot;****&amp;quot;;            	// Your NearBus Web user&lt;br /&gt;
 var pass       = &amp;quot;****&amp;quot;;            	// Your NearBus Web password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;        &lt;br /&gt;
&amp;lt;!-- ****************************************************************************************************************************** --&amp;gt;  &lt;br /&gt;
&amp;lt;!-- * NEARBUS JAVASCRIPT EXAMPLE - www.nearbus.net                                                                               * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- * Description: This simple code shows how to implement a temperature chart indicator on a Smartphone                         * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- * This example requires an Xively account (www.xively.com) in order to record the temperature in a historical way            * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- * The system is configured to work with a LM35 (lineal Temp Sensor (ºC)                                                      * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- * Support: info@nearbus.net                                                                                                  * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- ****************************************************************************************************************************** --&amp;gt;  &lt;br /&gt;
&amp;lt;!-- * REVISION HISTORY                                                                                                           * --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * v0.1 - 05-11-13 - Initial Release                                                                                          * --&amp;gt; &lt;br /&gt;
&amp;lt;!-- ****************************************************************************************************************************** --&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://code.jquery.com/jquery-1.9.1.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;PAGE&amp;quot; &amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type='text/javascript' src='http://nearbus.net/downloads/js_apps/nearapi_v05.js'&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
// +--------------------------------------------------------------------+&lt;br /&gt;
// | To run this example you should replace the following parameters    |&lt;br /&gt;
// | device_id         Your device ID, or.. devices ID :)               |&lt;br /&gt;
// | user              Your NearBus Web user                            |&lt;br /&gt;
// | pass              Your NearBus Web password                        |&lt;br /&gt;
// +--------------------------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//////////////////////////////////&lt;br /&gt;
// MAIN CONFIGURATION&lt;br /&gt;
//////////////////////////////////&lt;br /&gt;
var device_id     = &amp;quot;NB100xxx&amp;quot;;     // Your device ID&lt;br /&gt;
var    user       = &amp;quot;****&amp;quot;;         // Your NearBus Web user&lt;br /&gt;
var pass          = &amp;quot;****&amp;quot;;         // Your NearBus Web password&lt;br /&gt;
var LOOP_DELAY    = 2000;&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    window.onload = function ()&lt;br /&gt;
    {&lt;br /&gt;
        ///////////////////////////////////&lt;br /&gt;
        // Function: Main Loop&lt;br /&gt;
        ///////////////////////////////////&lt;br /&gt;
        setInterval( function()&lt;br /&gt;
        {&lt;br /&gt;
            ret = NearAPIjs( &amp;quot;ADC_INPUT&amp;quot;, device_id , 0, 0, &amp;quot;RONLY&amp;quot; );&lt;br /&gt;
            if( ret != &amp;quot;WAIT&amp;quot; ) {&lt;br /&gt;
                var temperature = ( ret * (5000/1023) / 10 ); &lt;br /&gt;
                $('#field_1').text( temperature.toString() );    &lt;br /&gt;
            }&lt;br /&gt;
        }, LOOP_DELAY );                &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body bgcolor=&amp;quot;#000&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;text-align:center; width:950px&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;http://nearbus.net/images/logo_nearbus.png&amp;quot; width=&amp;quot;140&amp;quot; heisgth=&amp;quot;78&amp;quot;&amp;lt;/div&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;text-align:center; width:950px; font: bold 60px Arial; color:orange;&amp;quot;&amp;gt;TEMPERATURE CHART&amp;lt;/div&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- this line embed a 750 x 400px feed chart form www.xively.com (former cosm.com) --&amp;gt; &lt;br /&gt;
&amp;lt;!-- you should replace the &amp;quot;feed&amp;quot; and the &amp;quot;zone&amp;quot; in order to get the chart from www.xively.com  --&amp;gt; &lt;br /&gt;
&amp;lt;div id=&amp;quot;div_temp_chart_cm&amp;quot;&amp;gt; &amp;lt;img src=&amp;quot;https://api.cosm.com/v2/feeds/***your_feed_here***/datastreams/0.png?width=750&amp;amp;height=400&amp;amp;colour=%23f15a24&amp;amp;duration=3hours&amp;amp;show_axis_labels=true&amp;amp;detailed_grid=true&amp;amp;timezone=***your_zone_here***&amp;quot; &amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;text-align:center; width:950px; font: bold 60px Arial; color:orange;&amp;quot;&amp;gt;celsius&amp;lt;/div&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div id=&amp;quot;field_1&amp;quot; style=&amp;quot;text-align:center; width:950px; font: bold 300px Arial; color:orange;&amp;quot;&amp;gt;. . . .&amp;lt;/div&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nearwiki</name></author>	</entry>

	</feed>