This repository has been archived by the owner on Feb 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sms.py
64 lines (49 loc) · 2.01 KB
/
sms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pandas
import time
from twilio.rest import Client
while True:
df=pandas.read_csv("https://thingspeak.com/channels/408082/feed.csv")
df=df.drop(["field4","entry_id","created_at"],1)
df=df.rename(columns={'field1': 'wifi', 'field2': 'humidity', 'field3': 'temp','field5': 'aqi','field6': 'moisture'})
avgwifi=df['wifi'].mean()
avghumidity=df['humidity'].mean()
avgtemp=df['temp'].mean()
avgaqi=df['aqi'].mean()
avgmoisture=df['moisture'].mean()
print(df,'\n')
#Average Values
print("Average Values : ")
print("Average Wifi Strength = ",avgwifi,"dB")
print("Average Humidity = ",avghumidity,"%")
print("Average Temperature = ",avgtemp," Celcius")
print("Average AQI = ",avgaqi)
print("Average Soil Moisture = ",avgmoisture)
print()
#Last Known Values / Current Values (Ignoring invalid indexes
wifi=df['wifi'][df['wifi'].last_valid_index()]
humidity=df['humidity'][df['humidity'].last_valid_index()]
temp=df['temp'][df['temp'].last_valid_index()]
aqi=df['aqi'][df['aqi'].last_valid_index()]
moisture=df['moisture'][df['moisture'].last_valid_index()]
print("Current Values : ")
print("Current Wifi Strength : ", wifi,"dB")
print("Current Humidity : ", humidity,"%")
print("Current Temperature : ",temp,"Celcius")
print("Current AQI : ",aqi)
print("Current Soil Moisture % : ",moisture,"%")
print()
if aqi>100:
account_sid = "ACb2b621362ce2b435ba55c4577fe1ed6d"
auth_token = "fea7e9970181ad490daeba47508e8db0"
client = Client(account_sid, auth_token)
message = client.messages.create(
to="+917738437356",
from_="+17206198978",
body="SMS Testing - Warning! Carbon Monoxide level is above 100 ppm !")
print(message.sid)
elif aqi==0:
print("Heating switched off, sensor is temporarily switched off")
else:
print("Carbon Monoxide level is normal!")
print("Refreshing data in 15 seconds")
time.sleep(15)