Jul-06-2019, 02:10 AM
(This post was last modified: Jul-06-2019, 02:10 AM by ElectronicsNut.)
I am an ElectronicsNut that is venturing into foreign coding territory. I have a Raspberry Pi that I have connected to a FONA 3G cellular module via port ttyUSB0. The attached code is up and running, but I would like to modify the line of code in Python script with a variable that would be used to specify a specific ALERT. The current test message that is sent to my cell phone in the code is "ALERT MESSAGE" (for testing purposes), which I would like to make a variable called "Alert Message". Based on the coding that I write, the Alert Messages could be:
Fridge Low Temperature Alert
Freezer Low Temperature Alert
Low Water Pressure Alert
No AC voltage
.....
I just need to figure out how to insert the variable in that line of code (see below).
I left the rcv and print lines in for testing purposes.
Thanks in advance for any assistance
Fridge Low Temperature Alert
Freezer Low Temperature Alert
Low Water Pressure Alert
No AC voltage
.....
I just need to figure out how to insert the variable in that line of code (see below).
I left the rcv and print lines in for testing purposes.
Thanks in advance for any assistance
import serial import RPi.GPIO as GPIO import os, time port = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=1) rcv = port.read(10) print rcv port.write('AT'+'\r\n') rcv = port.read(10) print rcv port.write('ATE0'+'\r\n') rcv = port.read(10) print rcv port.write('AT+CMGF=1'+'\r\n') rcv = port.read(10) print rcv port.write('AT+CMGS="xxxxxxxxxx" '+'\r\n') rcv = port.read(10) print rcv [b]port.write('ALERT MESSAGE'+'\r\n')[/b] rcv = port.read(10) print rcv port.write("\x1A") rcv = port.read(10) print rcv port.close()