@dixitupagyya23
Some part of your code is not visible in the screenshot.
Can you please copy paste the entire code instead of sharing the screenshot of the same?
import email_conf
from boltiot import Email, Bolt
import json, time
minimum_limit = 300 #the minimum threshold of light value
maximum_limit = 600 #the maximum threshold of light value
mybolt = Bolt(email_conf.API_KEY, email_conf.DEVICE_ID)
mailer = Email(email_conf.MAILGUN_API_KEY, email_conf.SANDBOX_URL, email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL)
while True:
print (āReading sensor valueā)
response = mybolt.analogRead(āA0ā)
data = json.loads(response)
print ("Sensor value is: " + str(data[āvalueā]))
try:
sensor_value = int(data[āvalueā])
if sensor_value > maximum_limit or sensor_value < minimum_limit:
print(āMaking request to Mailgun to send an emailā)
response = mailer.send_email(āAlertā, "The Current temperature sensor value is " +str(sensor_value))
response_text = json.loads(response.text)
print("Response received from Mailgun is: " + str(response_text[āmessageā]))
except Exception as e:
print (āError occured: Below are the detailsā)
print (e)
time.sleep(10)
here it is @yeshwant.naik
please help me to resolve my problem
If the indentation is right, then i guess there could be some error in the conf.py file u have writtenā¦
As far as the code, it seems rightā¦
Refer this and check out once again.
https://trainings.boltiot.com/courses/iotandml/lectures/6656783
but it is showing error in json function line.
@dixitupagyya23 Check if you have another file with the name json.py in the same directory as your program. Rename the json.py file and try again.
Actually there is an intendation error just be specific with python intendation and your code will run.
check the spelling of mailer.send_emaail in line 23 which is wrong thatās why error is occurring. And your problem is solved. That much you have to do mailer.send_email.
@dixitupagyya23 Thereās a spelling mistake in your code. change your response line "response = mailer.send_email(āAlertā, āThe Current temperature sensor value is " +str(sensor_value))ā