Running a Greengrass Core on a Raspberry Pi 3b+ - amazon-web-services

I have 2 greengrass cores, one is running on an AWS EC2 instance and the other is running on a Raspberry Pi.
In my project, I am sending video frames from my local machine to my RaspberryPi, then I process those frames, locate a marker with a QR code that is in the frame and send the coordinates of the marker to Greengrass. I am then reading those coordinates from my laptop.
In first scenario my greengrass was running on an EC2 instance (had it from before) and in order to boost performance I decided to run another greengrass core on my Raspberry Pi and use that one instead. My thinking was that instead of having a triangle Laptop->RBPi->EC2->Laptop I will essentially remove the EC2 instance and the cloud component from this process and therefore improve my performance.
The problem is that I do not see much/any difference in performance.
In both cases, if I want to connect to my greengrass core instance I use the AWS endpoint as the my "contact" point and the only difference is that in core's connectivity setting I am using my Raspberry Pi's IP address in one scenario and the IP address of the EC2 instance in the other. Am I wrong in doing it like this, is there another way?
How does this communication work in practice? Does my message go to the AWS endpoint somewhere in the cloud and is then sent to my greengrass core device (Raspberry Pi or EC2)?

Greengrass is an IoT service, and due to its purpose, it uses fast and lightweight MQTT protocol for communication.
Its communication model is based on "Publish-Subscribe" model, with MQTT broker in the middle.
You are right saying the message goes to AWS endpoint - that would be the AWS IoT Core MQTT broker.
When a IoT device (i.e. RPI or EC2) runs Greengrass or in fact any other IoT MQTT client software, when it 'sends' a message - it publishes it to that broker on specific topic. On the other side there is another IoT device which in turn is subscribed to that topic through the same broker.
The broker acts like a hub where devices publish messages and subscribe to receive those messages with the use of topics, thus the communication is possible.
IoT devices need that broker to communicate, hence it really doesn't matter whether you run Greengrass on EC2 or RPI since both have to publish to subscribe to the topic on the AWS IoT broker.

Related

AWS Iot Connection using legacy TCP Firmware

I have an existing solution for acquired IoT devices that have proprietary legacy firmware, that uses raw TCP.
The solution involves an application written in Node.JS running on an AWS EC2 instance. It creates a TCP server that opens a socket to listen to the device (each of them). Every time the IoT device pings the server, the server must ping back the device with a default message (created using the original message) as validation the connection is still online.
After pinging back, it then unscrambles the TCP data parsing it into Json and adding to a MongoDB database. Which then is used for displaying data to the customers.
Also, on the same EC2 instance, another application is deployed on-demand via front-end APIs requests to send commands to the IoT devices and logs it into the same DB, sometimes changing constants that are defined to each device separately.
As we are developing new devices in MQTT protocol, we are creating new serverless architecture using AWS IoT Core. I'm looking for an innovative serverless solution to integrate the legacy devices in this more robust and less demanding architecture (more cost effective).
As I can't change the protocol, it must still be a TCP, i'm looking for something to convert the TCP into MQTT and then forward it to the general IoT Core. That way, i can use the same architecture for both new and old devices. Giving me time to slowly decommission the older devices, not having to maintain both infrastructures.
The closest thing I've found is Amazon IoT Greengrass (https://aws.amazon.com/blogs/iot/converting-industrial-protocols-with-aws-iot-greengrass/), which appears to run a TCP client in an AWS lambda function, and then forwarding it as MQTT into AWS IoT Core.
We are testing this now, but i would like to know if anyone had similar issues with legacy protocols using Greengrass or other solutions.

AWS IoT - How to create a Web Application

I'm new to AWS and web application development.
I have a project where I have a motor and relay connected to a Raspberry Pi 4 Model B.
The Raspberry Pi is to communicate to a web application through AWS IoT to send/receive messages and commands from registered user accounts.
The web application should contain a Sign In page as well as a dashboard.
I wish to also host the web application on the AWS cloud.
I am unsure which of AWS services I should be using and how to use them.
So far, I've only worked out to use AWS IoT Core to communicate between the Raspberry Pi and AWS IoT Core without any web application involved.
Can anyone advise on what services/web framework I might need to know to create a web application that can send/receive commands/messages to/from the Raspberry Pi?
Any advice is much appreciated!
You can use AWS Greengrass service. Install the Greengrass Core on your IOT devices (Raspberry Pi) which will install and include the X.502 certificates required to connect to your AWS Account. once you set up the Greengrass, you can install components from Greengrass V2 onto your device from your AWS Account. Deploy a component which would be able to publish messages on an IOT Core topic as and when required by taking data from sensors. Use MQTT protocol for sending messages to IOT Core. Once you receive the messages in IOT Core you can send them to other AWS Services using IOT Core Rules.

how to establish a private network connection of AWS server to a remote IoT device running linux?

how to deploy a code to a remote IoT device running linux? Is there any zombie program to be written on the remote IoT device to establish a connection? Or is there any custom publisher subscriber shell script/python program needs to be handled at IoT device side? Is there any alternative web servers / Is it possible to deploy a code from gitlab to remote IoT device?
AWS IoT Greengrass is exactly the service you are looking for. You can set it up to be started with systemd and it will run a daemon that keeps your IoT device and the shadow device in sync. You can even deploy long-running lambda functions on your device that will only run locally (not in the cloud). All the deployment, secure connection, updating and offline handling is done by Greengrass.
I played with that and my Raspi with Sense HAT as my home office sensor. Now have a fancy dashboard of my room temperature, humidity and more... lots of fun.
You can get started here.

Is it possible to connect Amazon FreeRTOS Windows Simulator to local machine broker?

It is easy to send data from amazon FreeRTOS windows simulator to aws MQTT broker.
But I want to send data from amazon FreeRTOS windows simulator to local machine broker.
Is there any way to do that?
Here is a demo sending to mosquitto MQTT broker running on a local machine, and here is a demo connecting to test.mosquitto.org in the cloud. Both are a work in progress.

AWS GREENGRASS Cannot connect to device

I am new to AWS IoT. Can you please guide me or refer me some helpful material to implement whole greengrass. I want to use raspberry pi as my greengrass core in gg group and I want to establish communication between different devices which in my case are esp8266 and esp32 through raspberry pi.
Instead of terminal in my computer I want to use one esp8266 as publisher and another esp8266 as subscriber and exchange data between them via raspberry pi (greengrass core). I have no idea if I have to install device SDK on esp or what? I am finding no way out from here.
Thank you so much for help.
First you should read about Greengrass which you can find useful information and how to install it on RaspberryPi here.
Then you should choose which kinds of OS you want to use for your ESPs. You can use:
Amazon FreeRTOS
MongooseOS
Zerynth
I recommend to use Amazon FreeRTOS because it is well-known and the documentations are very good. You can find more information to get started with it here. You should consider that all of your devices (RaspberryPi and ESPs) should be in the same network and you should set the IP of the broker in your ESPs to the IP of your RaspberryPi in your local network. Also you should set the devices to be in same group in AWS IoT console and deploy the configuration to the Greengrass. The policies for IoT devices should allow them to publish/subscribe. For connecting to the AWS broker all of devices should have valid certifications and for connecting ESPs to the Greengrass network CA root certificate should be replaced by Greengrass group certificate.
You can't use esp8266 with aws Greengrass, because esp8266 doesn't support TLS 1.2 communication and aws IoT required TLS 1.2.
You can use esp32, which support TLS 1.2 and can exchange certificate, and establish the secure connection with aws greengrass.
I have written an article, which explain each and every steps, how you can start from stracth to advance level.
Zerynth official has featured this article on their blog. So follow it and complete your solution.