Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Salman Faris
Published © GPL3+

Jarvis - Personal Assistant

A personal assistant powered by Linklt Smart 7688 Duo and Telegram Bot for a smart office and smart home.

IntermediateFull instructions provided1 hour4,087
Jarvis - Personal Assistant

Things used in this project

Hardware components

DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
4 Channel DC 5V Relay Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
PuTTY
WinSCP
Telegram Bot

Story

Read more

Schematics

Wiring

Flowchart

Code

Python Code

Python
#coder :- Salman Faris
import sys
import mraa
import time
import random
import datetime
import telepot
import serial 


 
s= None

def setup():
    global s
    s = serial.Serial("/dev/ttyS0", 57600)
    

 

def handle(msg):
    chat_id = msg['chat']['id']
    command = msg['text']

    print 'Got command: %s' % command
    
    
    if command =='/start':
       bot.sendMessage(chat_id,"Hi, Am Jarvis Your Personal Assistant Powerd by Linit7688 Duo developed by Salman Faris. ")
       bot.sendMessage(chat_id,"Am here to help You...! ")
       bot.sendMessage(chat_id,"to know more about my command type /help")
    elif command == '/help':
        bot.sendMessage(chat_id,"/TurnOnBedroomLight or /TurnOffBedroomLight :- to turn on/off bedroom light")
        bot.sendMessage(chat_id,"/TurnOnKitchenLight or /TurnOffKitchenLight :- to turn on/off Kitchen light")
        bot.sendMessage(chat_id,"/TurnOnLights or /TurnOffLights :- to turn on/off all the light")
        bot.sendMessage(chat_id,"/RoomTemp :- To know about Room Temperature ")
        bot.sendMessage(chat_id,"/RoomHumi :- To know about Room Humidity ")
        bot.sendMessage(chat_id,"/News :- To read Latest News ")
        s.write("1")
    elif command == '/TurnOnBedroomLight':
        bot.sendMessage(chat_id,"ok..Bedroom light now ON")
        s.write("1")
    elif command =='/TurnOffBedroomLight':
         bot.sendMessage(chat_id,"ok...Bedroom light now OFF")
         s.write("0")
    elif command == '/TurnOnKitchenLight':
         bot.sendMessage(chat_id,"ok...kitchen light now ON")
         s.write("3")
    elif command == '/TurnOffKitchenLight':
         bot.sendMessage(chat_id,"ok...kitchen light now OFF")
         s.write("2")
    elif command == '/TurnOnLights':
         bot.sendMessage(chat_id,"bedroom and kitchen light's are On")
         s.write("1")
         s.write("3")
    elif command == '/TurnOffLights':
         bot.sendMessage(chat_id,"bedroom and kitchen light's are On")
         s.write("0")
         s.write("2")
    elif command == '/RoomTemp':
         bot.sendMessage(chat_id,"Temperature is")
         s.write("5")
         a = s.read(5)
         bot.sendMessage(chat_id,a)
         bot.sendMessage(chat_id,"Celsius")
    elif command == '/RoomHumi':
         bot.sendMessage(chat_id,"Humidity is ")
         s.write("4")
         a = s.read(5)
         bot.sendMessage(chat_id,a)
    elif command == '/News':
         bot.sendMessage(chat_id,"http://www.bbc.com/news/world")
         bot.sendMessage(chat_id,"http://timesofindia.indiatimes.com/news")
         bot.sendMessage(chat_id,"http://www.ndtv.com/latest")
         
    else:
        bot.sendMessage(chat_id,"Wrong Command")
        bot.sendMessage(chat_id,"please check /help section to know more about Command's")



bot = telepot.Bot('bot token')
bot.message_loop(handle)
print 'I am listening...'

while True:
    setup()

Arduino Code

C/C++
#include <DHT.h>

#define DHTPIN A1  // DHTT pin connected to A1
#define DHTTYPE DHT11   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);  // Initialize DHT sensor 


int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup() { 
          
          dht.begin();  //begin the DHTT
          
          Serial.begin(115200);  // open serial connection to USB Serial 
                                 //port(connected to your computer)
          Serial1.begin(57600);  // open internal serial connection to 
                                 //MT7688

          pinMode(13, OUTPUT); // Bedroom light
          pinMode(12,OUTPUT);  // kitchen light  
          
      }
      void loop() { 
         hum = dht.readHumidity();   // read humdity
         temp= dht.readTemperature();  //read temperature
         
            int c = Serial1.read();      // read from MT7688
            if (c != -1) {
                  switch(c) { 
                        case '0':                // turn off D13 when receiving "0"
                        digitalWrite(13, 0); 
                        break; 
                        case '1':                // turn on D13 when receiving "1" 
                        digitalWrite(13, 1); 
                        break; 
                        case '2':                // turn off D12 when receiving "1" 
                        digitalWrite(12,0);
                        break;
                        case '3':                // turn on D12 when receiving "1" 
                        digitalWrite(12,1);
                        break;
                        case '4':               // print temperature when receiving "4"
                        Serial1.print(hum);
                        break;
                        case '5':               //print humidity when receiving "5"
                        Serial1.print(temp);
                        break;
                        
                        
                        
                       
                  } 
            } 
      }

Credits

Salman Faris
26 projects • 418 followers
Maker | Hardware Hacker | Electronics Enthusiast

Comments