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 airlines or moving services, you know how stressful and problematic it is for your precious friends.
The main problem thus is: The horrid care pets get when they are transported.
Regarding the pet's safety and comfort:
Sometimes we need to send pets with an airline service for travel to another country or just around the corner. How can we be sure they're fine at all times? Take into consideration how baggage is treated.
And secondly, have we ever feared that our dog goes astray and you can never find it again, the following project might have a solution for that.
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 like to make me feel less guilty XP.
Solution:Solving for the pet's safety and comfort:
I will develop an integral IoT solution to monitor the pet’s environment based on Helium Developer Kit, powered by LoraWAN connectivity and Helium gateway service, in order to ensure their well-being throughout their journey. All this also integrated with a Helium Console with AWS as MQTT server and NodeRed based platform which, in addition to showing the status of the pet 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 flight or any travel.
Connection Diagram:- Kit Elements:
- Connect the Kit.
- Put everything in a case.
- Pycom Gateway:
The first step is to create an account in the helium console, this process will help us to obtain the credentials that we will input in our kit later.
We go to the Devices tab to create the credentials of our first device.
Within the platform we will create a device to obtain the connection credentials.
We save these values for the configuration of our device.
Kit Setup:All the guides needed to program the kit with Arduino IDE are in the official helium guide.
arduino | Helium Documentation
Once we have successfully completed the helium guide we will download and open the document in the "ArduinoIDE" folder and open it.
Add the following libraries:
NOTE: The libraries weren't fully compatible with the board, but after fixing them a bit, I did a push to the official githubs to help the open source community.
Now we will put the credentials that we obtained in the Helium Console.
If all goes well, you should be able to flash the code in the kit.
IFyou are in an area within the Helium coverage, go to the Checkpoint section.
Check the Coverage in your Region. https://network.helium.com/coverage
Miner Creation:In this case, the creation of a miner in AWS is perfectly detailed in the official documentation that Helium provides:
https://developer.helium.com/blockchain/run-your-own-miner
The only data that we will need in this case after running the miner will be the IPv4 Public IP:
The miner generates a pseudo-random name, in the case of our Miner we obtained the following name.
The Gateway configuration is carried out with a Fipy of the Pycom brand.
https://pycom.io/product/fipy/
In order to configure it correctly, we must first follow the official guide to configure and activate it on your Pybytes platform.
https://docs.pycom.io/gettingstarted/
I recommend reading it in detail since the board also has many more applications.
Gateway Setup:Note: in our case we use the Pymakr extension in Visual Studio Code.
https://docs.pycom.io/pymakr/installation/vscode/
Once the previous section is finished, we must download the folder called "Pycom Helium Gateway".
We open the folder with VS code to start editing the configuration of the gateway.
We have to configure the following parameters inside our config.py file
These are the constants that we will put in our code so that the connection with the miner works correctly.
Server = IPv4 Public IP from EC2 Miner
Port = 1680 (Helium Miner Port)
NTP = "pool.ntp.org"
NTP_PERIOD_S = 3600
WIFI_SSID = 'YOUR_SSID'
WIFI_PASS = 'YOURPASS'
LORA_FREQUENCY = 904300000
LORA_GW_DR = "SF10BW125" # DR_0
LORA_NODE_DR = 0
If everything works correctly you should see the push and pull of the gateway with the miner.
In the Pycom console:
On the console of the Kit.
{"UTC":[2,44,2],"Lat":19.24,"Lon":99.9,"Alt":2234.74,"Hum":37.20,"Press":777.72,"Temp":29.02,"Acc":[9,0,1026],"Gyro":[-1190,210,140],"Mag":[-111,87,-750]}
Checkpoint:In the Helium console we must see how the data arrives:
Since the data is coming to the Helium console, it is time to configure it to reach the AWS IoT core.
AWS IoT Setup:The AWS IoT configuration is well explained in the official Helium documentation:
https://developer.helium.com/console/integrations/awsiotcore
Since we have configured the service, we will save the topic that we use to send the data to AWS to be able to use it later.
AWS works through roles, these roles are credentials that we create so that the services can communicate with each other, in order to carry out all our integration we need to create a role that allows the effective transmission of all services, therefore that will be the first thing To make.
Note: always start here when doing a project with AWS.
IAM:- Enter the IAM console.
- Enter through the role tab and click "Create role".
- Create a role focused on the IoT platform.
- Press next till review.
- Now we have to add the additional permissions to the Role, in the roles tab enter the role we just created and press the Attach policies button.
Inside policies add the following:
- AmazonDynamoDBFullAccess
- Once that is finished, now we can start configuring the Rule within AWS IoT Core.
Once we receive the data to our AWS IoT Core, we will configure the Rules to connect the following services.
- Set any name for the Rule.
- In the SQL Query we will place our topic.
- The first rule we are going to create will be to save all the data in a DynamoDB.
- Press "Create a new resource" to create the table where we will save the data.
- For our table we will use the following parameters, I suggest that you use these specifically, since at production level all the device numbers will be different and in the "Time" column we are going to implement a special TIMESTAMP function.
The Sort Key value special function in the sortkey setup is:
${parse_time("yyyy.MM.dd G 'at' HH:mm:ss z", timestamp() )}
- Once this is finished, we will have finished the first rule. In this case, because the rule for the lambda uses a different SQL query, we will no longer add any more actions to this rule.
- To create a new rule but using the following SQL Query.
- We will add to this rule the following action:
- Press the "Create a new Lambda Function" button:
- We configure the lambda in the following way and create it:
- Once the lambda has been created we go down to the Execution role section and press the View the YOURROLE button on the IAM console to be able to add the SNS police to the SMS:
- We add the SNS service AmazonSNSFullAccess
- Once that is finished, we select the lambda in our rule to finish configuring the lambda trigger.
- Before programming the Lambda we will have to configure the SMS service through SNS.
- Press the "Create Topic" button to create our message service.
- Give the Topic a title and create it.
- Save the ARN number, since we are going to need it to configure the lambda.
- Click "Create subscription".
- Select as "Protocol" SMS and in Endpoint put your cell number (International dialing).
- Done, we have finished creating the necessary services to use the lambda correctly, now we return to the lambda and copy the code in the Lambda Code folder and paste it into your Lambda.
The most important part of the code is the Thresholds, each of them was obtained from the following references.
- Max Accel Limit: https://web.archive.org/web/20170104164718/http://www.au.af.mil/au/aupress/digital/pdf/book/b_0113_brulle_engineering_space_age.pdf
- Max Pressure on Flight: https://www.who.int/ith/mode_of_travel/cab/en/
- Max Degrees: 45 degrees maximum static friction before the dog slips
- Max Magnetic Field: https://www.who.int/peh-emf/publications/facts/fs322/en/
- Min and Max, Temperature and Humidity: http://www.dartmouth.edu/~cushman/courses/engs44/comfort.pdf
Since we have all our platform ready, we have to create the accesses to communicate with it. So we will have to create two Things in this case, the first is for our Helium Kit and the other will be for the NodeRed UI.
- First we have to access our AWS console y look for the IoT core service:
- Obtain your AWS endpoint, save it because we will use it to setup the RSL10 App and the webpage.
- In the lateral panel select the "Onboard" option and then "Get started".
- Select "Get started".
- At "Choose a platform" select "Linux/OSX", in AWS IoT DEvice SDK select "Python" and then click "Next".
- At Name, write any name, remember that you will have to do this process twice, so name things ion order that you can differentiate the credentials that you will put in NodeRed. Then click on "Next step".
- At "Download connection kit for" press the button "Linux/OSX" to download the credential package (which we will use later) and click on "Next Step".
- Click "Done".
- Click "Done".
- On the lateral bar, inside the Manage/Things section we can see our thing already created. Now we have to set up the policy of that thing for it to work without restrictions in AWS.
- At the lateral bar, in the Secure/Policies section we can see our thing-policy, click on it to modify it:
- Click on "Edit policy document".
- Copy-paste the following text in the document and save it.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
}
- Once this is done, we will go to our pc and to the folder with the credentials previously downloaded, extract them.
- With this, we have the entire cloud backend of the project, so now we can focus on the frontend.
Node Red is a tool for NodeJS where we can integrate services easily, without code and, of course, create excellent dashboards.
NodeJS installation guide: https://www.guru99.com/download-install-node-js.html
NodeRED installation guide: https://nodered.org/docs/getting-started/windows
NodeRED installation guide: https://flows.nodered.org/node/node-red-dashboard
- The file "flows.json" in the folder "Node-RED Flow", has all the information to import the flow into your NodeRED.
- Once that is done we will edit the MQTT node to enter our credentials.
- Set Server and Port.
- Press in the pencil in TSL configuration to add the certificates.
Note: RootCA certificate inside "Certs" folder.
- If everything works fine press the "Deploy" button and enter the following URL to check the Dashboard.
- The device's real-time location map is at:
http://localhost:1880/worldmap/
- This node receives the broker's payloads, filters according to the sensor which graph it has to go to and sends it to graph and deploy the adress in the world map.
All the solution in action:
UI:
- The device's real-time location map is at:
http://localhost:1880/worldmap/
Comments