Ahhh! The Adafruit tutorial strikes again! It’s always great to see services writing libraries for the Imp, so thanks! I’ll move the impTherm X2 over to GroveStreams and check it out!
Hi, nice always looking for things like this. Simple and straight forward.
Is there a way to NOT use a SPI example but a simple script that communicate’s the build in features like imp.rssi(), hardware.voltage(),hardware.lightlevel().
I my case coding is not really my strongest side, hardware is.
Many ppl look at the code, use and modify it to there needs, and test it quick to get a feel how its working together.
Why base it on a SPI board, many don’t have. i prefer testing without connecting 1 wire, if it works ill figure it out :), and grab my soldering iron
Let me take a stab at what you’re looking for and @mmills can correct me if I’m wrong.
In the device code, you’re basically going to remove everything except lines 99 to 102 and also will strip out the temperature leaving a simple (looping) device code of: function poll(){ local data = { id = hardware.getimpeeid(), mac = imp.getmacaddress(), voltage = hardware.voltage()} agent.send("GroveStreams", data); imp.wakeup(20, poll); //Wakeup every 20 second and read data. Change this value to change your sample frequency. } poll();
In the agent code, you’ll want to remove line 59 since you will no longer be passing the temperature from the device: url += "&" + TEMP_STREAM_ID + "=" + data.temp;
This does not give you the other readings (light level and rssi), but I’m hoping the above gives you the basis of what you’re looking for. To add the others, you would need to:
Create those streams in GroveStreams in the same fashion as voltage and temperature were defined
Modify the device code to pass that data to the agent in the “local data=” line
Modify the agent code inserting these values in the URL being passed to GroveStreams (similar in fashion to how the voltage and temperature are passed – just re-insert line 59, but with the new stream name(s) and data point(s)).
I think this is what you want and what @ctmorrisonhvacsp is suggesting. Just change the API_KEY to yours.
Agent:
`
// GroveStreams Settings
API_KEY <- “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”; //Change This!!! Your GS Organization Secret API Key
COMP_NAME <- “Electric+Imp+Simple” //Optionally change. Your GS Component Name (URL encoded. The “+” indicates spaces)
RSSI_STREAM_ID <- “rssi”; //Optionally change. Your GS rssi stream ID
VOLTAGE_STREAM_ID <- “voltage” //Optionally change. Your GS voltage stream ID
LIGHT_STREAM_ID <- “light” //Optionally change. Your GS light stream ID
GroveStreams <- {}; // this makes a 'namespace’
class GroveStreams.Client {
constructor() {
}
function Put(data){
local url = "https"+"://grovestreams.com/api/feed?compId=" + data.mac;
url += "&compName=" + COMP_NAME + "+(" + data.mac + ")";
url += "&api_key=" + API_KEY;
url += "&" + RSSI_STREAM_ID + "=" + data.rssi;
url += "&" + LIGHT_STREAM_ID + "=" + data.light;
url += "&" + VOLTAGE_STREAM_ID + "=" + data.voltage;
//url += "&compTmplId=template1"; //Uncomment to auto register a new component based on the template with ID=template1
local headers = { "Connection":"close", "X-Forwarded-For" : data.mac };
local request = http.put(url, headers, "");
local response = request.sendsync();
if(response.statuscode != 200) {
server.log("error sending message: " + response.body);
return null;
}
}
}
client <- GroveStreams.Client();
//END GroveStreams
device.on(“GroveStreams”, function(data) {
server.log(“Sending data to GS”);
client.Put(data);
});
`
Device:
`
function readData(){
server.log("Sending data to Imp Cloud Agent");
//Gather and pass the data to the Electric Imp Agent running in the cloud
local data = { id = hardware.getimpeeid(), mac = imp.getmacaddress(), rssi = imp.rssi(),
voltage = hardware.voltage(), light = hardware.lightlevel()}
agent.send("GroveStreams", data);
imp.wakeup(20, readData); //Wakeup every 20 second and read data. Change this value to change your sample frequency.
I think the problem is around the secret api key. Did you use the right API key? It should be this one: Feed Put API Key (with auto-registration rights)
If that’s not it, turn on API Tracing (In the GS Studio, Click API Keys, Select the above API key, Click Engage API Tracing). Wait a while until an upload occurs and then paste the result here and I’ll look at it - but, remove the secret key, an other sensitive data, from the tracing before you post it here.
I found that while creating the organization I made a mistake and then the GS didn’t propose for me the API Key(with auto-registration rights).
Thanks a lot