Str Error in Temperature sensor for sending SMS

I’m getting str error for Twilio.
Take a look at my program and error I’m receiving and help me to solve it.
Thank You.

please check your code once again maybe you have forgotten to write few values in the middle.

I checked it twice but I didn’t find any, please help me if you found any.

In line 6th u have to use conf . instead of confy. i am sending you the correct code use this and follow the same step which you followed from training .

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

minimum_limit = 300
maximum_limit = 600  

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']))
        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)

Hope your problem will solve now . …

1 Like

Hi @sauravghag8,

I think you are not getting the proper response from the Bolt Cloud. To check the response from the Bolt cloud, add a print statement just after data = json.loads(response)

data = json.loads(response)
print (data)

and then share a screenshot of the output of the code.

Do let m know in case you need further assistance.