MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Temperature_&_Humidity_Sensor_Pro",
        "continue": "gapcontinue||"
    },
    "query": {
        "pages": {
            "138": {
                "pageid": 138,
                "ns": 0,
                "title": "Reliable Power Switch",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "\nThe following code examples are intended to show you the simple way in which a NearBus enable device can be controlled from a simple Java Script code running on a browser (PC, or mobile device).\n\n\nBecause the NearBus system has been designed to control power devices through internet in a reliable way, these examples explain the different configurations that you can implement in order to increase the reliability in your controlled system.\n\n\n\n=== Motor Switch Code - Basic Example ===\n<br />\n\nThis simple example shows how to implement a basic Internet switch, to control a power load. The code implements the basic NearBus ACK call return in order to confirm that the remote agent has executed the command (at logical level) \n\n\n\nThe following video shows a working implementation of this example\n\n<html><iframe width=\"480\" height=\"360\" src=\"//www.youtube.com/embed/LS5DCB91NTQ?rel=0\" frameborder=\"0\" allowfullscreen></iframe></html>\n<br />\n<br />\n\nIn order to run this code you should copy the following code into a file, save it with html extension and run it in your browser. Additionally you should replace the device_ID, user and password in this file. \n\n\n===EXAMPLE CODE===\n\n<pre>\n<!DOCTYPE html>\n<html>\n<head>\n<script src=\"http://code.jquery.com/jquery-1.9.1.min.js\"></script>\n<script type=\"text/javascript\" src=\"PAGE\" ></script>\n<script type='text/javascript' src='http://nearbus.net/downloads/js_apps/nearapi_v01.js'></script>\n<script>\n\n\n//***********************************************************************\n// USER CONFIGURATION\n//***********************************************************************\nvar device_1     = \"NB100***\";         // Your device ID\nvar user         = \"user\";             // Your NearBus Web user\nvar pass         = \"1234\";             // Your NearBus Web password\n\n\n//***********************************************************************\n// SYSTEM CONFIGURATION\n//***********************************************************************\nvar state_log    = \"Waiting\";\nvar motor_state  = 0;\nvar step_pointer = 10;\nvar ret = 0;\nvar LOOP_DELAY   = 2000;               // Main Loop Delay\n\n\n//***********************************************************************\n// Function: refreshDisplay()\n//***********************************************************************\t\nfunction refreshDisplay()\n{\n\t$('#field_1').text( \"Step_Pointer = \" \t+ step_pointer.toString() );\n\t$('#field_2').text( \"Message = \" \t+ state_log );\t\t\t\n\t$('#field_3').text( \"Return = \" \t+ ret.toString() );\t\t\n\t$('#field_4').text( \"Motor = \" \t\t+ motor_state.toString() );\t\t\n}\n\n\n//********************************\n// Function: MOTOR_ON\n//********************************\t\t\nfunction Motor_On( )\n{\n\tstep_pointer = 100;\n}\n\n//********************************\n// Function: MOTOR_OFF\n//********************************\t\nfunction Motor_Off( )\n{\t\n\tstep_pointer = 200;\n}\n\n\n//********************************\n// Function: Main Loop\n//********************************\t\n$(document).ready( function ()\n{\n\t\n\tsetInterval( function()\n\t{\n\t\tswitch ( step_pointer )\n\t\t{\n\t\t\t//*******************************\n\t\t\t// WAITING\n\t\t\t//*******************************\n\t\t\tcase 10:\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t//*******************************\n\t\t\t//  MOTOR ON\n\t\t\t//*******************************\t\t\t\t\n\t\t\tcase 100:\n\t\t\t\tret = NearAPIjs( \"DIG_OUTPUT\", device_1, 0, 1 );\t\n\n\t\t\t\tif( ret == 1 ) {\n\t\t\t\t\tmotor_state = \"ON\";\n\t\t\t\t\tstep_pointer = 10;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\n\t\t\t\t\t\n\t\t\t//*******************************\n\t\t\t//  MOTOR OFF\n\t\t\t//*******************************\t\t\t\n\t\t\tcase 200:\t\t\t\n\t\t\t\tret = NearAPIjs( \"DIG_OUTPUT\", device_1, 0, 0 );\t\n\n\t\t\t\tif( ret == 0 ) {\n\t\t\t\t\tmotor_state = \"OFF\";\n\t\t\t\t\tstep_pointer = 10;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\n\t\t}\n\t\trefreshDisplay();\n\t\t\n\t}, 1000 );\t\n\t\t\t\t\n});\n\n\n</script>\n</head>\n\n<body>\n\n<!-- *************************************************************************************** -->  \n<!-- *  HTML CODE                                                                          * --> \t\n<!-- *************************************************************************************** --> \n\n<p><b> MOTOR SWITCH DEMO </b></p>\n\n<div id=\"field_1\">field_1</div>\n<br />\n<div id=\"field_2\">field_2</div>\n<br />\n<div id=\"field_3\">field_3</div>\n<br />\n<div id=\"field_4\">field_4</div>\n<br />\n<br />\n<button onclick=\"Motor_On()\">MOTOR ON</button>\n<br />\n<br />\n<button onclick=\"Motor_Off()\">MOTOR OFF</button>\n</body>\n\n</pre>\n\n<br />\n<br />\n<br />\n----\n\n=== Motor Switch Code - Advanced Example ===\n<br />\n\nThis example implements two features in order to increase the system reliability. In this context the reliability should be understood as an improvement in the capacity of all system to guarantee that the remote power switch works as expected, or under failure it will trip to a well-defined state. \n\n\nTo accomplish this behaviour the system implements: \n* A Watch-Dog supervisor code. \n* A current feedback signal (using a non-invasive current transformer). \n\n\nThe two systems work independently to guarantee the system whole reliability. The Watch-Dog code is a simple register counter that increments by one with each state-machine cycle. The Watch-Dog counter is reset with each successful operation and put the system in a \"turn-off\" state when the counter reaches a threshold level. \n\n\nThe current transformer measures the real current that feeds the power load. This signal allows to the control system to know if the load is really working or not and then take the right action. The last versions of NearBus system offers enhanced features like the True RMS function that allows know the true RMS current value of the load. This feature allows calculate the active power that the load is consuming. \n\n\n\n'''Current Feedback'''\n\nTo know if the Motor is running the system measured the current through the \"RMS_INPUT\" service. Before to measure the current, the system configures the remote ADC to a value of 1100mV calling the \"RMS_INPUT_CONFIG\" service (because this example uses a low power motor of only 15 Watts). The measured current is compared with a threshold reference of 10 in order to decide if the Motor is running or not. \n\n\n\n'''Power Calculation'''\n\nIn order to calculate the active Power consumption we use the following parameters: \n\n * V = 220Vac\n * Power Factor = 0.75 (inductive motor)\n * TI Ratio = 5:2 [A/V]\n * Vref ADC 1100mV\n * ADC resolution 10 bits (1023)\n \n '''Power [Watts] = Irms * (1100 / 1023) / 1000 * (5 / 2) * 220 * 0.75'''\n\n\n\nThe following picture shows the prototype used to test this example.\n\n[[File:Motor_switch_01.png|600px]] \n\n\n'''Components:'''\n\n*[[Grove Modules Guide#Grove - Electricity Sensor|Current Transformer]]\n\n*[[Grove Modules Guide#Grove - Relay|Power Relay]]\n\n*[[Arduino Grove Shield|Arduino Grove Shield]]\n\n<br />\n<br />\n===EXAMPLE CODE===\n\n<pre>\n<!DOCTYPE html>\n<html>\n<head>\n<script src=\"http://code.jquery.com/jquery-1.9.1.min.js\"></script>\n<script type=\"text/javascript\" src=\"PAGE\" ></script>\n<script type='text/javascript' src='http://nearbus.net/downloads/js_apps/nearapi_v01.js'></script>\n\n<script>\n\n//***********************************************************************\n// USER CONFIGURATION\n//***********************************************************************\nvar device_1     = \"NB100***\";\t\t// Your device ID\nvar user \t = \"user\";\t\t// Your NearBus Web user\nvar pass \t = \"1234\";\t\t// Your NearBus Web password\n\n\n//***********************************************************************\n// SYSTEM CONFIGURATION\n//***********************************************************************\nvar state_log    = \"Waiting\";\nvar motor_state  = 0;\nvar step_pointer = 10;\nvar my_watch_dog = 0;\nvar ret          = 0;\nvar power        = 0;\nvar LOOP_DELAY   = 2000;\t\t// Main Loop Delay\nvar WATCH_DOG    = 20;\n\n\n//***********************************************************************\n// Function: refreshDisplay()\n//***********************************************************************\t\nfunction refreshDisplay()\n{\n\t$('#field_1').text( \"Step_Pointer = \" \t+ step_pointer.toString() );\n\t$('#field_2').text( \"Message = \" \t+ state_log );\t\t\t\n\t$('#field_3').text( \"Return = \" \t+ ret.toString() );\t\t\n\t$('#field_4').text( \"Watch_Dog = \" \t+ my_watch_dog.toString() );\t\t\n\t$('#field_5').text( \"Motor = \" \t\t+ motor_state.toString() );\t\t\n\t$('#field_6').text( \"Power = \" \t\t+ power.toString() + \" Watts\" );\t\t\t\n}\n\n\n//********************************\n// Function: MOTOR_ON\n//********************************\t\t\nfunction Motor_On( )\n{\n\tstep_pointer = 100;\n}\n\n\n//********************************\n// Function: MOTOR_OFF\n//********************************\t\nfunction Motor_Off( )\n{\t\n\tstep_pointer = 200;\n}\n\n\n//********************************\n// Function: Main Loop\n//********************************\t\n$(document).ready( function ()\n{\n\t\n\tsetInterval( function()\n\t{\n\n\t\t//**************************************************\n\t\t// WATCH DOG CONTROL\n\t\t//**************************************************\n\t\tmy_watch_dog++;\n\t\tif ( my_watch_dog > WATCH_DOG )\t{\n\t\t\tmy_watch_dog = 0;\n\t\t\tstep_pointer = 200;\n\t\t}\t\n\n\t\tswitch ( step_pointer )\n\t\t{\n\t\t\t//*******************************\n\t\t\t// WAITING\n\t\t\t//*******************************\n\t\t\tcase 10:\n\t\t\t\tmy_watch_dog = 0;\n\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t//*******************************\n\t\t\t//  MOTOR ON\n\t\t\t//*******************************\t\t\t\t\n\t\t\tcase 100:\n\t\t\t\tret = NearAPIjs( \"DIG_OUTPUT\", device_1, 0, 1 );\n\n\t\t\t\tif( ret == 1 ) {\n\t\t\t\t\tmy_watch_dog = 0;\n\t\t\t\t\tstep_pointer = 110;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\t\t\n\t\t\tcase 110:\n\t\t\t\tret = NearAPIjs( \"RMS_INPUT_CONFIG\", device_1, 1, 1100 );\t\t\t\t\n\t\t\t\t\n\t\t\t\tif( ret != \"WAIT\" ) {\n\t\t\t\t\tmy_watch_dog = 0;\t\t\t\t\t\n\t\t\t\t\tstep_pointer = 120;\n\t\t\t\t}\n\t\t\t\tbreak;\t\n\t\t\t\t\n\t\t\t\t\n\t\t\tcase 120:\n\t\t\t\tret = NearAPIjs( \"RMS_INPUT\", device_1, 1, 0 );\t\n\n\t\t\t\tif( ret != \"WAIT\" && ret > 10 ) {\n\t\t\t\t\tmotor_state = \"ON\";\n\t\t\t\t\tmy_watch_dog = 0;\t\t\t\t\t\n\t\t\t\t\tstep_pointer = 130;\n\t\t\t\t}\n\t\t\t\tbreak;\t\n\t\t\t\t\n\t\t\t\t\n\t\t\tcase 130:\n\t\t\t\tret = NearAPIjs( \"RMS_INPUT\", device_1, 1, 0 );\n\t\n\t\t\t\tif( ret != \"WAIT\" ) {\n\t\t\t\t\tpower  =  Math.round( ret * (1100 / 1023) / 1000 * (5 / 2) * 220 * 0.75 );\n\t\t\t\t\tmy_watch_dog = 0;\t\t\t\t\t\n\t\t\t\t\tstep_pointer = 130;\n\t\t\t\t}\n\t\t\t\tbreak;\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t//*******************************\n\t\t\t//  MOTOR OFF\n\t\t\t//*******************************\t\t\t\n\t\t\tcase 200:\t\t\t\n\t\t\t\tret = NearAPIjs( \"DIG_OUTPUT\", device_1, 0, 0 );\n\t\n\t\t\t\tif( ret == 0 ) {\n\t\t\t\t\tmy_watch_dog = 0;\n\t\t\t\t\tstep_pointer = 210;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\t\n\t\t\tcase 210:\n\t\t\t\tret = NearAPIjs( \"RMS_INPUT\", device_1, 1, 0 );\t\n\n\t\t\t\tif( ret != \"WAIT\" && ret < 10 ) {\n\t\t\t\t\tmotor_state = \"OFF\";\n\t\t\t\t\tmy_watch_dog = 0;\n\t\t\t\t\tstep_pointer = 10;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t}\n\t\trefreshDisplay();\n\t\t\n\t}, 1000 );\t\n\t\t\t\t\n});\n\n\n\n</script>\n</head>\n\n<body>\n\n<!-- ******************************************************************** -->  \n<!-- *  HTML CODE\t\t\t\t\t \t        * --> \t\n<!-- ******************************************************************** --> \n\n<p><b> MOTOR SWITCH DEMO </b></p>\n\n<div id=\"field_1\">field_1</div>\n<br />\n<div id=\"field_2\">field_2</div>\n<br />\n<div id=\"field_3\">field_3</div>\n<br />\n<div id=\"field_4\">field_4</div>\n<br />\n<div id=\"field_5\">field_5</div>\n<br />\n<div id=\"field_6\">field_6</div>\n<br />\n<br />\n<button onclick=\"Motor_On()\">MOTOR ON</button>\n<br />\n<br />\n<button onclick=\"Motor_Off()\">MOTOR OFF</button>\n\n</body>\n</html>\n</pre>"
                    }
                ]
            },
            "159": {
                "pageid": 159,
                "ns": 0,
                "title": "Resistors Color Code",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "[[File:Resistor_color_codes.jpg|800px]]"
                    }
                ]
            }
        }
    }
}