parent
a9d3ab68f0
commit
28b3a21126
@ -0,0 +1,196 @@ |
||||
#include <SPI.h> |
||||
|
||||
const int slavePIN = 4; |
||||
|
||||
// set up the speed, data order and data mode
|
||||
SPISettings settingsSPI(1000000, MSBFIRST, SPI_MODE3);
|
||||
|
||||
const int VOLTAGE_SCALE = 675; //680
|
||||
const float CURRENT_SCALE = 31.5; //250
|
||||
const int RMS_VOLTAGE_ADDRESS = 0x2C; |
||||
const int RMS_CURRENT_ADDRESS = 0x3F; |
||||
const int STATUS_BITS = 0x1A; |
||||
|
||||
|
||||
|
||||
// Include the ESP8266 WiFi library. (Works a lot like the
|
||||
// Arduino WiFi library.)
|
||||
#include <ESP8266WiFi.h> |
||||
// Include the SparkFun Phant library.
|
||||
#include <Phant.h> |
||||
|
||||
//////////////////////
|
||||
// WiFi Definitions //
|
||||
//////////////////////
|
||||
const char WiFiSSID[] = "****SSID****"; |
||||
const char WiFiPSK[] = "****PASS****"; |
||||
|
||||
/////////////////////
|
||||
// Pin Definitions //
|
||||
/////////////////////
|
||||
const int LED_PIN = 2; // Thing's onboard, green LED
|
||||
|
||||
////////////////
|
||||
// Phant Keys //
|
||||
////////////////
|
||||
const char PhantHost[] = "data.sparkfun.com"; |
||||
const char PublicKey[] = "2J8dEzMvpGhoAXg3zy6E"; |
||||
const char PrivateKey[] = "GPpYDNwBjgFn1aEvprM8"; |
||||
|
||||
/////////////////
|
||||
// Post Timing //
|
||||
/////////////////
|
||||
const unsigned long postRate = 10000; |
||||
unsigned long lastPost = 0; |
||||
|
||||
|
||||
|
||||
#include "RunningMedian.h" |
||||
const int sampleCount = 11; |
||||
RunningMedian voltageSamples = RunningMedian(sampleCount); |
||||
RunningMedian currentSamples = RunningMedian(sampleCount); |
||||
|
||||
|
||||
|
||||
|
||||
void setup() { |
||||
Serial.begin(115200); |
||||
// pinMode(DIGITAL_PIN, INPUT_PULLUP);
|
||||
pinMode(LED_PIN, OUTPUT); |
||||
digitalWrite(LED_PIN, LOW); |
||||
|
||||
|
||||
connectWiFi(); |
||||
Serial.begin(115200); |
||||
|
||||
|
||||
// set the Slave Select Pins as outputs:
|
||||
pinMode (slavePIN, OUTPUT); |
||||
digitalWrite (slavePIN, HIGH); |
||||
// initialize SPI:
|
||||
SPI.begin();
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
void loop() |
||||
{ |
||||
|
||||
if (lastPost + postRate <= millis()) |
||||
{ |
||||
if (postToPhant()) |
||||
lastPost = millis(); |
||||
else |
||||
delay(100); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
int32_t readSPI(uint8_t address) { |
||||
|
||||
uint8_t val0, val1, val2; |
||||
int32_t result; |
||||
|
||||
// read three bytes from device A
|
||||
SPI.beginTransaction(settingsSPI); |
||||
digitalWrite (slavePIN, LOW); |
||||
// reading only, so data sent does not matter
|
||||
SPI.transfer(0x01); |
||||
SPI.transfer(address << 2); |
||||
val0 = SPI.transfer(0); |
||||
val1 = SPI.transfer(0); |
||||
val2 = SPI.transfer(0); |
||||
digitalWrite (slavePIN, HIGH); |
||||
SPI.endTransaction(); |
||||
|
||||
result = (val0 << 8) | val1; |
||||
result = (result << 8) | val2; |
||||
|
||||
return result; |
||||
|
||||
} |
||||
|
||||
|
||||
void connectWiFi() |
||||
{ |
||||
byte ledStatus = LOW; |
||||
|
||||
// Set WiFi mode to station (as opposed to AP or AP_STA)
|
||||
WiFi.mode(WIFI_STA); |
||||
|
||||
// WiFI.begin([ssid], [passkey]) initiates a WiFI connection
|
||||
// to the stated [ssid], using the [passkey] as a WPA, WPA2,
|
||||
// or WEP passphrase.
|
||||
WiFi.begin(WiFiSSID, WiFiPSK); |
||||
|
||||
// Use the WiFi.status() function to check if the ESP8266
|
||||
// is connected to a WiFi network.
|
||||
while (WiFi.status() != WL_CONNECTED) |
||||
{ |
||||
// Blink the LED
|
||||
digitalWrite(LED_PIN, ledStatus); // Write LED high/low
|
||||
ledStatus = (ledStatus == HIGH) ? LOW : HIGH; |
||||
|
||||
// Delays allow the ESP8266 to perform critical tasks
|
||||
// defined outside of the sketch. These tasks include
|
||||
// setting up, and maintaining, a WiFi connection.
|
||||
delay(100); |
||||
// Potentially infinite loops are generally dangerous.
|
||||
// Add delays -- allowing the processor to perform other
|
||||
// tasks -- wherever possible.
|
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
int postToPhant() |
||||
{ |
||||
// LED turns on when we enter, it'll go off when we
|
||||
// successfully post.
|
||||
digitalWrite(LED_PIN, HIGH); |
||||
|
||||
// Declare an object from the Phant library - phant
|
||||
Phant phant(PhantHost, PublicKey, PrivateKey); |
||||
|
||||
for (int i = 1; i <= sampleCount; i++) { |
||||
while (1) { |
||||
// Wait for DRDY
|
||||
if (bitRead(readSPI(STATUS_BITS), 23)) |
||||
break; |
||||
} |
||||
|
||||
voltageSamples.add((readSPI(RMS_VOLTAGE_ADDRESS)/pow(2, 23)) * VOLTAGE_SCALE); |
||||
currentSamples.add((readSPI(RMS_CURRENT_ADDRESS)/pow(2, 23)) * CURRENT_SCALE); |
||||
delay(20); |
||||
} |
||||
|
||||
phant.add("voltage", voltageSamples.getMedian()); |
||||
phant.add("current", currentSamples.getMedian()); |
||||
|
||||
// Now connect to data.sparkfun.com, and post our data:
|
||||
WiFiClient client; |
||||
const int httpPort = 80; |
||||
if (!client.connect(PhantHost, httpPort)) |
||||
{ |
||||
// If we fail to connect, return 0.
|
||||
return 0; |
||||
} |
||||
// If we successfully connected, print our Phant post:
|
||||
client.print(phant.post()); |
||||
|
||||
// Read all the lines of the reply from server and print them to Serial
|
||||
while (client.available()) { |
||||
String line = client.readStringUntil('\r'); |
||||
Serial.print(line); // Trying to avoid using serial
|
||||
} |
||||
|
||||
// Before we exit, turn the LED off.
|
||||
digitalWrite(LED_PIN, LOW); |
||||
|
||||
return 1; // Return success
|
||||
} |
||||
|
@ -0,0 +1,103 @@ |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<!-- EXTERNAL LIBS--> |
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
||||
<script src="https://www.google.com/jsapi"></script> |
||||
|
||||
<!-- EXAMPLE SCRIPT --> |
||||
<script> |
||||
|
||||
|
||||
|
||||
// onload callback |
||||
function drawChart() { |
||||
|
||||
// var volt, amp; |
||||
|
||||
var public_key = '2J8dEzMvpGhoAXg3zy6E'; |
||||
|
||||
// JSONP request |
||||
var jsonData = $.ajax({ |
||||
url: 'https://data.sparkfun.com/output/' + public_key + '.json', |
||||
data: { |
||||
'gte': { |
||||
// 'timestamp': 'now - 1 day', |
||||
'timestamp': 'now - 186 hour', |
||||
'current': 0.05, |
||||
'voltage': 200, |
||||
}, |
||||
'lte': { |
||||
'timestamp': 'now - 174 hour', |
||||
}, |
||||
}, |
||||
cache: true, |
||||
dataType: 'jsonp', |
||||
}); |
||||
|
||||
jsonData.done(function (results) { |
||||
|
||||
var data = new google.visualization.DataTable(); |
||||
|
||||
data.addColumn('datetime', 'Time'); |
||||
data.addColumn('number', 'RMS Voltage [V]'); |
||||
data.addColumn('number', 'RMS Current [A]'); |
||||
|
||||
$.each(results, function (i, row) { |
||||
var date = (new Date(row.timestamp)); |
||||
var voltage = parseFloat(row.voltage); |
||||
var current = parseFloat(row.current); |
||||
|
||||
// The last measurement |
||||
if (i == 0) { |
||||
var va = voltage * current; |
||||
// console.log(voltage + " V; " + current + " A; " + va + " VA; @ " + date); |
||||
$('#va').html("Last measured apparent power: <strong>" + va.toFixed(4) + " VA</strong>"); |
||||
} |
||||
|
||||
data.addRow([date, voltage, current]); |
||||
}); |
||||
|
||||
var chart = new google.visualization.LineChart($('#chart').get(0)); |
||||
|
||||
chart.draw(data, { |
||||
// title: 'ESP8266 Thing Example Stream', |
||||
hAxis: {format: 'HH:mm:ss'}, |
||||
vAxes:[ |
||||
{title: 'Voltage (blue)', maxValue: 255}, // Left axis |
||||
{title: 'Current (red)'} // Right axis |
||||
], |
||||
series:[ |
||||
{targetAxisIndex:0}, |
||||
{targetAxisIndex:1} |
||||
], |
||||
}); |
||||
|
||||
$('#relay').visible(); |
||||
|
||||
}); |
||||
|
||||
} |
||||
|
||||
// load chart lib |
||||
google.load('visualization', '1', { |
||||
packages: ['corechart'] |
||||
}); |
||||
|
||||
// call drawChart once google charts is loaded |
||||
google.setOnLoadCallback(drawChart); |
||||
|
||||
|
||||
|
||||
|
||||
</script> |
||||
|
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 100%;"></div> |
||||
<div id="va" style="font-size: 3em; margin: 0 100px; "></div> |
||||
<div id="relay" style="visibility: hidden; font-size: 2em; margin: 50px 100px; "> |
||||
<stron>Relay: </stron><input type="button" value="Turn OFF" /> |
||||
</div> |
||||
</body> |
||||
</html> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@ |
||||
####################################################################### |
||||
## |
||||
## CGI modules |
||||
## --------------- |
||||
## |
||||
## http://www.lighttpd.net/documentation/cgi.html |
||||
## |
||||
server.modules += ( "mod_cgi" ) |
||||
|
||||
## |
||||
## Plain old CGI handling |
||||
## |
||||
## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini. |
||||
## |
||||
cgi.assign = ( ".pl" => "/usr/bin/perl", |
||||
".cgi" => "/usr/bin/perl", |
||||
".rb" => "/usr/bin/ruby", |
||||
".erb" => "/usr/bin/eruby", |
||||
".py" => "/usr/bin/python", |
||||
".php" => "/usr/bin/php-cgi" ) |
||||
|
||||
## |
||||
## to get the old cgi-bin behavior of apache |
||||
## |
||||
## Note: make sure that mod_alias is loaded if you uncomment the |
||||
## next line. (see modules.conf) |
||||
## |
||||
#alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" ) |
||||
#$HTTP["url"] =~ "^/cgi-bin" { |
||||
# cgi.assign = ( "" => "" ) |
||||
#} |
||||
|
||||
## |
||||
####################################################################### |
@ -0,0 +1,36 @@ |
||||
|
||||
config dnsmasq |
||||
option domainneeded '1' |
||||
option boguspriv '1' |
||||
option filterwin2k '0' |
||||
option localise_queries '1' |
||||
option rebind_protection '1' |
||||
option rebind_localhost '1' |
||||
option local '/lan/' |
||||
option domain 'lan' |
||||
option expandhosts '1' |
||||
option nonegcache '0' |
||||
option authoritative '1' |
||||
option readethers '1' |
||||
option leasefile '/tmp/dhcp.leases' |
||||
option resolvfile '/tmp/resolv.conf.auto' |
||||
option localservice '1' |
||||
|
||||
config dhcp 'lan' |
||||
option interface 'lan' |
||||
option start '100' |
||||
option limit '150' |
||||
option leasetime '12h' |
||||
option dhcpv6 'server' |
||||
option ra 'server' |
||||
option ignore '1' |
||||
|
||||
config dhcp 'wan' |
||||
option interface 'wan' |
||||
option ignore '1' |
||||
|
||||
config odhcpd 'odhcpd' |
||||
option maindhcp '0' |
||||
option leasefile '/tmp/hosts/odhcpd' |
||||
option leasetrigger '/usr/sbin/odhcpd-update' |
||||
|
@ -0,0 +1,15 @@ |
||||
|
||||
config interface 'loopback' |
||||
option ifname 'lo' |
||||
option proto 'static' |
||||
option ipaddr '127.0.0.1' |
||||
option netmask '255.0.0.0' |
||||
|
||||
config globals 'globals' |
||||
option ula_prefix 'fd78:9aef:9e52::/48' |
||||
|
||||
config interface 'lan' |
||||
option ifname 'eth0 eth1' |
||||
option type 'bridge' |
||||
option proto 'dhcp' |
||||
|
@ -0,0 +1,25 @@ |
||||
|
||||
config system |
||||
option hostname 'OpenWrt' |
||||
option timezone 'CET-1CEST' |
||||
|
||||
config timeserver 'ntp' |
||||
list server '0.openwrt.pool.ntp.org' |
||||
list server '1.openwrt.pool.ntp.org' |
||||
list server '2.openwrt.pool.ntp.org' |
||||
list server '3.openwrt.pool.ntp.org' |
||||
option enabled '1' |
||||
option enable_server '0' |
||||
|
||||
config led 'led_lan' |
||||
option name 'LAN' |
||||
option sysfs 'gl-connect:green:lan' |
||||
option trigger 'netdev' |
||||
option dev 'eth1' |
||||
option mode 'link tx rx' |
||||
|
||||
config led 'led_wlan' |
||||
option name 'WLAN' |
||||
option sysfs 'gl-connect:red:wlan' |
||||
option trigger 'phy0tpt' |
||||
|
@ -0,0 +1,321 @@ |
||||
[PHP] |
||||
|
||||
zend.ze1_compatibility_mode = Off |
||||
|
||||
; Language Options |
||||
|
||||
engine = On |
||||
;short_open_tag = Off |
||||
precision = 12 |
||||
y2k_compliance = On |
||||
output_buffering = Off |
||||
;output_handler = |
||||
zlib.output_compression = Off |
||||
;zlib.output_compression_level = -1 |
||||
;zlib.output_handler = |
||||
implicit_flush = Off |
||||
unserialize_callback_func = |
||||
serialize_precision = 100 |
||||
|
||||
;open_basedir = |
||||
disable_functions = |
||||
disable_classes = |
||||
|
||||
; Colors for Syntax Highlighting mode. Anything that's acceptable in |
||||
; <span style="color: ???????"> would work. |
||||
;highlight.string = #DD0000 |
||||
;highlight.comment = #FF9900 |
||||
;highlight.keyword = #007700 |
||||
;highlight.bg = #FFFFFF |
||||
;highlight.default = #0000BB |
||||
;highlight.html = #000000 |
||||
|
||||
;ignore_user_abort = On |
||||
;realpath_cache_size = 16k |
||||
;realpath_cache_ttl = 120 |
||||
|
||||
; Miscellaneous |
||||
|
||||
expose_php = On |
||||
|
||||
; Resource Limits |
||||
|
||||
max_execution_time = 30 ; Maximum execution time of each script, in seconds. |
||||
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data. |
||||
;max_input_nesting_level = 64 |
||||
memory_limit = 8M ; Maximum amount of memory a script may consume. |
||||
|
||||
; Error handling and logging |
||||
|
||||
; Error Level Constants: |
||||
; E_ALL - All errors and warnings (includes E_STRICT as of PHP 6.0.0) |
||||
; E_ERROR - fatal run-time errors |
||||
; E_RECOVERABLE_ERROR - almost fatal run-time errors |
||||
; E_WARNING - run-time warnings (non-fatal errors) |
||||
; E_PARSE - compile-time parse errors |
||||
; E_NOTICE - run-time notices (these are warnings which often result |
||||
; from a bug in your code, but it's possible that it was |
||||
; intentional (e.g., using an uninitialized variable and |
||||
; relying on the fact it's automatically initialized to an |
||||
; empty string) |
||||
; E_STRICT - run-time notices, enable to have PHP suggest changes |
||||
; to your code which will ensure the best interoperability |
||||
; and forward compatibility of your code |
||||
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup |
||||
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's |
||||
; initial startup |
||||
; E_COMPILE_ERROR - fatal compile-time errors |
||||
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) |
||||
; E_USER_ERROR - user-generated error message |
||||
; E_USER_WARNING - user-generated warning message |
||||
; E_USER_NOTICE - user-generated notice message |
||||
; E_DEPRECATED - warn about code that will not work in future versions |
||||
; of PHP |
||||
; E_USER_DEPRECATED - user-generated deprecation warnings |
||||
; |
||||
; Common Values: |
||||
; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.) |
||||
; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices) |
||||
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) |
||||
; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.) |
||||
; Default Value: E_ALL & ~E_NOTICE |
||||
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT |
||||
|
||||
display_errors = On |
||||
display_startup_errors = Off |
||||
log_errors = Off |
||||
log_errors_max_len = 1024 |
||||
ignore_repeated_errors = Off |
||||
ignore_repeated_source = Off |
||||
report_memleaks = On |
||||
;report_zend_debug = 0 |
||||
track_errors = Off |
||||
;html_errors = Off |
||||
;docref_root = "/phpmanual/" |
||||
;docref_ext = .html |
||||
;error_prepend_string = "<font color=#ff0000>" |
||||
;error_append_string = "</font>" |
||||
; Log errors to specified file. |
||||
;error_log = /var/log/php_errors.log |
||||
; Log errors to syslog. |
||||
;error_log = syslog |
||||
|
||||
; Data Handling |
||||
|
||||
;arg_separator.output = "&" |
||||
;arg_separator.input = ";&" |
||||
variables_order = "EGPCS" |
||||
request_order = "GP" |
||||
register_globals = Off |
||||
register_long_arrays = Off |
||||
register_argc_argv = On |
||||
auto_globals_jit = On |
||||
post_max_size = 8M |
||||
;magic_quotes_gpc = Off |
||||
magic_quotes_runtime = Off |
||||
magic_quotes_sybase = Off |
||||
auto_prepend_file = |
||||
auto_append_file = |
||||
default_mimetype = "text/html" |
||||
;default_charset = "iso-8859-1" |
||||
;always_populate_raw_post_data = On |
||||
|
||||
; Paths and Directories |
||||
|
||||
; UNIX: "/path1:/path2" |
||||
;include_path = ".:/php/includes" |
||||
doc_root = "/www" |
||||
user_dir = |
||||
extension_dir = "/usr/lib/php" |
||||
enable_dl = On |
||||
;cgi.force_redirect = 1 |
||||
;cgi.nph = 1 |
||||
;cgi.redirect_status_env = ; |
||||
cgi.fix_pathinfo=1 |
||||
;fastcgi.impersonate = 1; |
||||
;fastcgi.logging = 0 |
||||
;cgi.rfc2616_headers = 0 |
||||
|
||||
; File Uploads |
||||
|
||||
file_uploads = On |
||||
upload_tmp_dir = "/tmp" |
||||
upload_max_filesize = 2M |
||||
max_file_uploads = 20 |
||||
|
||||
; Fopen wrappers |
||||
|
||||
allow_url_fopen = On |
||||
allow_url_include = Off |
||||
;from="john@doe.com" |
||||
;user_agent="PHP" |
||||
default_socket_timeout = 60 |
||||
;auto_detect_line_endings = Off |
||||
|
||||
; Dynamic Extensions |
||||
|
||||
;extension=ctype.so |
||||
;extension=curl.so |
||||
;extension=dom.so |
||||
;extension=exif.so |
||||
;extension=ftp.so |
||||
;extension=gd.so |
||||
;extension=gmp.so |
||||
;extension=hash.so |
||||
;extension=iconv.so |
||||
;extension=json.so |
||||
;extension=ldap.so |
||||
;extension=mbstring.so |
||||
;extension=mcrypt.so |
||||
;extension=mysql.so |
||||
;extension=openssl.so |
||||
;extension=pcre.so |
||||
;extension=pdo.so |
||||
;extension=pdo-mysql.so |
||||
;extension=pdo-pgsql.so |
||||
;extension=pdo_sqlite.so |
||||
;extension=pgsql.so |
||||
;extension=session.so |
||||
;extension=soap.so |
||||
;extension=sockets.so |
||||
;extension=sqlite.so |
||||
;extension=sqlite3.so |
||||
;extension=tokenizer.so |
||||
;extension=xml.so |
||||
;extension=xmlreader.so |
||||
;extension=xmlwriter.so |
||||
|
||||
; Module Settings |
||||
|
||||
[APC] |
||||
apc.enabled = 1 |
||||
apc.shm_segments = 1 ;The number of shared memory segments to allocate for the compiler cache. |
||||
apc.shm_size = 4M ;The size of each shared memory segment. |
||||
|
||||
[Date] |
||||
date.timezone = 'Europe/Bratislava' |
||||
;date.default_latitude = 31.7667 |
||||
;date.default_longitude = 35.2333 |
||||
;date.sunrise_zenith = 90.583333 |
||||
;date.sunset_zenith = 90.583333 |
||||
|
||||
[filter] |
||||
;filter.default = unsafe_raw |
||||
;filter.default_flags = |
||||
|
||||
[iconv] |
||||
;iconv.input_encoding = ISO-8859-1 |
||||
;iconv.internal_encoding = ISO-8859-1 |
||||
;iconv.output_encoding = ISO-8859-1 |
||||
|
||||
[sqlite] |
||||
;sqlite.assoc_case = 0 |
||||
|
||||
[sqlite3] |
||||
;sqlite3.extension_dir = |
||||
|
||||
[Pdo_mysql] |
||||
pdo_mysql.cache_size = 2000 |
||||
pdo_mysql.default_socket= |
||||
|
||||
[MySQL] |
||||
mysql.allow_local_infile = On |
||||
mysql.allow_persistent = On |
||||
mysql.cache_size = 2000 |
||||
mysql.max_persistent = -1 |
||||
mysql.max_links = -1 |
||||
mysql.default_port = |
||||
mysql.default_socket = |
||||
mysql.default_host = |
||||
mysql.default_user = |
||||
mysql.default_password = |
||||
mysql.connect_timeout = 60 |
||||
mysql.trace_mode = Off |
||||
|
||||
[PostgresSQL] |
||||
pgsql.allow_persistent = On |
||||
pgsql.auto_reset_persistent = Off |
||||
pgsql.max_persistent = -1 |
||||
pgsql.max_links = -1 |
||||
pgsql.ignore_notice = 0 |
||||
pgsql.log_notice = 0 |
||||
|
||||
[Session] |
||||
session.save_handler = files |
||||
session.save_path = "/tmp" |
||||
session.use_cookies = 1 |
||||
;session.cookie_secure = |
||||
session.use_only_cookies = 1 |
||||
session.name = PHPSESSID |
||||
session.auto_start = 0 |
||||
session.cookie_lifetime = 0 |
||||
session.cookie_path = / |
||||
session.cookie_domain = |
||||
session.cookie_httponly = |
||||
session.serialize_handler = php |
||||
session.gc_probability = 1 |
||||
session.gc_divisor = 100 |
||||
session.gc_maxlifetime = 1440 |
||||
session.bug_compat_42 = On |
||||
session.bug_compat_warn = On |
||||
session.referer_check = |
||||
session.entropy_length = 0 |
||||
;session.entropy_file = /dev/urandom |
||||
session.entropy_file = |
||||
;session.entropy_length = 16 |
||||
session.cache_limiter = nocache |
||||
session.cache_expire = 180 |
||||
session.use_trans_sid = 0 |
||||
session.hash_function = 0 |
||||
session.hash_bits_per_character = 4 |
||||
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" |
||||
|
||||
[mbstring] |
||||
;mbstring.language = Japanese |
||||
;mbstring.internal_encoding = EUC-JP |
||||
;mbstring.http_input = auto |
||||
;mbstring.http_output = SJIS |
||||
;mbstring.encoding_translation = Off |
||||
;mbstring.detect_order = auto |
||||
;mbstring.substitute_character = none; |
||||
;mbstring.func_overload = 0 |
||||
;mbstring.strict_detection = Off |
||||
;mbstring.http_output_conv_mimetype= |
||||
;mbstring.script_encoding= |
||||
|
||||
[gd] |
||||
;gd.jpeg_ignore_warning = 0 |
||||
|
||||
[exif] |
||||
;exif.encode_unicode = ISO-8859-15 |
||||
;exif.decode_unicode_motorola = UCS-2BE |
||||
;exif.decode_unicode_intel = UCS-2LE |
||||
;exif.encode_jis = |
||||
;exif.decode_jis_motorola = JIS |
||||
;exif.decode_jis_intel = JIS |
||||
|
||||
[soap] |
||||
soap.wsdl_cache_enabled=1 |
||||
soap.wsdl_cache_dir="/tmp" |
||||
soap.wsdl_cache_ttl=86400 |
||||
soap.wsdl_cache_limit = 5 |
||||
|
||||
[sysvshm] |
||||
;sysvshm.init_mem = 10000 |
||||
|
||||
[ldap] |
||||
ldap.max_links = -1 |
||||
|
||||
[mcrypt] |
||||
;mcrypt.algorithms_dir= |
||||
;mcrypt.modes_dir= |
||||
|
||||
[opcache] |
||||
;opcache.memory_consumption=8 ; 8M is the allowed minimum |
||||
;opcache.interned_strings_buffer=1 |
||||
opcache.max_accelerated_files=200 ; 200 is the allowed minimum |
||||
;opcache.revalidate_freq=60 |
||||
;opcache.fast_shutdown=1 |
||||
opcache.enable_cli=1 |
||||
opcache.enable=1 |
||||
;opcache.log_verbosity_level=4 |
@ -0,0 +1,103 @@ |
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<!-- EXTERNAL LIBS--> |
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
||||
<script src="https://www.google.com/jsapi"></script> |
||||
|
||||
<!-- EXAMPLE SCRIPT --> |
||||
<script> |
||||
|
||||
|
||||
|
||||
// onload callback |
||||
function drawChart() { |
||||
|
||||
// var volt, amp; |
||||
|
||||
var public_key = '2J8dEzMvpGhoAXg3zy6E'; |
||||
|
||||
// JSONP request |
||||
var jsonData = $.ajax({ |
||||
url: 'https://data.sparkfun.com/output/' + public_key + '.json', |
||||
data: { |
||||
'gte': { |
||||
// 'timestamp': 'now - 1 day', |
||||
'timestamp': 'now - 186 hour', |
||||
'current': 0.05, |
||||
'voltage': 200, |
||||
}, |
||||
'lte': { |
||||
'timestamp': 'now - 174 hour', |
||||
}, |
||||
}, |
||||
cache: true, |
||||
dataType: 'jsonp', |
||||
}); |
||||
|
||||
jsonData.done(function (results) { |
||||
|
||||
var data = new google.visualization.DataTable(); |
||||
|
||||
data.addColumn('datetime', 'Time'); |
||||
data.addColumn('number', 'RMS Voltage [V]'); |
||||
data.addColumn('number', 'RMS Current [A]'); |
||||
|
||||
$.each(results, function (i, row) { |
||||
var date = (new Date(row.timestamp)); |
||||
var voltage = parseFloat(row.voltage); |
||||
var current = parseFloat(row.current); |
||||
|
||||
// The last measurement |
||||
if (i == 0) { |
||||
var va = voltage * current; |
||||
// console.log(voltage + " V; " + current + " A; " + va + " VA; @ " + date); |
||||
$('#va').html("Last measured apparent power: <strong>" + va.toFixed(4) + " VA</strong>"); |
||||
} |
||||
|
||||
data.addRow([date, voltage, current]); |
||||
}); |
||||
|
||||
var chart = new google.visualization.LineChart($('#chart').get(0)); |
||||
|
||||
chart.draw(data, { |
||||
// title: 'ESP8266 Thing Example Stream', |
||||
hAxis: {format: 'HH:mm:ss'}, |
||||
vAxes:[ |
||||
{title: 'Voltage (blue)', maxValue: 255}, // Left axis |
||||
{title: 'Current (red)'} // Right axis |
||||
], |
||||
series:[ |
||||
{targetAxisIndex:0}, |
||||
{targetAxisIndex:1} |
||||
], |
||||
}); |
||||
|
||||
$('#relay').visible(); |
||||
|
||||
}); |
||||
|
||||
} |
||||
|
||||
// load chart lib |
||||
google.load('visualization', '1', { |
||||
packages: ['corechart'] |
||||
}); |
||||
|
||||
// call drawChart once google charts is loaded |
||||
google.setOnLoadCallback(drawChart); |
||||
|
||||
|
||||
|
||||
|
||||
</script> |
||||
|
||||
</head> |
||||
<body> |
||||
<div id="chart" style="width: 100%;"></div> |
||||
<div id="va" style="font-size: 3em; margin: 0 100px; "></div> |
||||
<div id="relay" style="visibility: hidden; font-size: 2em; margin: 50px 100px; "> |
||||
<stron>Relay: </stron><input type="button" value="Turn OFF" /> |
||||
</div> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue