Greengrass V2 - Issue with Raspberry and resources (sensor + led)

0

Hi everyone,

First of all, let me say that in general, I am a little bit newbie using AWS services, so forgive me beforehand if I ask something to you guys that might be obvious.

So, coming back to the main topic, I am developing a simple project where I will need a camera to detect people, and if that happens, send a picture somewhere of AWS (maybe to a S3 bucket, but that will be a problem to think deeper in the future), a temperature / humidity sensor to check envionmental parameters, and a bulb to set alarms.

My very first step is to read from the temperature / humidity sensor (specifically, the DHT22), and if its values exceeds a threshold, switch on the bulb (a led diode). For this, I decided to use AWS Greengrass V2, so I have followed the workshop shown below:
https://greengrassv2.workshop.aws/en/chapter1_introduction.html

Instead of the Cloud9 environment, I have taken a Raspberry Pi 3 - model B with Raspberry Pi OS. I did everything until step F, and here is where my problem comes.

  • In the Publisher, I need to read directly the DHT22 sensor from the Raspberry Pi, but it does not work properly when I use its driver, and it works without crashes when I set both values as a random number. I dare say that the driver works because I have develop a simple example isolating that part, and it gives values.
  • It happens the same in the Subscriber when I try to change the led diode state. It also works, since I followed the same estrategy as the DHT22.

The led diode control will be placed in the lambda, but I guess I will have the same issue.

I have taken a look to the AWS Greengrass V1 user guide, and also, some videos from people on Youtube, and I could see that there is something to have into consideration, and it is what is called "resources", but I cannot see something like that in V2.

Am I missing something? Do I have to follow another guide?

Thank you very much for your time, looking forward to hearing from you.

Kind regards.
Daniel.

asked 3 years ago383 views
3 Answers
0

Hi,
Can you try to develop your code as a Greengrass component and not as a Lambda?
https://docs.aws.amazon.com/greengrass/v2/developerguide/create-components.html

As you correctly identified, if running as a Lambda, you have to figure out how to mount the devices into the container lambda is running within.
If you do want to run a Lambda in V2 inside a container for some reason, please look at the docs here: https://docs.aws.amazon.com/greengrass/v2/developerguide/import-lambda-function-console.html#import-lambda-console-run-isolated
This shows how to mount volumes and devices into the container so your lambda can access them.

answered 3 years ago
0

Hi,

Thank you very much for replying!!

Maybe I have not explained properly what I have so far in my previous post, but never mind, I will try as many times as it were neccesary!

Right now, I have developed two components as a first approach (speaking of sensor stuff only):
1- The first one generates two random values of temperature and humidity, since readings from DHT22 sensor makes the component crash due to what I told before, and that is what I am trying to fix.
2- The second one is subscribed to those values in order to switch on or switch off the led if a predefined threshold is exceeded. It happens the same as exposed in the other component.

*Note -> Fortunately, the first link you shared before does the same as the workshop.

The lambda will be developed after this has been completed in order to send alarms, and maybe, to control the led instead of the component, but that will be the next step for sure.

Perhaps this is a wrong way and it has to be done differently, but in any case, the hardware access will have to be accesible in one of them.

I hope this clarifies the issue, feel free to ask me for whatever you need (I mean, logs, files developed and so on).

Looking forward to hearing from you.

Kind regards.
Daniel.

answered 3 years ago
0

Hi there!

I would like to report that I have advances, and they are that both components are working with direct hardware iterations on the Raspberry Pi (in this case, GPIOs for both the sensor and the led diode).

I was able to see in the logs for the components the following sentence:
2021-06-07T09:43:10.488Z -WARN- (Copier) com.example.Subscriber: stderr. RuntimeError: No access to /dev/mem. Try running as root!. {scriptName=services.com.example.Subscriber.lifecycle.Run, serviceName=com.example.Subscriber, currentState=RUNNING}

That actually gave me a great clue, so I did a little reseach, finding that it was that I had no permissions in /dev/mem and in /dev/gpio* folders for the AWS Greengrass group in the core device, so I included them by using the commands shown below:
sudo usermod -aG kmem ggc_user
sudo usermod -aG gpio ggc_user

I hope this help people that might have the same problem. Now I will try the lambda functionalities, moving the led part here, so I will let you know if I have any more issues.

Thank you very much for your support.

Kind regards.
Daniel.

Edited by: dpergarc on Jun 8, 2021 1:49 AM

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions