Introduction: IoT Bit Functions
In this instructable, we will show you how to use the IoT Bit Functions GUI for your minicomputers like the Raspberry Pi 1,2 and 3. The functions the GUI will have in V1 are:
- "Send SMS",
- "Display SMS",
- "Delete SMS",
- "Make Call",
- "Hang up",
- "Set GPIO to HIGH/LOW"
- "Signal Quality"
These functions simplify communicating with the IoT Bit modem and by using them in an automated script we'll be able to control hardware attached to the Raspberry Pi's GPIO pins by simply sending an SMS to the IoT Bit. This can be useful in many projects, where you want to turn on or off the devices from a remote location, it can be done with nearly any device if properly set up.
In this Instructable we will show the very first version of the IoT Bit graphical user interface and how to set up a python script to have the "Set GPIO High/Low " function always running so if an SMS is sent it will automatically, set the chosen pin.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Material Needed
1 x IoT Bit Package
1 x Mini computer (Used Raspberry Pi 3 for this instructable)
1 x PC Monitor(HDMI or with adaptor)
1 x Mouse
1 x Keyboard
1 x SD Card (with an operating system like Raspbian, Ubuntu)
1x USB Cable
Step 2: 40-Pin Header Layout
Here is the schematic of the 40-Pin header to fit your project accordingly with the available pins.
Available Ports Port//Description
- Diagnostics port for output developing message(This isn't in use) (Typically ttyUSB0)
- NMEA port which outputs GPS information (Typically ttyUSB1)
- AT command port (Typically ttyUSB2)
- Modem port (Typically ttyUSB3)
- USB-Audio port (Typically ttyUSB4)
Step 3: Setting Up the GUI
The first thing to do is to run in the Terminal:
- $ sudo apt-get update
- $ sudo apt-get upgrade
This will ensure you have everything up to date and all packages installed.
The main module we used in this instructable is PyQt5 for Python 2.7 which should be installed by using the following command:
- $ sudo apt-get install python-pyqt5
After the PyQt5 is downloaded, you will need "IoT_Bit_library.py", "IoT_Bit_GUI_V1.py" and "popup.py" scripts we have made, to download them go to the GitHub link:
After downloading them, save them in the "/home/pi" directory.
Before running it we need to give it executable permissions by opening and writing on the terminal:
- $ sudo chmod +x IoT_Bit_GUI_V1.py
To run the GUI script just input into the terminal:
- $ ./IoT_Bit_GUI_V1.py
It's recommended to use python 2.7 since this GUI and the library has been created using it. If you want to use any versions above or under python 2.7 you will have to modify the code and it might not work optimally.
Step 4: How to Use
- To send an SMS you must first enter the phone number in the first entry box. Then enter your text message in the second entry box right next to the send SMS button and click on send. If successful, a message should show up on the Display box to confirm that it was sent.
- To display SMS, click the "Display All" to see all messages, 1 to see the first SMS, 2 to see the second SMS, and so on. After inputting the number click the "Display SMS" button and the message will show on the Display box below.
- To delete the SMS, click the "Delete All" button to delete all SMS, to delete a specific SMS select "Delete Specific SMS" from the drop-down menu and click "Delete SMS" button, a pop up will open for you to input the SMS you wish to delete after typing the SMS number press "OK" to delete that specific SMS and close the box if you don't wish to delete any other specific SMS (Remember the SMS you wish to delete refers to the index number next to the SMS when you click "Display All" and not the order in which you see them in the display window). Then to delete all SMS with the status "Received Read" select "Delete Read" from the drop-down menu and click "Delete SMS", to delete all SMS with the status "Received Read" and "Stored Sent" select "Delete Read & Sent" from the drop-down menu and click "Delete SMS", to delete all SMS with the status "Received Read", "Stored Sent" and "Stored Unsent" select "Delete Read, Sent & Unsent" from the drop-down menu and click "Delete SMS".
- To make a call, input the phone number into the same entry box as the phone for SMS and click on "Make Call", to hang up just click on the "Hangup" button once.
- To check signal you only have to click on the "Signal Quality" button and a message will show up on the display box, there are only five options "Poor Signal", "OK Signal", "Good Signal", "Exceptional Signal" and "No Connection"
- Then you have the "Set GPIO to HIGH/LOW" this function will set the chosen GPIO pin to either low or high depending on the last text message sent, for example: "PIN26H" will set pin 26 to high and "PIN26L" will set it to low after the button is clicked. We have done this for pins 26, 19 and 13, other GPIO pins can be added just make sure they are not being used by the IoT Bit.
Step 5: Auto_Script.py Script
To set up the GPIO functions to be running indefinitely you need to download the "Auto_Bash.sh" and "Auto_Script.py" from this GitHub link and save them in your "/home/pi" folder:
Then to make the bash script executable do:
- $ chmod +x Auto_Bash.sh
After saving them to your pi and making the bash script executable all you need to do is open terminal and write on the command line:
- $ sudo nano /etc/rc.local
Then at the end just before the "exit 0" input:
- bash /home/pi/Auto_Bash.sh
Reboot your pi to start up the script. You are all done congratulations. The script should be running and whenever you send a message to any of the pins that are set up they will go to high or low respectively. Keep in mind you can always change the keyword to set the pin to high or low.
Step 6: List of SMS Commands
Remember that you can change the SMS commands to any word you wish and add any GPIO pins not used by the raspberry pi just go into the "Auto_Script.py" and look for the above commands and replicate them for other pins.