- Temperature sensor, to A0
- Light sensor, to A1
With the following code, we read values from sensors and send every 2 secs. (in the config) a msg to AWS IoT, containing value read for temperature (C) and light (lux).
Configuration is read from a file (config.js), whose content is:
{
"keyPath" : "/node_app_slot/certs/thunder10-private.pem.key",}
"certPath" : "/node_app_slot/certs/thunder10-certificate.pem.crt",
"caPath" : "/node_app_slot/certs/root-ca.crt",
"region" : "eu-west-1",
"clientId" : "thunder10",
"sleepTime" : 2000
The last piece (config.js) shows you what must be considered a best practice: Keep separated the logic from the configuration, that probably needs to be different from device to device and maybe can change more frequently. This way you need only to replace the config.js file.
The nice thing with Edison is that, if you want to change the configuration, you can simply upload the config.js file Over The Air.
No comments:
Post a Comment