Video 4.3 programming Raspberry Pi to check Sq s. In this video, we will learn the following writing a Python code on Raspberry Pi, understanding the Python code. In the previous video, we have successfully stored on and off messages in Sq Sq my ESP 32 underscore triggering underscore Q. Now, we will write a Python code on raspberry pi, which will check the Sq sq. Okay, the code for triggering is similar to that of scheduling. Wait, let me tell you how. In scheduling, we check the skew skew.
If any messages were found, then we turned on the LED and after a delay of 20 seconds, we turned off the LED in triggering also, we will check this Q Sq if you find an on message, then we'll run the script on.sh and when we find an author's message, then we'll run the script of.sh so in this video I would like to modify the scheduling code. Now, open the repository that you have downloaded at the beginning of this course. Here, you can find Section four, select it, then select video 4.3. Now, open the Python file with the name triggering code for checking Sq s. This is the code for triggering, but I will not copy this code directly. As I already told you, I will modify the scheduling code so that you can understand triggering better. Now going back, select section three, video 3.5.
Here, you can find a Python file with the name our PI code to check Sq s. Open it. Now, we will modify this code. These three lines are for importing the required libraries. Next, giving the access key and access secret of the IM user that we created earlier. Open the Excel sheet that have downloaded while creating the user. Copy access key and paste it here.
Now copy access secret and paste it here. Next region, North Virginia. So use hyphen East hyphen one to edit open Sq s, copy the URL and paste it here. Now, this part of the code is same for both scheduling and triggering. Now here we need to change this try block. Here we are popping out the message and then printing it.
If the message is on, then we need to run on.sh. So if message is equal equal on then we need to run the owner sh script. So ran the script file using system calls. And if the message is off, then we need to run off.sh o Ellis message equal equal of then After the search using the following command, then except block, this is the same for scheduling and triggering. So we have edited the code successfully. Now, we will copy the entire code.
Next, connect your Raspberry Pi to the PC and open up putty terminal, type ls and then enter. This will show all the files in slash home slash pi. Here, we already have on.sh and off.sh scripts that we created during scheduling, we will use the same scripts for triggering too. If you guys have not implemented scheduling, please go and check out the downloaded repository in the section three. You can find this on.sh and off.sh scripts there. Now let's create a Python file using the command sudo nano triggering.py.
Paste the entire code here. Check if all the indentation are correct. Generally, while copying the code, there might be some indentation issues. As we have already completed editing the code, we will save this directly. So, press Ctrl x and then y and enter. We have successfully programmed our Raspberry Pi.
Are you excited to test this? Okay, hold your excitement because I'm going to end this video here. In this video, we learned the following writing the Python code on Raspberry Pi, understanding the Python code. In the next video, we will trigger led connected to the Raspberry Pi with AWS cloud. See you guys in the next video.