Related to sms project

please help with the above error

Hello birjeyugandhara1798,
You have to give indentation for specifying the blocks.
Here blocks refer to while loop , if…else statements ,etc;
In c,c++ programming languages , we use { } (flower brackets) to specify blocks.
In python , we have to use indentation i.e; space to specify blocks.
Hope you understood !!:slightly_smiling_face:

Thanks for the reply @suryaanirudh2611.I will correct it immediately

hey [birjeyugandhara1798] .!
On 12th line you have to put conditions of " if " inside a bracket like ()
i.e. the line will be like
if (sensor_value>maximum_limit)
and after that use a curly bracket like " { } " put print command inside the curly bracket.

how to resolve above error

The code

try the below stated code just copy and paste it’ll work 100%

import conf
from boltiot import Sms, Bolt
import json, time

minimum_limit = 400     #manage according to yours
maximum_limit = 423.15  #manage according to yours


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)


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 Twilio to send a SMS")
            response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(2)
1 Like

Thanks @prasad.hunny03 .i completed the project yesterday itself

1 Like