-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserialconection.py
39 lines (34 loc) · 1.23 KB
/
serialconection.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
import serial
arduino =serial.Serial('COM7',9600)
import smtplib
from email.message import EmailMessage
from datetime import datetime
now=datetime.now()
current_time=now.strftime("%H:%M:%S")
server=smtplib.SMTP_SSL('smtp.gmail.com',465)
server.login('[email protected]','replace yours')
msg=EmailMessage()
usub="low quantity of stock"
vsub = "orders placed by user"
vendor='[email protected]'
user='[email protected]'
def sendmail(content,emailreciver,subject,emailsender):
msg = EmailMessage()
msg.set_content(content)
msg["To"]=emailreciver
msg['from']=emailsender
msg['Subject']=subject
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login('[email protected]', 'bnnbtzjuznnmpyvq')
server.send_message(msg)
while True:
height=abs(float(arduino.readline().decode().strip()))
mass =height
print(height)
ucontent = "sugar is low quantity\n Reaming quantity:-" + str(mass)+"grams\nRequired quantity:-"+str(1000)+'grams\nOrder placed to vendor'
vcontent ="Stockname:-sugar\nRequired quantity:-"+str(1000)+'grams\nOrder placed at '+current_time+""
print(ucontent,vcontent)
if height<=59:
sendmail(ucontent,user,usub,vendor)
sendmail(vcontent,vendor,vsub, vendor)
quit()