Follow My Paws

Sometimes we need to send pets with parcel services. How can we be sure they're fine at all times? Take into consideration how baggage.
Victor Altamirano
Published © MIT
Follow My Paws
Difficulty: Intermediate | Type: tutorial | Duration: 3 hours | Views: 270

Things used in this project

Hardware components

Wio LTE US Version - 4G, Cat.1, GNSS, JavaScript(Espruino) Compatible Wio LTE US Version - 4G, Cat.1, GNSS, JavaScript(Espruino) Compatible × 1
SORACOM Air Global IoT SIM SORACOM Air Global IoT SIM × 1
Grove starter kit plus for Intel Edison Grove starter kit plus for Intel Edison × 1
DHT11 Temperature & Humidity Sensor (4 pins) DHT11 Temperature & Humidity Sensor (4 pins) × 1

Software apps and online services

Arduino IDE Arduino IDE × 1
SORACOM Funnel SORACOM Funnel × 1
AWS IoT AWS IoT × 1
AWS Lambda AWS Lambda × 1
AWS SNS AWS SNS × 1
AWS S3 AWS S3 × 1

Hand tools and fabrication machines

10 Pc. Jumper Wire Kit, 5 cm Long 10 Pc. Jumper Wire Kit, 5 cm Long × 1

Story

Follow my paws:

If you have a dog, cat or any pet that needs to go into a kennel when travelling, and be left in the hands of parcel services, you know how stressfull and problematic it is for your precious friends.

The main problem thus is: The horrid care pets get when they are transported in parcel services.

Sometimes we need to send pets with parcel services. How can we be sure they're fine at all times? Take into consideration how baggage is treated.

Always use technology to improve the world, if you are a black hat or gray hat hacker please abstain at this point......... or at least leave your star to make me feel less guilty XP.

Solution:

I will make an integral IoT solution to monitor the pet’s environment, in order to ensure their well-being throughout their journey. All this also integrated with a cloud platform which, in addition to showing the status of the package in real time, also sends notifications at the frequency that is convenient.

The current monitoring solutions are restricted to only lifeless packages, this making the continuous monitoring of pets a novelty. It is useful because thanks to this system pet owners can be 100% sure that their pets will be well and can monitor and follow them throughout their journey.

Materials:

Hardware:

  • WIO Lte.
  • Soracom Air Global IoT SIM Card.
  • DTH11 (Preferably the Grove version). https://www.seeedstudio.com/Grove-Temperature-Humidity-Sensor-DHT11-p-745.html
  • Grove - 3-Axis Digital Accelerometer.
  • Software:

  • Arduino IDE.
  • AWS Cloud Services.
  • Soracom Platform.
  • Hardware Hacking:

    To connect the sensors to the WIO, it is necessary that the sensors have a Grove-type input, such as those shown in the following link.

    https://www.seeedstudio.com/catalogsearch/result/index/?cat=890&q=Grove

    For this project, I already had the "Grove Starter Kit Plus" package which is shown in the following images.

    The Content:

    The connections that were made, were the following:

    The accelerometer included in the Grove package had no problem connecting to the WIO because it already has its Grove adapter, which I had to hack was the DHT, as we did not had the Grove's DHT.

    Accelerometer Grove Version:

    DHT No-Grove Version:

    This is how to connect the module to the grove cable:

    Wio Setup:

    We will prepare the WIO LTE by connecting the SIM card in the appropriate slot.

    Once we locate the Slot of the SIM card, insert the SIM card into the slot (yes, protect your IMEI and other data).

    This will be seen once the card is inserted completely.

    Since we have the SIM card in the WIO LTE, we will connect the antennas to the slots shown in the image below.

    Once we finish this, we will have our module ready to use it with Arduino IDE.

    Wio Arduino Setup:

    This is the official guide to install the WIO LTE on the Arduino IDE. I recommend to follow it 100%, it is very clear and concise.

    https://github.com/Seeed-Studio/Wio_LTE_Arduino_Library

    The Arduino Software is on Github.

    Soracom Platform Setup:

    It is very important to check that your SIM card is already attached to a group, in my case I call it Harvest Group.

    In the case that we do not have a group created, we will create one as shown in the image below, if we do not do this we will not be able to perform the AWS IoT configuration.

    Since the group was created, in my case we entered the group menu by pressing "Harvest Group" and once inside we will see the following.

    Within the group menu we will enter the option "SORACOM Funnel", this option will allow us to access the connectivity with the services of AWS, all the credentials will be obtained later in the AWS configuration, so do not close this tab (Please follow).

    AWS IoT Setup

    To communicate with AWS IoT we need to create a role in the IAM console in order to authorize Soracom access to our console.

  • The first step is to create a role that allows us to communicate with AWS.
  • Within the role configuration we need to grant access to AWS IoT.
  • Here we can see the services that we can use with this role, in this case this policy is just an example. Note: If you doubt which policy to grab the role, choose the policy (AWSIoTFullAccess).
  • We put the name we want to the new role.
  • We enter the AWS IoT console and go to the "Settings" section.
  • Once in the "Settings" section we will copy the "Endpoint", this will be used in the Soracom console tab.
  • The next step will be to create the connection between AWS IoT and the other AWS services such as Lambda, SNS and DynamoDB. So for that we will have to create a "Rule" which will serve to generate a bridge between this service and the aforementioned services.
  • Once we have our rule, we will configure it as shown in the image.
  • Already in this tab we will configure what lambda we want to be activated once a data arrives (not close until we finish configuring the other services)
  • AWS Lambda Setup
  • We create a Lambda as shown on the screen (it is quite intuitive, should not have problems).
  • The lambda should be seen in this way, the reason for using a lambda would be because we need to process the data obtained from the module to give a response with a message and our web platform (do this process 2 times because we are going to configure 2 lambdas for connect to the services of SNS and DynamoDB)
  • First Lambda SNS Service:

    This is the code to send a notification to SNS, the TopicARN will be obtained later in the SNS configuration.

    console.log('Loading function'); // Load the AWS SDK var AWS = require("aws-sdk"); // Set up the code to call when the Lambda function is invoked exports.handler = (event, context, callback) => { // Load the message passed into the Lambda function into a JSON object var eventText = JSON.parse(JSON.stringify(event, null, 2)); // Log a message to the console; you can view this text in the Monitoring tab in the Lambda console or in the CloudWatch Logs console // Create a string, extracting the click type and serial number from the message sent by the AWS IoT button // Write the string to the console var temp=parseInt(eventText.temperature) var acc=parseInt(eventText.accelerometer) var moi=parseInt(eventText.moisture) var air=parseInt(eventText.air) var id=eventText.ID var myarray=[0,0,0,0] if(temp<15) { myarray[0]=4 } else if(temp >= 15 && temp < 18) { myarray[0]=3 } else if(temp >= 18 && temp < 19) { myarray[0]=2 } else if(temp >= 21 && temp < 24) { myarray[0]=1 } else if(temp >= 24 && temp < 26) { myarray[0]=2 } else if(temp >= 26 && temp < 28) { myarray[0]=3 } else if(temp >= 28) { myarray[0]=4 } temp=temp*1.8+32 if(acc<3) { myarray[1]=1 } else if(acc >= 3 && acc < 6) { myarray[1]=2 } else if(acc >= 6 && acc < 10) { myarray[1]=3 } else if(acc >= 10) { myarray[1]=4 } if(moi<20) { myarray[3]=4 } else if(moi >= 20 && moi < 30) { myarray[3]=3 } else if(moi >= 30 && moi < 40) { myarray[3]=2 } else if(moi >= 40 && moi < 50) { myarray[3]=1 } else if(moi >= 50 && moi < 65) { myarray[3]=2 } else if(moi >= 65 && moi < 80) { myarray[3]=3 } else if(moi >= 80) { myarray[3]=4 } air=0.5 * (temp + 61.0 + ((temp-68.0)*1.2) + (moi*0.094)) if(air<90) { myarray[2]=1 } else if(air >= 90 && air < 102) { myarray[2]=2 } else if(air >= 102 && air < 122) { myarray[2]=3 } else if(air >= 122) { myarray[2]=4 } var mess=""; if(myarray[3]==1 || myarray[2]==1 || myarray[1]==1 || myarray[0]==1) { mess="Your dog goes in perfect travel conditions" } if(myarray[3]==2 || myarray[2]==2 || myarray[1]==2 || myarray[0]==2) { mess="Your dog is in good condition" } if(myarray[3]==3 || myarray[2]==3 || myarray[1]==3 || myarray[0]==3) { mess="Your dog is fine but the travel conditions are not the best." } if(myarray[3]==4 || myarray[2]==4 || myarray[1]==4 || myarray[0]==4) { mess="Your dog is fine but travel conditions should improve" } // Create an SNS object var sns = new AWS.SNS(); console.log("Received event:",JSON.stringify(myarray, null, 2),air); var params = { Message: mess, TopicArn: "YOURSNSENDPOINT" }; sns.publish(params, context.done); }; Second Lambda DynamoDB Service:

    This is the code to send data to DynamoDB.

    console.log('Loading function'); var AWS = require("aws-sdk"); exports.handler = (event, context, callback) => { var eventText = JSON.parse(JSON.stringify(event, null, 2)); var temp=parseInt(eventText.temperature) var acc=parseInt(eventText.accelerometer) var moi=parseInt(eventText.moisture) var air=0 var id=eventText.ID var myarray=[0,0,0,0] if(temp<15) { myarray[0]=4 } else if(temp >= 15 && temp < 18) { myarray[0]=3 } else if(temp >= 18 && temp < 19) { myarray[0]=2 } else if(temp >= 21 && temp < 24) { myarray[0]=1 } else if(temp >= 24 && temp < 26) { myarray[0]=2 } else if(temp >= 26 && temp < 28) { myarray[0]=3 } else if(temp >= 28) { myarray[0]=4 } temp=temp*1.8+32 if(acc<3) { myarray[1]=1 } else if(acc >= 3 && acc < 6) { myarray[1]=2 } else if(acc >= 6 && acc < 10) { myarray[1]=3 } else if(acc >= 10) { myarray[1]=4 } if(moi<20) { myarray[3]=4 } else if(moi >= 20 && moi < 30) { myarray[3]=3 } else if(moi >= 30 && moi < 40) { myarray[3]=2 } else if(moi >= 40 && moi < 50) { myarray[3]=1 } else if(moi >= 50 && moi < 65) { myarray[3]=2 } else if(moi >= 65 && moi < 80) { myarray[3]=3 } else if(moi >= 80) { myarray[3]=4 } air=0.5 * (temp + 61.0 + ((temp-68.0)*1.2) + (moi*0.094)) if(air<90) { myarray[2]=1 } else if(air >= 90 && air < 102) { myarray[2]=2 } else if(air >= 102 && air < 122) { myarray[2]=3 } else if(air >= 122) { myarray[2]=4 } // Set the region AWS.config.update({region: 'ap-northeast-1'}); // Create the DynamoDB service object var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'}); var params = { TableName: 'FMPtemp', Item: { 'ID' : {S: id}, 'Array' : {S: JSON.stringify(myarray, null, 2)} } }; // Call DynamoDB to add the item to the table ddb.putItem(params, function(err, data) {if (err) {} else {}}); }; AWS SNS Setup:
  • In the SNS service we created a topic
  • In the SNS service we created a topic.
  • Since we create the topic we can create subscriptions where we want the notification to arrive.
  • This is an example of all sides that we can send notifications.
  • Save this ARN for your First Lambda:
  • AWS DynamoDB Setup:

    For this project and for our web implementation, we will need 2 tables created in DynamoDB, since one we will use as data storage and another we will use it for temporary variables that we can use in the WEB platform.

  • For this step, only two tables were created as shown in the image:
  • WEB Interface Setup:

    The web platform may look simple, but it has a very interesting implementation in its way of interacting with AWS.

    One of the biggest problems when working with a web page, is having temporary variables, because every time the page is updated, we will lose all the information stored by the variables, however in my implementation I extract data directly from DynamoDB, thanks to the javascript SDK that provides AWS, therefore I can store information in a database, as seen in the above image in the database called "FMP", and save temporary variables and quick access for the deployment and update of the web page "FMPtemp".

  • At the time of displaying the web page, the FMPtemp database is called to obtain the status in real time of the pets and according to our algorithm determine the state of the pet in general, it will be notified by colors as shown in the image down.
  • Each of the legs represents the following:

  • Temp: Ambient Temperature
  • Accel: Max Acceleration
  • Air Q: Air Quality
  • Moist: Air Moisture
  • Color Ranges:

    The air quality is calculated using the following formula using a reduced version to calculate the dew point of the air and according to the books it must be less than 90:

    Air Q=0.5 * (temp + 61.0 + ((temp-68.0)1.2) + (moist0.094))The Final Product:
  • We assemble the temperature sensor in the case.
  • Time of Our Epic Demo: