Kids School Control
Preparation:
RFIDConnection
Pins:
We need this to connect our RFID module to Raspberry pi 3.
- Preparation
$ sudo nano /etc/modprobe.d/raspi-blacklist.conf #blacklist spi-bcm2708 $ sudo apt-get install python-dev $ git clone https://github.com/lthiery/SPI-Py.git $ cd SPI-Py $ sudo python setup.py install
- read.py When the script finds authorized card, it turns on the green led and send sms.
import MFRC522 import signal import os import time continue_reading = True MIFAREReader = MFRC522.MFRC522() cardA = [224,96,42,137,35] cardB = [176,203,130,124,133] cardC = [20,38,121,207,132] def end_read(signal, frame): global continue_reading continue_reading = False print "Ctrl+C captured, ending read." MIFAREReader.GPIO_CLEEN() signal.signal(signal.SIGINT, end_read) while continue_reading: (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) if status == MIFAREReader.MI_OK: print "Card detected" (status,backData) = MIFAREReader.MFRC522_Anticoll() if status == MIFAREReader.MI_OK: print "Card read UID: "+str(backData[0])+","+str(backData[1])+","+str(backData[2])+","+str(backD$ if backData == cardA: print "Vasea Pupkin" os.system("python /home/pi/SPI-Py/MFRC522-python/greenled.py 2>/dev/null") date_string = time.strftime("%Y-%m-%d-%H:%M:%S") os.system("./sending.sh telnumber 'Vasea at school-'" + date_string) elif backData == cardB: print "Kris" os.system("python /home/pi/SPI-Py/MFRC522-python/greenled.py 2>/dev/null") date_string = time.strftime("%Y-%m-%d-%H:%M:%S") os.system("./sending.sh telnumber 'Kris at school-'" + date_string) elif backData == cardC: print "is Card C" else: print "wrong Card" os.system("python /home/pi/SPI-Py/MFRC522-python/redled.py 2>/dev/null")
- Using Example
$ git clone https://github.com/rasplay/MFRC522-python.git $ cd MFRC522-python $ sudo python read.py
$ sudo python read.py
Led Connection
Connect your led to any gpio you want + GND. In my case i used GPIO16 for green led and GPIO26 for red. When you are done, test it:
Create 2 simple python scripts for green and red led with following content:
- greenled.py
from gpiozero import LED from time import sleep led = LED(16) while True: led.on() sleep(3) led.off() led.cleanup()
- redled.py
from gpiozero import LED from time import sleep led = LED(26) while True: led.on() sleep(3) led.off() led.cleanup()
- And then test it. If led's are glowing, then everything works good.
python greenled.py python redled.py
Sending SMS
Here 3 steps are necessary:
- Get session id
- Get token
- Send / receive sms
Step 1 - Get session id For getting the session id I use the following command in an own shell script. Create shell script session.sh :
#!/bin/bash
curl -b session.txt -c session.txt http://192.168.8.1/html/index.html > /dev/null 2>&1
Step 2 - Get token
For getting the token I use the following commands, also in an own shell script token.sh :
#!/bin/bash
TOKEN=$(curl -s -b session.txt -c session.txt http://192.168.8.1/html/smsinbox.html)
TOKEN=$(echo $TOKEN | cut -d'"' -f 10)
echo $TOKEN > token.txt
Step 3 Part A - Send SMS
Finally a third shell script "sending.sh" for sending the sms, which also invokes the two other scripts:
#!/bin/bash
NUMBER=$1
MESSAGE=$2
./session.sh
./token.sh
LENGTH=${#MESSAGE}
TIME=$(date +"%Y-%m-%d %T")
TOKEN=$(<token.txt)
SMS="<request><Index>-1</Index><Phones><Phone>$NUMBER</Phone></Phones><Sca/><Content>$MESSAGE</Content><Length>$LENGTH</Length><Reserved>1</Reserved><Date>$TIME</Date></request>"
echo $SMS
curl -v -b session.txt -c session.txt -H "X-Requested-With: XMLHttpRequest" --data "$SMS" http://192.168.8.1/api/sms/send-sms --header "__RequestVerificationToken: $TOKEN" --header "Content-Type:text/xml"
Now test it:
./sending.sh yourtelnumber "Hello World!"
School and essay are two important aspects of education. Schools are educational institutions where students learn and acquire knowledge and skills. Essays, on the other hand, are written assignments https://essaywriter.org/ given to students to demonstrate their understanding of a subject or topic. Students often write essays as part of their academic coursework, and it helps them develop critical thinking, research, and writing skills. Essays play a significant role in assessing students' comprehension and ability to express their thoughts effectively.