Close
0%
0%

Kids School Control

Notifies parents when their kid came to school via SMS

Similar projects worth following
Notifies parents when their kid came to school via SMS.

Hardware used : Raspberry Pi3 + NFC module + GSM Modem (Huawei)
When kid is at school, he approaches to Rpi, uses his card or keychain to "authorize".
Rpi is sending SMS to his parents with authorization time.

Parents can be calm. :)

*This is ongoing project and i still have a lot of work to do ...


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:

  1. Get session id
  2. Get token
  3. 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!"

x-python - 1.39 kB - 09/22/2017 at 13:24

Download

x-shellscript - 524.00 bytes - 09/21/2017 at 13:08

Download

x-shellscript - 162.00 bytes - 09/21/2017 at 13:08

Download

x-shellscript - 100.00 bytes - 09/21/2017 at 13:08

Download

x-python - 149.00 bytes - 09/21/2017 at 13:07

Download

View all 6 files

  • 1 × Raspberry Pi 3
  • 1 × RFID reader/writer module MFRC522
  • 1 × USB Huawei 3372 modem
  • 2 × Led Green and Red

  • Adding script to crontab

    Evghenii09/21/2017 at 14:22 0 comments

    To automatically start script at boot, we need to add it to crontab.

    crontab -e

     add the following line to the end of crontab 

    @reboot python /path/to/script/read.py

     After reboot, script will start and listen to new cards

  • Schematics :)

    Evghenii09/21/2017 at 14:10 0 comments

  • Usb Huawei Modem

    Evghenii09/21/2017 at 13:33 0 comments

    Connect usb modem and check it 

    lsusb
    

     The output will be something like Huawei Technologies...

    You can also check its status by accessing web page
    http://192.168.8.1

  • Led's

    Evghenii09/21/2017 at 13:28 0 comments

    Connect your led to any gpio you want + GND. In my case i used GPIO16 for green led and GPIO26 for red. 

  • NFC/RFID Connection

    Evghenii09/21/2017 at 13:20 0 comments

    Connect RFID sensor to rpi as follows



  • ​Led Connection

    Evghenii09/21/2017 at 13:18 0 comments

    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

  • Update & upgrade

    Evghenii09/21/2017 at 13:15 0 comments

    sudo apt-get update
    sudo apt-get dist-upgrade

View all 7 project logs

Enjoy this project?

Share

Discussions

blum675 wrote 07/31/2023 at 20:22 point

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.

  Are you sure? yes | no

BrendaPratt wrote 04/17/2021 at 06:35 point

Thanks for introducing me to this marvelous tool, I'm looking for such a device for my college project. I want the device to work as desired and now it's time to check australian assignment help to hire a legit services. A search of this device on the internet found that your website was the only website that featured this product.

  Are you sure? yes | no

Evghenii wrote 09/21/2017 at 16:35 point

Hi, do you mean that NFC card tags can match with another one?

  Are you sure? yes | no

Kyle N. wrote 09/21/2017 at 15:41 point

Does this project include prevention mechanisms for replay attacks?  Wouldn't be hard to spoof someone else's NFC tag(s) with the current setup as I understand it.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates