Skip to content

Instantly share code, notes, and snippets.

@emilssolmanis
Created June 16, 2016 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilssolmanis/2854bcc90547b07b3900f1cb26c52620 to your computer and use it in GitHub Desktop.
Save emilssolmanis/2854bcc90547b07b3900f1cb26c52620 to your computer and use it in GitHub Desktop.
function handle_request(code, data)
if code < 0 then
print("failed to post http")
do_it()
else
print("score, sleeping for 1 hour")
node.dsleep(4294967295, nil)
end
end
function read_value()
hx711.init(6, 7)
return hx711.read()
end
function post_value(value)
http.post(
"https://api.thingspeak.com/update.json",
"",
string.format("api_key=FOOBAR&field1=%s", value),
handle_request
)
end
function do_it()
value = read_value()
post_value(value)
end
if not tmr.alarm(0, 15000, tmr.ALARM_SINGLE, do_it) then
print("failed to set up timer")
else
print("starting things in 15s")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment