SMS based device control with GSM Modem on Raspberry Pi

import serial import RPi.GPIO as GPIO import sys, math import io import os,time import string GPIO.setmode(GPIO.BCM) #print (“rcv”) # Enable Serial Communication port = serial.Serial(“/dev/ttyS0″, baudrate=115200, timeout=1) # Transmitting AT Commands to the Modem # ‘\r\n’ indicates the Enter key # at_command=to_bytes(‘AT\r\n’) port.write(b”AT\r\n”) port.flush() rcv = port.read(20) print(rcv) time.sleep(1) port.write(b”AT+CMGR=1\r\n”) port.flush() rcv = port.read(250) print(rcv) time.sleep(1) if b”220130″ in rcv or b”220131″ in rcv: if b”220130″ in rcv: print (“Got Zero”) else: print (“Got One”) print(“Complete”) print(“testing complete”) ##port.write(b”AT+CMGD=2\r\n”) ##port.flush() ##rcv = port.read(250) ##print(rcv) ##time.sleep(1) ## ##port.write(b”AT+CMGR=2\r\n”) ##port.flush() ##rcv = port.read(250) ##print(rcv) ##time.sleep(1)
You can leave a response, or trackback from your own site.
Leave a Reply to the article

Learning & Certifications
Follow Us
Facebook Icon   Linked In Icon   Twitter Icon  
Validation and Recognition

Valid CSS! Valid HTML5!          Protected by Copyscape