- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Dear Community,
I would like to ask if someone can help me to Getting started with the Intel Edison Board,
My board is connect with AWS, I created a topic and a rule for store a data ( temperature ) on my DynamoDB.
But I'm not able to create an history of the temperature received from my sensor connect to the board on PIN A0 ( analog PIN)
Problems:
- I cannot read the data inside DynamoDB
- I don't know how to create a appropriate JSON ( I mean the logic structure )
- In this moment, I'm using SNS (I created a rule, of course) for receive an email with a condition ( temperature = 25, send me an email ) WORKS!
Same procedure with DynamoDB, DOESN'T WORK
- How works the thingShadow.publish and the thingShadow logic structure? Very crucial for me
- How works Lambda function?
- What is the best way to use the relational database management system? Also crucial
*****************
*****************************
JAVASCRIPT CODE
****************************
*****************
var awsIot = require('aws-iot-device-sdk'); //require for awsiot
var mraa = require('mraa'); //require mraa for analog/digital read/write
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
/*
* CONFIGURATION varIABLES
* To set your AWS credentials, export them to your environment variables.
* Run the following from the Edison command line:
* export AWS_ACCESS_KEY_ID='AKID'
* export AWS_SECRET_ACCESS_KEY='SECRET'
*/
// AWS IoT variables
var mqttPort = 8883;
var rootPath = '/home/root/awscerts/';
var awsRootCACert = "root-CA.pem.crt";
var awsClientCert = "certificate.pem.crt";
var awsClientPrivateKey = "private.pem.key";
var topicName = "Edison";
var awsClientId = "Edison";
var awsIoTHostAddr = "host";
/*
* Instance AWS variables for use in the application for
* AWS IoT Certificates for secure connection.
*/
var privateKeyPath = rootPath + awsClientPrivateKey;
var clientCertPath = rootPath + awsClientCert;
var rootCAPath = rootPath + awsRootCACert;
/*
*Initializing Device Communication for AWS IoT
*/
var myThingName = 'Edison';
var thingShadows = awsIot.thingShadow({
keyPath: privateKeyPath,
certPath: clientCertPath,
caPath: rootCAPath,
clientId: awsClientId,
region: 'us-west-2'
});
console.log("AWS IoT Device object initialized");
mythingstate = {
"state": {
"reported": {
"ip": "unknown"
}
}
} ;
var networkInterfaces = require( 'os' ).networkInterfaces( );
mythingstate["state"]["reported"]["ip"] = networkInterfaces['wlan0'][0]['address'];
var temperaturePin = new mraa.Aio(2); //setup access analog input Analog pin # 2 (A2)
var temperatureValue = temperaturePin.read(); //read the value of the analog pin
console.log(temperatureValue); //write the value of the analog pin to the console
// calculate temperature
var tmpVoltage = ((temperatureValue*5.0)/1023.0); // convert analog value to voltage
var temperature = (5.26*Math.pow(tmpVoltage,3))-(27.34*Math.pow(tmpVoltage,2))+(68.87*tmpVoltage)-17.81);// convert analog value to voltage
console.log(temperature);
thingShadows.on('connect', function() {
console.log("Connected...");
console.log("Registering...");
thingShadows.register(myThingName);
// An update right away causes a timeout error, so we wait about 2 seconds
setTimeout( function() {
console.log("Updating my IP address...");
clientTokenIP = thingShadows.update(myThingName, mythingstate);
console.log("Update:" + clientTokenIP);
}, 2500 );
// Code below just logs messages for info/debugging
thingShadows.on('status',
function(thingName, stat, clientToken, stateObject) {
console.log('received '+stat+' on '+thingName+': '+
JSON.stringify(stateObject));
});
thingShadows.on('update',
function(thingName, stateObject) {
console.log('received update '+' on '+thingName+': '+
JSON.stringify(stateObject));
});
thingShadows.on('delta',
function(thingName, stateObject) {
console.log('received delta '+' on '+thingName+': '+
JSON.stringify(stateObject));
});
thingShadows.on('timeout',
function(thingName, clientToken) {
console.log('received timeout for '+ clientToken)
});
thingShadows
.on('close', function() {
console.log('close');
});
thingShadows
.on('reconnect', function() {
console.log('reconnect');
});
thingShadows
.on('offline', function() {
console.log('offline');
});
thingShadows
.on('error', function(error) {
console.log('error', error);
});
//Watch for temperature
if(temperature > 35 ){
thingShadows.publish('topic',
'Your room temperature is greater than 35deg C');
}
});
IDE: Intel XD
Language: Javascript
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello Ed_Edison_Pic,
I have never interacted with AWS before but I found a few links that I believe could be of help for you, why don't you check them out? They are:
https://software.intel.com/en-us/articles/connecting-to-amazon-web-services-aws-iot-using-mqtt
https://software.intel.com/en-us/articles/setup-aws-iot-intel-edison-board
https://github.com/intel-iot-devkit/aws-iot-intel
Nevertheless, if you still have doubts after checking those links, I'd suggest you to contact Amazon as they own the support of AWS. You can contact them in https://aws.amazon.com/contact-us/.
-Peter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thank you very much Peter,
May can you provide me more manual or tutorial about that?
I really appreciated your effort to help me, but I'm still waiting some people can help me with AWS application
Best regards and have a nice day,
Edoardo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Unfortunately, the guides I posted above are (to my knowledge) the only ones currently available. As this is strictly related to AWS, I would strongly suggest you to reach out to Amazon as they should be able to provide you a more accurate suggestion.
If you have any other doubts related to Edison, I would be more than happy to assist you.
-Peter.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page