|Hand tools and fabrication machines:|
This project was built as the final deliverable of our Embedded System course.
when you hard work and have a hard day in work it's so desirable to drink a hot tea when you arrive home. but you so tired and it's difficult to go to kitchen and start making tea .
so what's the remedy ?
maybe you want a device to make tea for you like me ?
I produce a device that work with a telegram bot .when you arrive home and also you are so tired, just tell it about temperature and thickness of your tea and it start making a good tea for you . it first start heating water and after that pump the hot water into a glass and then start drowning a tea bag in it . after reaching your ordered thickness device call you to drink it.
the intelligent tea maker is made of two primary component
- an electric kettle, a temperature sensor and a water pump that work togethe.
- an DVD Drive that Drowning tea bag into glass.
after joining these two part we have this view :
according to this view when you ask teaMaker to make a tea , it first turn of electrical kettle and measure temperature every one second until rich to desired temperature . after that teaMaker turn off electrical kettle and turn on water pump to transfer water from kettle to glass . then teaMaker turn off water pump and turn on DVD drive motor and drowning tea bag. after these steps your tea is ready to drink !
we need to design multiple modulo and combine theme to build tea maker
- first we need a motor driver to run DVD drive motor . I use a L293D IC to accomplish this task . the following step is wiring L293D :
but we want to drive only one motor(DVD drive motor) with this IC so you need to connect only pin3 and pin6 or pin11 and pin14 of L293D to your motor ( I use pin3 and pin6)
the important point that you should be careful about is how to number L293D pins . you should start from left side of a hole that placed in top of the IC . look at this picture to see this point :
to start connecting motor to L293D I first connect VCC and GND this picture can help you to accomplish this :
be aware that pin2 of raspberry pi is VCC (5 v) and pin6 is GND.
you should connect pin16 of L293D to VCC of raspberry pi and pin 4,5,12,13 to GND and also pin8 of L293D to power supply that depend on type of your motor.
then you most connect data wires . this picture help you :
GPIO 25–Pin 22 of raspberry --> pin1 of L293D
GPIO 24–Pin 18 of raspberry --> pin2 of L293D
GPIO 23–Pin 16 of raspberry --> pin7 of L293D–Pin 7
so far we learn how to connect DVD drive motor to raspberry pi .in following steps we learn about temperature sensor (DS18b20) .
· to connect temperature sensor to raspberry pi you should use 1-wire protocol and I2C port that is enabled by default . but if it is disabled you can enable it from raspberry configuration . you can google this to get more information . be aware that you should use GPIO4 by default to read temperature but you can change it if necessary. this picture help you to wiring DS18b20 :
reading temperature from this modulo is a long process . so i give you a link that completely show you how to connect DS18b20 and how to work with it.
be aware that if you connect wires properly and double check it but the sensor is not working yet connect it's VCC to 5v power instead of 3.3v.
the last modulo we most build is relay . kettle is work with 220 v but raspberry GPIOs is only 3.3 v . so to turning the kettle on we most use a switch . this switch should connect kettle to 220 v when we send a 1 to it and should disconncet it when we send 0 . such a switch is called relay . we use two 3.3 v relay in this project .one for water pump and one for electric kettle . maybe you ask why we don't use L293D to turning on water pump ? because i use an strong motor that L293D can't supply proper current to run it . if you use a light motor then it should work with L293D .
remember that you can't connect relay to raspberry pi directly because it can't supply proper current . you should build and use this circuit :
to identify relay pins use this picture :
by default input pin of relay is connected to normally open pin . when you connect coil pins it disconnect from normally open and connect to normally close pin.
after building relay circuit you have see something like this :
remember that you need 2 item of this circuit so start building another.
now we can start assembling modulo that we already build .
i use GPIO17,GPIO18 for controlling relays . if you also use this two pins , your breadboard most be something like this :
lets start preparing kettle and DVD drive .
in first step you most transfer temperature sensor to kettle.i do it like this :
and then put the water pump in the kettle :
after that you most ready up DVD drive . it is so simple . open DVD drive and put this two wire in it.
now every thing is OK and we can connect kettle and DVD drive to raspberry PI
first connect water pomp to one of two relays that we build earlier and then connect signal pin of relay to GPIO17 on raspberry (breadboard) . also connect the VCC of relay to 3.3 v pin of raspberry (pin 1 or pin 17) and connect GND pin of relay to GND pin of raspberry PI (pin 6 for example) .
you can use 4 battery to run the water pump . after connecting the water pump you breadboard most be like this :
then connect DVD drive to raspberry PI . simply connect that two wires that we put in DVD drive earlier to pin 3 and pin 6 of L293D.
after doing this you most have this this view :
connecting electric kettle is similar to connecting water pump so i don't take picture of it . remember that you most use 220 v instead of 4 battery for kettle.
at last the completed device is :
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters import logging import os import glob import time import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) DVDmotorA=23 DVDmotorB=24 DVDmotorE=25 electricalKettleRelayPin= 18 waterPumpRelayPin= 17 GPIO.setup(DVDmotorA,GPIO.OUT) GPIO.setup(DVDmotorB,GPIO.OUT) GPIO.setup(DVDmotorE,GPIO.OUT) GPIO.setup(electricalKettleRelayPin,GPIO.OUT) GPIO.setup(waterPumpRelayPin,GPIO.OUT) GPIO.output(DVDmotorA,False) GPIO.output(DVDmotorB,False) GPIO.output(electricalKettleRelayPin,False) GPIO.output(waterPumpRelayPin,False) global teaTemp global teaStrongness os.system('modprobe w1-gpio') os.system('modprobe w1-therm') base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*') device_file = device_folder + '/w1_slave' def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() return lines def read_temp(): lines = read_temp_raw() while lines.strip()[-3:] != 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines.find('t=') if equals_pos != -1: temp_string = lines[equals_pos+2:] temp_c = float(temp_string) / 1000.0 temp_f = temp_c * 9.0 / 5.0 + 32.0 return temp_c def DVDmotor(cmd): if (cmd == 'open'): print ("Turning motor on") GPIO.output(DVDmotorA,GPIO.HIGH) GPIO.output(DVDmotorB,GPIO.LOW) GPIO.output(DVDmotorE,GPIO.HIGH) return if (cmd == 'close'): print ("Stopping motor") GPIO.output(DVDmotorA,GPIO.LOW) GPIO.output(DVDmotorB,GPIO.HIGH) GPIO.output(DVDmotorE,GPIO.HIGH) return if (cmd == 'stop'): GPIO.output(DVDmotorA,GPIO.LOW) GPIO.output(DVDmotorB,GPIO.LOW) GPIO.output(DVDmotorE,GPIO.LOW) return def waterPumpMotor(cmd): if (cmd == 'start'): print ("Turning motor on") GPIO.output(waterPumpRelayPin,True) return if (cmd == 'stop'): GPIO.output(waterPumpRelayPin,False) return def makeTea() : print('starting !') temp = read_temp() if temp<75 : print('water is so cold , please wait') GPIO.output(electricalKettleRelayPin,True) while temp<75 : sleep(1) temp=read_temp() print (temp) GPIO.output(electricalKettleRelayPin,False) print('well,the water temp is high') print('start sucking water') GPIO.output(waterPumpRelayPin,True) waterPumpMotor('start') sleep(10) GPIO.output(waterPumpRelayPin,False) waterPumpMotor('stop') i=0 while i<10: DVDmotor('open') sleep(2) DVDmotor('close') sleep(5) i = i+1 DVDmotor('stop') print('ok') # Enable logging logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) # Define a few command handlers. These usually take the two arguments bot and # update. Error handlers also receive the raised TelegramError object in error. def start(bot, update): update.message.reply_text('Hi..Whats up ? you are so tired.right ? i help you to drink a good tea !') update.message.reply_text('Please Select your preferd tea Hot or Warm ? Enter Warm for warm and Hot for a hot tea !') def help(bot, update): """Send a message when the command /help is issued.""" update.message.reply_text('Help!') def getInfo(bot, update): """Echo the user message.""" update.message.reply_text(update.message.text) temp = update.message.text if (temp=='Warm' or temp=='Hot'): if(temp=='warm' or temp=='Warm'): teaTemp = 75 else : teaTemp = 80 update.message.reply_text('Good! Now Tell Me About Tea Stringness . Strong for a strong tea and Light for a light tea') else: if(temp=='Strong' or temp =='strong') : teaStrongness = 15 else: teaStrongness = 10 update.message.reply_text('Well! your tea is in making process ! please wait until i notify you !') makeTea() update.message.reply_text('Your Tea is Ready MyLord ! Please Come and Drink it') def error(bot, update, error): """Log Errors caused by Updates.""" logger.warning('Update "%s" caused error "%s"', update, error) def main(): """Start the bot.""" # Create the EventHandler and pass it your bot's token. updater = Updater("509298071:AAEkyahfx-tEYYUeXXKph4TWQhMM8YK8iQ4") # Get the dispatcher to register handlers dp = updater.dispatcher # on different commands - answer in Telegram dp.add_handler(CommandHandler("start", start)) dp.add_handler(CommandHandler("help", help)) # on noncommand i.e message - echo the message on Telegram dp.add_handler(MessageHandler(Filters.text, getInfo)) # log all errors dp.add_error_handler(error) # Start the Bot updater.start_polling() # Run the bot until you press Ctrl-C or the process receives SIGINT, # SIGTERM or SIGABRT. This should be used most of the time, since # start_polling() is non-blocking and will stop the bot gracefully. updater.idle() if __name__ == '__main__': main()
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!