![sparkfun Wimp Скачать руководство пользователя страница 21](http://html1.mh-extra.com/html/sparkfun/wimp/wimp_manual_1339705021.webp)
dewPoint = dewPoint * 9 / 5.0 + 32;
//server.log("rh=" + relativeHu " tempF=" + tempF + " tempC=" + tempC);
//server.log("DewPoint = " + dewPoint);
return
(dewPoint );
}
function
checkMidnight (ignore ) {
//Check to see if it's midnight. If it is, send @ to Arduino to reset time based variables
//Get the local time that this measurement was taken
local
localTime = calcLocalTime ();
//server.log("Local hour = " + format("%c", localTime[0]) + format("%c", localTime[1]));
if
(localTime [0].tochar () == "0" && localTime [1].tochar () == "4")
{
if
(midnightReset ==
false
)
{
server .log("Sending midnight reset" );
midnightReset =
true
;
//We should only reset once
device .send("sendMidnightReset" , 1);
}
}
else
{
midnightReset =
false
;
//Reset our state
}
}
//Recording to a google doc is a bit tricky. Many people have found ways of posting
//to a google form to get data into a spreadsheet. This requires a https connection
//so we use pushingbox to handle the secure connection.
//See http://productforums.google.com/forum/#!topic/docs/f4hJKF1OQOw for more info
//To push two items I had to use a GET instead of a post
function
recordLevels (batt, light ) {
//Smash it all together
local
stringToSend = "http://api.pushingbox.com/pushingbox?devid=vB0A3446EBB4828F"
;
stringToSend = stringToSend + "&" + batt;
stringToSend = stringToSend + "&" + light ;
//server.log("string to send: " + stringToSend); //Debugging
//Push to internet
local
request = http.post(stringToSend , {}, "");
local
response = request .sendsync ();
//server.log("Google response=" + response.body);
server .log("Post to spreadsheet complete." )
}
//Given pressure in pascals, convert the pressure to Altimeter Setting, inches mercury
function
convertToInHg (pressure_Pa )
{
local
pressure_mb = pressure_Pa / 100;
//pressure is now in millibars, 1 pascal = 0.01 millibars
local
part1 = pressure_mb - 0.3;
//Part 1 of formula
local
part2 = 8.42288 / 100000.0 ;
local
part3 = math .pow((pressure_mb - 0.3), 0.190284 );
local
part4 = LOCAL_ALTITUDE_METERS / part3 ;
local
part5 = (1.0 + (part2 * part4 ));
local
part6 = math .pow(part5 , (1.0/0.190284 ));
local
altimeter_setting_pressure_mb = part1 * part6 ;
//Output is now in adjusted millibars
local
baromin = altimeter_setting_pressure_mb * 0.02953 ;
//server.log(format("%s", baromin));
return
(baromin );
}
//From Hugo: http://forums.electricimp.com/discussion/915/processing-nmea-0183-gps-strings/p1
//You rock! Thanks Hugo!
function
mysplit (a, b) {
local
ret = [];
local
field = "";
foreach
(c
in
a) {
if
(c == b) {
// found separator, push field
ret .push(field);
field ="";
}
else
{
field += c.tochar ();
// append to field
}
}
// Push the last field
ret .push(field);
return
ret;