The aim of this project is to manage the Temperature control and if there exist any change in temperature we will get a notification (i.e. In Twitter) that the temperature has crossed such a limit.
Since I know that by using the BOLT Wifi Module which is at a cheaper price and then implementing in large scale purpose so, it will be helpful for companies with less input and maximum output to be achieved.
So we can implement this logic in medicinal companies where for particular medicine a particular temperature is to be set.
Step 1:Hardware Requirements:
1] Breadboard
2] BOLT WiFi Module
3] LM35 Temperature Sensor
4] 2LEDs
5] Power USB
6] Jumper Wires
7] Buzzer
Making the Circuit Connection:
i) Take breadboard
ii) Insert two LEDs (form making alert to look effecient) and buzzer in breadboard as shown below:
iii) Make connection of LM35 sensor (5V, A0, GND) in this format:
iv) Make connection of both LEDs as shown below:
v) Make connection of both buzzers as shown below:
Software Requirements:
1] Twitter Account
Steps for creating Twitter account:
- Create a twitter account by moving to url :https://twitter.com/login?lang=en
- Afterwards do the following steps given in image below:
- Now you have done with your twitter account and creation:
- Now go to the url : https://cloud.boltiot.com/login
- Now create an account as follows given in image below:
- Then you need to install Application in your Android phone for interacting with the BOLT cloud.
- Perform the following steps as given in image below:
- After above step and open the BOLT Account (i.e from https://cloud.boltiot.com/login)
- You will see a Green Button on.(NOTE: If all above step is performed and usb is connected to the BOLT Module)
- Connect the LM35 sensor using the steps below:
- Open Twitter you will see this image:
- Go to scripts in Python folder giving the path in cmd.
- The use this command and press Enter.
- pip install boltiot
- Below image displays what will be seen in cmd.
- Then install the next command in cmd :
Note: Perform same step as for Bolt IoT module.
- Here there are 2 files of.py extension first one is:
1] File 1: conftwitter.py
Code:
consumer_key = "Consumer Key (API Key) for Twitter App"
consumer_secret = "Consumer Secret (API Secret) for Twitter App"
access_token = "Access Token for Twitter App"
access_token_secret = "Access Token Secret for Twitter App"
bolt_cloud_api_key = "API key of your Bolt Cloud. You can find in API section on Bolt Cloud"
device_id = "ID of your Bolt Device"
Note: Here you should replace the Quotes with your personal keys.
2] File 2: post-tweet.py
Code:
- Console output is displayed as:
- The notification in Twitter is displayed as follows:
- After changing the value and again running we get:
- Output:
- The notification in twitter is displayed as follows:
- After all is done check for connection in below image and run it.
- Now, you will receive the notifications in your twitter account.
For full source code, please refer below (conf-twitter.py):
import tweepy
import conftwitter, json, time
from boltiot import Bolt
api_key = "1a48f33d-71f1-4259-8207-4a7b913486aa"
device_id = "BOLT6093942"
mybolt = Bolt(api_key, device_id)
response1 = mybolt.digitalWrite('1', 'HIGH')
print(response1)
response1 = mybolt.digitalWrite('1', 'LOW')
print(response1)
# Dictionary to store credentials as key-value pairs.
config = {
"consumer_key" : conftwitter.consumer_key,
"consumer_secret" : conftwitter.consumer_secret,
"access_token" : conftwitter.access_token,
"access_token_secret" : conftwitter.access_token_secret
}
# Method to authenticate user via Tweepy and return API object
def get_api_object(cfg):
auth =tweepy.OAuthHandler(cfg['consumer_key'],
cfg['consumer_secret'])
auth.set_access_token(cfg['access_token'],
cfg['access_token_secret'])
return tweepy.API(auth)
mybolt = Bolt(conftwitter.bolt_cloud_api_key, conftwitter.device_id)
temperature_threshold =5900
while True:
response = mybolt.analogRead('A0')
data = json.loads(response)
print (data['value'])
try:
sensor_value = int(data['value'])
tt1=int(sensor_value/10.24)
print("Sensor value: ", tt1, "Celsius")
if sensor_value > temperature_threshold:
print ("*** Temperature has crossed the threshold !!! Current temperature is:", tt1, "Celsius. ***")
# Call get_api_object to authenticate user and get the API object
api_object = get_api_object(config)
response1 = mybolt.digitalWrite('1', 'HIGH')
print(response1)
response2 = mybolt.digitalWrite('2', 'HIGH')
print(response2)
response3 = mybolt.digitalWrite('3', 'HIGH')
print(response3)
# Store the tweet message in the variable
tweet = "*** Temperature_has_crossed_the_threshold !!! Current_temperature_is:", tt1, "Celsius. ***"
# Post the tweet on your Twitter account using the update_status method.
status = api_object.update_status(status=tweet)
else:
print ("*** Temperature has not crossed the threshold !!! Current temperature is:", tt1, "Celsius. ***")
# Call get_api_object to authenticate user and get the API object
api_object = get_api_object(config)
# Store the tweet message in the variable
tweet = "*** Temperature_has_not_crossed_the_threshold !!! Current_temperature_is:", tt1, "Celsius. ***"
# Post the tweet on your Twitter account using the update_status method.
status = api_object.update_status(status=tweet)
response1 = mybolt.digitalWrite('1', 'HIGH')
print(response1)
response2 = mybolt.digitalWrite('2', 'HIGH')
print(response2)
response3 = mybolt.digitalWrite('3', 'HIGH')
print(response3)
response1 = mybolt.digitalWrite('1', 'LOW')
print(response1)
response2 = mybolt.digitalWrite('2', 'LOW')
print(response2)
response3 = mybolt.digitalWrite('3', 'LOW')
print(response3)
except Exception as e:
print ("An error occurred ", e)
time.sleep(10)
Output:
i) When value for temperature_threshold is 59 (If sensor value is greater than temperature threshold).
1] Before running the Python file:
2] After executing the Python (conf-twiter.py) the first LED starts blinking.
3] Here both LEDs start blinking and buzzer starts alert sound until and unless any person knows there is any need for emergency and external input is made.
For example: In medicine company to know if for a particular medicine temperature change and externally temperature is adjusted by employee.
Output:
i) When value for temperature_threshold is 1500 (If sensor value is less than temperature threshold).
1] Before running the Python file:
2] Since the sensor value is less than temperature threshold so both LEDs start blinking and buzzer starts alerting sound for some time and then it stops automatically.
That's all!
Comments
Please log in or sign up to comment.