Internet of Things: Difference between revisions
No edit summary |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
I have two raspberry pis that i'd like to wire up using AWS IoT | I have two raspberry pis that i'd like to wire up using AWS IoT | ||
== AWS Iot Notes == | |||
=== AWS Setup Notes === | |||
http://docs.aws.amazon.com/iot/latest/developerguide/policy-actions.html | |||
aws iot list-policy-principals --policy-name mypolicy | |||
aws iot list-principal-policies --principal ?? | |||
aws iot list-principal-things --principal ?? | |||
aws iot list-thing-principals --thing-name mypi1 | |||
principal means certificate. | |||
THINGS <-> PRINCIPAL ( cert ) <-> POLICY | |||
best guid so far: | |||
https://www.hackster.io/mariocannistra/python-and-paho-for-mqtt-with-aws-iot-921e41 | |||
this is the policy that AWS gives the rile that Iot WIll use to port to ES | |||
<pre> | |||
{ | |||
"Version": "2012-10-17", | |||
"Statement": { | |||
"Effect": "Allow", | |||
"Action": "es:ESHttpPut", | |||
"Resource": [ | |||
"arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/myiotcatcher/*" | |||
] | |||
} | |||
} | |||
</pre> | |||
more here: http://docs.aws.amazon.com/iot/latest/developerguide/iot-create-role.html | |||
=== Script service setup === | |||
from: http://www.diegoacuna.me/how-to-run-a-script-as-a-service-in-raspberry-pi-raspbian-jessie/ | |||
/lib/systemd/system/awsiotpub_temp.service | |||
<pre> | |||
[Unit] | |||
Description=IoT AWS Sensor Publisher | |||
After=multi-user.target | |||
[Service] | |||
Type=simple | |||
ExecStart=/usr/bin/python /home/pi/python-paho-mqtt-for-aws-iot/awsiotpub_temp.py | |||
Restart=on-abort | |||
[Install] | |||
WantedBy=multi-user.target | |||
</pre> | |||
enable: | |||
<pre> | |||
sudo chmod 644 /lib/systemd/system/hello.service | |||
chmod +x /home/pi/hello_world.py | |||
sudo systemctl daemon-reload | |||
sudo systemctl enable hello.service | |||
sudo systemctl start hello.service | |||
</pre> | |||
on creating rules with variable substitution | |||
http://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html | |||
for example if you want to post data from device X to an elasticsearch index with id X | |||
you should generate a new uuid id for each reading: | |||
"id": "${newuuid()}" | |||
=== AWS ElasticSearch setup === | |||
curl 'https://search-myiotcatcher-eq4tipuq24ltctdtgz5hydwvb4.us-east-1.es.amazonaws.com/_cat/indices?v' | |||
== Guides == | == Guides == | ||
Line 14: | Line 96: | ||
== References == | == References == | ||
MQ Best practices | ;MQ Best practices | ||
http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices | :http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices | ||
;If It Moves, Measure It: Logging IoT with ELK | |||
:https://www.elastic.co/elasticon/2015/sf/if-it-moves-measure-it-logging-iot-with-elk | |||
read more: "aeon lab home energy meter" | |||
setup and secure mqtt https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-centos-7 | |||
== More == | |||
* [[/AWS Iot ESP32 Sensor - circa 2022]] |
Latest revision as of 01:11, 11 November 2022
aka IoT
I have two raspberry pis that i'd like to wire up using AWS IoT
AWS Iot Notes
AWS Setup Notes
http://docs.aws.amazon.com/iot/latest/developerguide/policy-actions.html
aws iot list-policy-principals --policy-name mypolicy aws iot list-principal-policies --principal ?? aws iot list-principal-things --principal ?? aws iot list-thing-principals --thing-name mypi1
principal means certificate.
THINGS <-> PRINCIPAL ( cert ) <-> POLICY
best guid so far:
https://www.hackster.io/mariocannistra/python-and-paho-for-mqtt-with-aws-iot-921e41
this is the policy that AWS gives the rile that Iot WIll use to port to ES
{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "es:ESHttpPut", "Resource": [ "arn:aws:es:us-east-1:XXXXXXXXXXXX:domain/myiotcatcher/*" ] } }
more here: http://docs.aws.amazon.com/iot/latest/developerguide/iot-create-role.html
Script service setup
from: http://www.diegoacuna.me/how-to-run-a-script-as-a-service-in-raspberry-pi-raspbian-jessie/
/lib/systemd/system/awsiotpub_temp.service
[Unit] Description=IoT AWS Sensor Publisher After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/python /home/pi/python-paho-mqtt-for-aws-iot/awsiotpub_temp.py Restart=on-abort [Install] WantedBy=multi-user.target
enable:
sudo chmod 644 /lib/systemd/system/hello.service chmod +x /home/pi/hello_world.py sudo systemctl daemon-reload sudo systemctl enable hello.service sudo systemctl start hello.service
on creating rules with variable substitution
http://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html
for example if you want to post data from device X to an elasticsearch index with id X
you should generate a new uuid id for each reading:
"id": "${newuuid()}"
AWS ElasticSearch setup
curl 'https://search-myiotcatcher-eq4tipuq24ltctdtgz5hydwvb4.us-east-1.es.amazonaws.com/_cat/indices?v'
Guides
- https://dzone.com/refcardz/getting-started-with-mqtt
- What is mqtt?
- https://www.hackster.io/mariocannistra/python-and-paho-for-mqtt-with-aws-iot-921e41
- I like this guide because it gives an example subscriber and an example publisher.
References
- If It Moves, Measure It
- Logging IoT with ELK
- https://www.elastic.co/elasticon/2015/sf/if-it-moves-measure-it-logging-iot-with-elk
read more: "aeon lab home energy meter"
setup and secure mqtt https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-centos-7