A predictive maintenance demo using a speed controlled motor setup to predict failures before they happen, using data and machine learning. It gathers data from sensors, uses advanced algorithms to forecast problems, and provides actionable insights through visualizations. Ultimately, it shows how predictive maintenance can prevent breakdowns and optimize equipment performance.
To build the physical demo, please take a look go to BuildSpec.md for list of materials.
The project is built using CDK IaC. So it can be deployed to your AWS account with a single deploy command.
-
Ensure your AWS credentials are in place for your account
-
Bootstrap your account: In the root folder, run the following commands
npm ci npm run cdk bootstrap -- --toolkit-stack-name CDKToolkit-Predictive-Maintenance --qualifier predmaint
- Run the Jupiter NoteBook located in lib/ml to train the model with the example dataset provided. Feel free to run locally if you have a Jupiter instance or use a Notebook Instance in your AWS account (Guide here).
- After you finish running the notebook a trained model is created by the default name
lstm.h5
- Go to your AWS account, create a s3 bucket and upload the model
- keep note of bucket name and filename, as we will pass that to the cdk code later.
- Clone this repo.
- in your AWS Account enable AWS IAM Identity Center and create a user for yourself
- Go to ckd.json and update the
mlBucketPath
field with your ml bucket details you created earlier. - In the root folder, run the following commands
npm run deploy
- For any future changes you just need to redeploy using
npm run deploy
This steps assume you have an SD Card and Raspberry PI
- Install Raspeberry Pi OS Lite (64-bit) on a SD card:
- Download Raspberry Pi Imager
- Launch the imager
- Select the right image:
Raspeberry Pi OS (other)
>Raspeberry Pi OS Lite (64-bit)
- Select the right drive
- Set up a the Wifi (you can create a hotspot with your phone for instance) and ssh credentials by clicking on the gear on the bottom right:
- Check
Enable SSH
- Set username and password
- Check
Configure Wireless LAN
(This connection will help you connect to the pi from your computer after the first boot) - Set Wifi
SSID
andPassword
- Save
- Check
- Click
Write
button to write the image to the SD card
- Connect to your Raspberry Pi:
- Start your Raspberry Pi with SD Card plugged in it
- SSH to it by connecting your PC to the network you set up in the previous steps (
ssh pi@raspberrypi.local
)
- Setup up Raspberry Pi:
- Configure the interface options:
- run
raspi-config
- Go to Interface options
- Enable I4, I5, I6 (enable Hardware Serial port only, not login shell), I7 and I8
- Reboot your PI !
- run
- Install Java and pip3 using apt
sudo apt-get update sudo apt-get install default-jre python3-pip docker.io
- Create ggc_user and give it permission to access serial port and GPIO
useradd ggc_user && sudo groupadd ggc_group && sudo usermod -aG ggc_group ggc_user && sudo usermod -a -G dialout ggc_user && sudo usermod -a -G gpio ggc_user
- Install Greengrass running the following command
curl -s https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip > greengrass-nucleus-latest.zip && unzip greengrass-nucleus-latest.zip -d GreengrassInstaller
- Register your PI to your backend
- The Greengrass installer uses AWS credentials to provision the AWS resources that it requires. You can provide credentials as environment variables. Copy the command below to your device’s terminal. Replace the text after the ‘=’ sign with the specified information. Learn more
export AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> export AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY> export AWS_SESSION_TOKEN=<AWS_SESSION_TOKEN>
- Run the command given as output of your backend deployment (aka.
npm run deploy
). Something likesudo -E java -Droot="/greengrass/v2" ...
- The Greengrass installer uses AWS credentials to provision the AWS resources that it requires. You can provide credentials as environment variables. Copy the command below to your device’s terminal. Replace the text after the ‘=’ sign with the specified information. Learn more
- Configure the interface options:
- Check the device is registered in your account:
- Go to AWS IOT Core console > Greengrass devices > Core devices >
PredictiveMaintenanceDemoStack-Thing
> Deployments - Check the deployments are
Completed
- Go to AWS IOT Core console > Greengrass devices > Core devices >
You are all set !
To see everything in action, we can login to Grafana and checkout our Dashboard to view watertank digital twin and all the metrics. After deployment the url for our grafana instance will be printed out in your command line or you could get the url from your AWS console by visiting the Managed Grafana service page, however you won't have access yet. AWS Managed Grafana is using AWS IAM Identity Center for Authorisation previously known as AWS Single Sign-On (SSO).
You should have an IAM Identity User created by now, so we need to give it permission to access our Grafana Instance.
- Login to your console and visit the Managed Grafana servie page.
- Go to the grafana workspace created by our deployment.
- In the Authentication tab, click on
Configure users and user groups
- Add your IAM Identity User
Now you are ready to visit grafana dashboard.ra
-
Just visit the grafana url either printed in your terminal or diplayed in your console under Grafana workspace Url.
-
login using your IAM Identity User credentials
-
Visit the dashboard section, choose browse and you can view the dashboard created by our deployment as seen below.
To deploy any changes in greengrass components, make sure you upgrade the componenent version in cdk.json, before running npm run deploy
again
To remove all resources created by this stack run the following
npm run destroy
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.