mikecmills2

GroveStreams Electric Imp Quick Start Device

Nov 12th, 2014
1,690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Electric Imp Quick Start Device Code for GroveStreams
  2. // A full "how to" guide for this device can be found at https://www.grovestreams.com/developers/getting_started_elec_imp_quick.html
  3. //
  4.  
  5. // License:
  6. //  Copyright 2014 GroveStreams LLC.
  7. //  Licensed under the Apache License, Version 2.0 (the "License");
  8. //  you may not use this file except in compliance with the License.
  9. //  You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. //  Unless required by applicable law or agreed to in writing, software
  12. //  distributed under the License is distributed on an "AS IS" BASIS,
  13. //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. //  See the License for the specific language governing permissions and
  15. //  limitations under the License.
  16.  
  17. function readData(){
  18.  
  19.     server.log("Sending data to Imp Cloud Agent");
  20.    
  21.     //Gather and pass the data to the Electric Imp Agent running in the cloud
  22.     local data = { id = hardware.getimpeeid(), mac = imp.getmacaddress(), rssi = imp.rssi(),
  23.                    voltage = hardware.voltage(), light = hardware.lightlevel()}
  24.     agent.send("GroveStreams", data);
  25.    
  26.     imp.wakeup(20, readData); //Wakeup every 20 second and read data. Change this value to change your sample frequency.
  27. }
  28.  
  29.  
  30. //Begin executing program
  31. readData();
Add Comment
Please, Sign In to add comment