I have installed boltiot on the ubuntu server but I’m unable to import sms from boltiot. Please help and thanks in advance.
I think you’re boltiot module has not been installed properly. Re-enter the command to install the boltiot module.
just go through the python installation guides in the course and properly install the sms module
Check your code. There might be a spelling error.
Hello Dear,
Kindly ensure that boltiot lib is installed in your machine. If not, use following command
Step 1: Update the packages on Ubuntu
Execute the command below so that the packages on Ubuntu are updated to the latest version. If you skip this step, you may encounter an error while installing the Boltiot package.
sudo apt-get -y update
Step 2: Install python3 pip3
pip3 is a package manager for python3 used to install and manage packages and python libraries. It is system independent.
Install pip3 using the following command,
sudo apt install python3-pip
Step 3: Installing boltiot library using pip
Now we will install the boltiot python library on your Ubuntu server.
Type the below command in terminal to install boltiot python library.
sudo pip3 install boltiot
Now we are done with boltiot python library installation. In the next section, we will learn how to use the Bolt python library to check the device status and switch off the device.
Refer following code for sms sending using Twillio–
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’]))
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(10)