Skip to content

tibernardinelli/plant-watering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plant Watering

This project uses Greengo to manage Greengrass operations, in an automated, reliable, and repeatable way. You may read more about it on this article.

Environment setup

Start creating a Python virtualenv running Python 2.7. Python 3.x is not supported on Greengrass Lambda yet, so using version as default for the project. The virtualenvwrapper lib is recommended to simplify management:

mkvirtualenv plantwatering --python=python2.7

If not already activated, do it by executing:

workon plantwatering

Then, install Greengo using pip:

pip install git+git://github.com/rpedigoni/greengo.git#egg=greengo

Running

Create Greengrass resources

All Greengrass definitions are set on the greengo.yaml configuration file. The first step is to create those definitions on AWS:

greengo create

The command above will create a Greengrass Core, its Lambda functions, Device Resources, and MQTT subscriptions between entities.

Also, the create command will generate the necessary certificates (./certs/) and the Greengrass configuration file (./config/config.json).

You may open the AWS Console on Greengrass panel and navigate between the generated entities.

Setup Raspberry PI

Follow Greengrass documentation modules 1 and 2 to setup the Raspberry PI device. You may want to skip the config/certificates part as we'll use the ones provided by greengo create.

With the device prepared, copy the generated certificates to it. From your machine, execute:

rsync config/* pi@RASPBERRY_PI_ADDR:/tmp/config/
rsync certs/* pi@RASPBERRY_PI_ADDR:/tmp/certs/

On the Raspberry PI device, move from /tmp/ to its correct location:

mv /tmp/config/* /greengrass/config/
mv /tmp/certs/* /greengrass/certs/

Create data folder required to run PlantWatering:

mkdir /usr/plantwatering/

Then start Greengrass Core:

/greengrass/ggc/core/greengrassd start

You should receive a confirmation message with the running PID for Greengrass Core service.

GPIO/USB connections

  • Connect relay to Raspberry PI pin 18 (BCM).

Deploy

To get your definitions deployed to the devices, execute on your machine:

greengo deploy

This command does exactly the same thing as clicking on the Deploy button on Greengrass AWS Console.

Development and testing

After making changes to your Greengrass project (eg: editing lambda functions, creating MQTT subscriptions, etc), you must update its definitions on AWS. Do it by running:

greengo update

Behind the scenes, greengo will remove all lambdas, resources and subscriptions, and then recreate them with a new Greengrass Group Version.

After updating, run greengo deploy any time and the changes will be deployed to the devices.

Troubleshooting

Greengrass deployment

For greengo deploy command, you may receive the following message:

ERROR! TES service role is not associated with this account

Using the AWS CLI, check that an appropriate service role is associated with your account by using GetServiceRoleForAccount and ensure that the role has at least the AWSGreengrassResourceAccessRolePolicy permission applied. If you need to associate a Greengrass service role with your account, use AssociateServiceRoleToAccount:

aws greengrass associate-service-role-to-account --role-arn YOUR_GG_ROLE_ARN

PiCamera on RPi /dev/video0

sudo modprobe bcm2835-v4l2

About

Plant Watering system powered by AWS Greengrass

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • Dockerfile 0.1%