import conf, json ,time from boltiot import Sms, Bolt minimum_limit = 290 maximum_limit = 330 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 " +$ 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(10)
Tabs and spaces are shown as whitespace on your screen.This is because there is no rule on how wide a tab character should be. Python expects the rest of the lines to have same indentation as the first line.
Go to the settings of your text editor. Click on enable the " convert tabs to spaces". This method replaces tab character with n space characters or press Ctrl and T. Once the the property panel opens tick the Tabs as spaces.
In your python editor use Edit> Untabify region. This converts tab to spaces.
We must indentation (spaces before statements after lops,if-else,function initialisation etc,.)whlle using loops,if-else statements,functions etc.,. in python in python language. You have to give some spaces infront of statements inside the loop we use,inside any function we use, and to all statements for which if-else ,try -execpt conditions applied by us.
NOTE: we must use spaces all over the code or tab spaces all over the code ,any one only. It is not right of using sometimes spaces and sometimes tabs in the same code.
That’s why ,you are getting that type of error as "inconsistent use of tabs and spaces"
So , correct them for proper execution of the code.
THE CODE WILL BE LIKE THIS :
These spaces are must and should in python language. Without them we can’t our programs. These are because to seperate the statements of loops,functions from other statements we use in remaining program. So that compiler can know which statements are main and which are of loops and conditions.
I hope it will be helpful to you.