Brett,
Would you consider adding support for Thingspeak - Its an opensource Xively alternative.
API Reference - https://uk.mathworks.com/help/thingspeak/api-reference.html
thanks
Brett,
Would you consider adding support for Thingspeak - Its an opensource Xively alternative.
API Reference - https://uk.mathworks.com/help/thingspeak/api-reference.html
thanks
Member for
15 years 7 monthsAndrew,this should be doable
Andrew,
this should be doable with a plugboard script.
I am worried about the direction xively is heading too so I might have a crack at this myself when time allows.
I'll see if I can knock up a script at the weekend
Garry
Member for
13 years 11 monthsHi Garry,That sounds like a
Hi Garry,
That sounds like a plan
Thanks
Andeew
Member for
16 years 10 monthsGary,I can give you some
Gary,
I can give you some hellp. My free time at the moment is stil consumed with work.
Companies don't seem to realize that laying people off may reduce expenses however it does not reduce the work !
Member for
15 years 7 monthsThanks Brett, I'm sure you
Thanks Brett, I'm sure you will be able to tidy my efforts up a bit when I'm done.
I now have a script uploading data to thing speak, will stress test it and post at weekend if all remains well.
thingspeak does look good, especially the ability to multi plot, etc.
I understand your work issues, I'm going through a bit of that myself. Who needs hobbies and play time anyhow :(
Garry
Member for
15 years 7 monthsThanks Brett, I'm sure you
Thanks Brett, I'm sure you will be able to tidy my efforts up a bit when I'm done.
I now have a script uploading data to thing speak, will stress test it and post at weekend if all remains well.
thingspeak does look good, especially the ability to multi plot, etc.
I understand your work issues, I'm going through a bit of that myself. Who needs hobbies and play time anyhow :(
Garry
Member for
15 years 7 monthsSorry, posting from ipad so
Sorry, posting from ipad so file is posted long hand in post - not attached.
please treat as beta and change API key before use. Also setup your fields in thing speak beforehand.
any probs/questions let me know!
attached is applet to upload to thing speak
garry
--[[
xAP Caching and Thingspeak interface
--]]
module(...,package.seeall)
require("xap")
require("pl.stringx").import()
require("pl.pretty")
socket = require("socket")
info={
version="1.0", description="xAP to Thingspeak applet"
}
local fields = {
{source = "dbzoo.RaspPi.Plugboard:HouseAveTemp",class = "xAPBSC.event",section = "input.state",value = "text"},
{source = "dbzoo.RaspPi.Controller:1wire.1",class = "xAPBSC.event",section = "input.state",value = "text"}
}
local APIKey = "xxxxxxxxxxxxxx"
local vfs = {
filter={},
data={}
}
for i,k in ipairs(fields) do
vfs.filter[i] = xap.Filter{["xap-header"] = {
source=fields[i]["source"],
class=fields[i]["class"] }}
end
function updateCache(frame)
for i,k in ipairs(fields) do
if frame:getValue("xap-header","source") == fields[i]["source"] then
vfs.data[i] = frame:getValue(fields[i]["section"],fields[i]["value"])
end
end
end
function send()
local host, port = "api.thingspeak.com", 80
client = socket.tcp()
client:connect(host, port)
local fieldtext = ""
for i,k in ipairs(fields) do
if vfs.data[i] then
fieldtext = fieldtext.."&field"..i.."="..vfs.data[i]
else end
end
client:send("GET /update?api_key="..APIKey..fieldtext
.. " HTTP/1.1\r\n"
.. "Host: api.thingspeak.com\r\n"
.. "Connection: close\r\n"
.. "Accept: */*\r\n"
.. "User-Agent: Mozilla/4.0 (compatible; Lua; Windows NT 5.1)\r\n"
.. "\r\n")
end
function init()
for _,k in pairs(vfs.filter) do
k:callback(updateCache)
end
xap.Timer(send, 60):start(false)
end
Member for
13 years 11 monthsExcellent work Garry :)my
Excellent work Garry :)
my quick test feed for the 1Wires - https://thingspeak.com/channels/87676
I had to create the channels / fields first to access an additional API key for writing to the channel but after this the feed data appeared
thanks
Andrew
Member for
13 years 11 monthsGarry,I hope you dont mind, I
Garry,
I hope you dont mind, I made a few modifications to your script to allow it to be used with OpenEnergyMonitors EmonCMS http://www.emoncms.org
Emoncms contains some very nice built in apps for historical power logging plus a matching android app.
As above set you own API key / Endpoints / Update timer.
Thanks
Andrew
Member for
15 years 7 monthsNot at all. Glad it was of
Not at all. Glad it was of some use.
Member for
15 years 11 monthsHelp sought
I am using the lua script for reporting to Thingspeak, but it doesnt seem to work with on/off states from the pir sensor.I can find the code where it is converted for xively
now = 1;
But I don't know how to convert this to lua. Could an expert assist me?
Member for
16 years 10 monthsI think you need an amendment
I think you need an amendment to Gary's code to handle on/off (this code is untested)
function updateCache(frame)
for i,k in ipairs(fields) do
if frame:getValue("xap-header","source") == fields[i]["source"] then
vfs.data[i] = frame:getValue(fields[i]["section"],fields[i]["value"])
if vfs.data[i] == "on" then vfs.data[i] = 1 end
if vfs.data[i] == "off" then vfs.data[i] = 0 end
end
end
end
Member for
15 years 11 monthsThank you...
I have tried this but still not appearing. I can see the result coming through on xfx viewer and the message gets through to xively (https://personal.xively.com/feeds/2128585885 - feeds 7 and 8) but not on thingspeak (which I have made public for now https://thingspeak.com/channels/399026 - same feeds ). Attached is my applet with amendment.
In case it was a latching problem I tried changing both on and off to 1's and also tried changing 1 to "1" but neither works.
At the moment I am using ftp for the changes and just rebooting the machine. Maybe next I shall try stopping and starting the applet using ssh and see if I get any errors.
Unless anyone else has any bright idea? .....
Kim
Member for
15 years 11 monthshow irritating is this...
just after I posted I did a final check of what was ftp'd and it was the original file without amendment. So it DOES work exactly as posted by Brett.
So much for doing lots of checks before posting. Sorry.
Member for
15 years 7 monthsThanks For the modification
Thanks for the modification Brett.
I only use it for charting temps so hadn't run into this issue.
Glad it's working for you Kim.
Garry