Jithesh R B
Published

Smart Geyser (Prototype)

To alert the user when the bath is ready according to the user's preference to limit power consumption and water usage

IntermediateProtip1 hour336
Smart Geyser (Prototype)

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×1
Through Hole Resistor, 330 kohm
Through Hole Resistor, 330 kohm
×1
Temperature Sensor
Temperature Sensor
×1
Buzzer
Buzzer
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

VS Code
Microsoft VS Code
Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

Smart Geyser Prototype Schematic

Code

Smart Geyser Prototype Code

Python
MAILGUN_API_KEY = 'Enter your credentials here'
SANDBOX_URL= 'Enter your credentials here'
SENDER_EMAIL = 'Enter your credentials here'
RECIPIENT_EMAIL = 'Enter your credentials here'
API_KEY = 'Enter your credentials here'
DEVICE_ID = 'Enter your credentials here'

from boltiot import Email, Bolt
import json, time




mybolt = Bolt(API_KEY,DEVICE_ID)
mailer = Email(MAILGUN_API_KEY,SANDBOX_URL,SENDER_EMAIL,RECIPIENT_EMAIL)

user=int(input('Do you want your bath to be 1.WARM , 2.LUKE WARM , 3.HOT ,4.VERY HOT. Choose any option''\n'))
if user==1:
    
   minw=int(input('THE MINIMUM TEMPERATURE FOR BATH IS SET AT 0.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT''\n'))
   maxw=int(input('THE MAXIMUM TEMPERATURE FOR BATH IS SET AT 10.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT''\n'))


   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'])
        temp=0.097*sensor_value
        if  minw < temp < maxw :

        
            print("Making request to Mailgun to send an email")
            response = mailer.send_email("WARM BATH READY", "Water is ready and the current temperature is  " +str(temp))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " + str(response_text['message']))
            re=mybolt.digitalWrite('0', 'HIGH')
            print(re)
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

if user==2:
    
   minlw=int(input('THE MINIMUM TEMPERATURE FOR BATH IS SET AT 11.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))
   maxlw=int(input('THE MAXIMUM TEMPERATURE FOR BATH IS SET AT 20.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))


   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'])
        temp=0.097*sensor_value
        if  minlw < temp < maxlw :

        
            print("Making request to Mailgun to send an email")
            response = mailer.send_email("LUKE WARM BATH READY", "Water is ready and the current temperature is" +str(temp))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " + str(response_text['message']))
            re=mybolt.digitalWrite('0', 'HIGH')
            print(re)
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

if user==3:
    
   minh=int(input('THE MINIMUM TEMPERATURE FOR BATH IS SET AT 21.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))
   maxh=int(input('THE MAXIMUM TEMPERATURE FOR BATH IS SET AT 30.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))


   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'])
        temp=0.097*sensor_value
        if  minh < temp < maxh :

        
            print("Making request to Mailgun to send an email")
            response = mailer.send_email("HOT BATH READY", "Water is ready and the current temperature is" +str(temp))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " + str(response_text['message']))
            re=mybolt.digitalWrite('0', 'HIGH')
            print(re)
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

if user==4:
    
   minvh=int(input('THE MINIMUM TEMPERATURE FOR BATH IS SET AT 31.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))
   maxvh=int(input('THE MAXIMUM TEMPERATURE FOR BATH IS SET AT 40.ENTER THE TEMPERATURE IF YOU WANT TO CHANGE IT'))


   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'])
        temp=0.097*sensor_value
        if  minvh < temp < maxvh :

        
            print("Making request to Mailgun to send an email")
            response = mailer.send_email("VERY HOT BATH READY", "Water is ready and the current temperature is" +str(temp))
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " + str(response_text['message']))
            re=mybolt.digitalWrite('0', 'HIGH')
            print(re)
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)


#POLYNOMIAL REGRESSION IS USED TO PREDICT FUTURE TEMPERATURE POINTS.
#PASTE THE CODE GIVEN BELOW IN BOLT PRODUCTS CONFIGURE TAB

#setChartLibrary('google-chart');
#setChartTitle('Temperature Monitoring and Prediction');
#setChartType('predictionGraph')
#setAxisName('time_stamp','temp');
#mul(0.0977);
#plotChart('time_stamp','temp');

Credits

Jithesh R B
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.