Geet jiDeepak AgarwalTsering Losel
Published

ECHOTRON: College RoboGuide

A voice automated bot that takes you around a college campus.

IntermediateFull instructions provided30 days1,549

Things used in this project

Hardware components

WIZwiki-W7500
WIZnet WIZwiki-W7500
×2
WIZ750SR
WIZnet WIZ750SR
×1
RFID Module (Generic)
RC522
×1
RJ45 Patch Cord CAT5 Ethernet LAN Network Patch Cable
Ethernet Cable
×1
TP-Link TL-WR841N 300Mbps Wireless-N Router
Router
×1
Echo Dot
Amazon Alexa Echo Dot
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

ThingSpeak API
ThingSpeak API
os.mbed.com
AWS Lambda
Amazon Web Services AWS Lambda
AWS IoT
Amazon Web Services AWS IoT
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit

Story

Read more

Schematics

WIz7500 and RFID's

Connection between WIz7500 and RFID's

WIZ Boards and RFID connection

Receiving data values from RFID tags when tapped in RFID reader connected with WizWiki-W7500

Code

AWS lambda function

Python
This code is for the alexa skills kit implementation for a new user who enters into the campus and wants to now his/her suitable block
def get_welcome_response():
    """ If we wanted to initialize the session to have some attributes we could
    add those here
    """
 
    session_attributes = {}
    card_title = "Welcome"
    speech_output = "Welcome to the Christ University Faculty Of engineering " \
                    "Please tell me your subject choice by saying, " \
                    "my favorite subject is electronics or computers or electrical"
    # If the user either does not reply to the welcome message or says something
    # that is not understood, they will be prompted again with this text.
    reprompt_text = "Please tell me your favorite subject by saying, " \
                    "my favorite sub is electronics or e.c.e ."
    should_end_session = False
    return build_response(session_attributes, build_speechlet_response(
        card_title, speech_output, reprompt_text, should_end_session))
 
 
def handle_session_end_request():
    card_title = "Session Ended"
    speech_output = "Thank you . " \
                    "Have a nice day! "
    # Setting this to true ends the session and exits the skill.
    should_end_session = True
    return build_response({}, build_speechlet_response(
        card_title, speech_output, None, should_end_session))
 
 
def create_favorite_sub_attributes(favorite_sub):
    return {"favoriteSub": favorite_sub}
 
 
def set_sub_in_session(intent, session):
    """ Sets the sub in the session and prepares the speech to reply to the
    user.
    """
 
    card_title = intent['name']
    session_attributes = {}
    should_end_session = False
 
    if 'Sub' in intent['slots']:
        favorite_sub = intent['slots']['Sub']['value']
        session_attributes = create_favorite_sub_attributes(favorite_sub)
        speech_output = "I now know your favorite subject is " + \
                        favorite_sub + \
                        ". You can ask me your suitable block by saying, " \
                        "what's my suitable block?"
        reprompt_text = "You can ask me your suitable block by saying, " \
                        "what's my favorite subject?"
    else:
        speech_output = "I'm not sure what your favorite subject is. " \
                        "Please try again."
        reprompt_text = "I'm not sure what your favorite subject is. " \
                        "You can tell me your favorite subject by saying, " \
                        "my favorite subject is computers."
    return build_response(session_attributes, build_speechlet_response(
        card_title, speech_output, reprompt_text, should_end_session))
 
 
def get_sub_from_session(intent, session):
    session_attributes = {}
    reprompt_text = None
 
    if session.get('attributes', {}) and "favoriteSub" in session.get('attributes', {}):
        favorite_sub = session['attributes']['favoriteSub']
        if favorite_sub == "electronics" or favorite_sub == "computers":
            speech_output = "Your suitable block is second block for  " + favorite_sub + \
                        ". Goodbye."
            should_end_session = True
        elif favorite_sub == "civil" or favorite_sub == "electrical":
            speech_output = "Your suitable block is third block for  " + favorite_sub + \
                        ". Goodbye."
should_end_session = True    
        else:    
            speech_output = "Your block " + favorite_sub + \
          should_end_session = True
        #speech_output = "Your favorite subject is " + favorite_sub + \
         #               ". Goodbye."
        #should_end_session = True

CODE FOR WIZ750SR

C/C++
Below is the code for WIZ750SR module for connecting it with the internet:-
#include "mbed.h"
#include "EthernetInterface.h"
#include "Adafruit_SSD1306.h"
 
#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x53, 0xAE, 0x90};
#endif
// W7500 onboard LED & Init
DigitalOut rled(LED1,1);
DigitalOut gled(LED2,0);
DigitalOut bled(LED3,1);
 
// I2C Class
I2C i2c(PA_10,PA_9);
 
// OLED Class   
Adafruit_SSD1306_I2c gOled(i2c,NC,0x78,64,128);
 
Serial pc(USBTX, USBRX);
Serial device(D1,D0);
EthernetInterface eth;
 
// Declare TCP Connection Class
TCPSocketConnection sock;
 
DigitalOut myled(D1);
 
 
 
int main() {
   
pc.baud(115200);
    int received_data=0;
    printf("Wait a second...\r\n");
 
   eth.init(mac_addr);     //Use DHCP
eth.connect();
    
      printf("IP Address is %s\r\n\r\n", eth.getIPAddress());
        printf("MASK Address is %s\r\n\r\n", eth.getNetworkMask());
        printf("GATEWAY Address is %s\r\n\r\n", eth.getGateway());
        printf("MAC Address is %s\r\n\r\n", eth.getMACAddress());
    
         while(1){
             
        while(pc.readable()) 
        {
            device.putc(pc.getc());
        }
        while(device.readable())
        {
            if(device.readable()) 
            {
                received_data = device.getc();
                printf("received_data = %d", received_data);
            }
        }
        // TCP socket connect to openweather server 
        //TCPSocketConnection sock;
        char send_data[1024];
        received_data = device.getc();
        pc.printf("received_data = %d\n", received_data);
        char *p="api.thingspeak.com";
           int a=sock.connect(p,80);
          while(1){
                if(a!=0) {
                    printf("\r\n could not connect to socket : error = %d\r\n", p);
                    
                    a = sock.connect(p, 80);
                } else {
                    printf("socket connected\r\n");
                                break;
                }
             } 
        //sock.connect("api.thingspeak.com", 80);
        sprintf((char *)send_data,"GET /update?api_key=GR1IFBYTK5NKNIV6&field2=%d HTTP 1.0\n\n",received_data); 
           
        sock.send_all(send_data, sizeof(send_data));
        char buffer[2048];
        int ret;
        while (true) {
            ret = sock.receive_all(buffer, sizeof(buffer));
            if (ret <= 0)
                break;
            buffer[ret] = '\0';
            printf("Received %d chars from server: %s\n", ret, buffer);     
        }
        printf("\r\n\r\n");
    }
 
}

Obstacle Detection through OpenCV

Python
Implementation of Optical flow
import cv2
import numpy as np
from skimage.measure import compare_ssim
import argparse
import imutils

cap = cv2.VideoCapture(1)
ret, frame1 = cap.read()
prvs = cv2.cvtColor(frame1,cv2.COLOR_BGR2GRAY)
hsv = np.zeros_like(frame1)
hsv[..., 1] = 255
height,width = frame1.shape[:2]
count=0
while(1):
    ret, frame2 = cap.read()

    next = cv2.cvtColor(frame2,cv2.COLOR_BGR2GRAY)
    flow = cv2.calcOpticalFlowFarneback(prvs,next, None, 0.5, 3, 15, 3, 5, 1.2, 0)
    mag, ang = cv2.cartToPolar(flow[...,0], flow[...,1])
    hsv[...,0] = ang*180/np.pi/2
    hsv[...,2] = cv2.normalize(mag,None,0,255,cv2.NORM_MINMAX)
    bgr = cv2.cvtColor(hsv,cv2.COLOR_HSV2BGR)
    
    start_row, start_col = int(0), int(0)
    end_row, end_col1 = int(height), int(width / 3)
    end_row, end_col2 = int(height), int(width * 2 / 3)
    end_col = width

    cropped_left = bgr[start_row:end_row, start_col:end_col1]
    cropped_middle = bgr[start_row:end_row, end_col1:end_col2]
    cropped_right = bgr[start_row:end_row, end_col2:end_col]
    #print(a[...,2])

    cv2.imshow("Cropped left", cropped_left)
    cv2.imshow("Cropped middle", cropped_middle)
    cv2.imshow("Cropped right", cropped_right)

    a = cv2.cvtColor(cropped_left, cv2.COLOR_BGR2HSV)
    b = cv2.cvtColor(cropped_middle, cv2.COLOR_BGR2HSV)
    c = cv2.cvtColor(cropped_right, cv2.COLOR_BGR2HSV)
    if np.all(a[...,2]<80):
        count+=1
        if count>3:
            print("left empty")
            count=0
    elif np.all(b[..., 2] < 80):
        count += 1
        if count > 3:
            print("middle empty")
            count = 0
    elif np.all(c[..., 2] < 80):
        count += 1
        if count > 3:
            print("right empty")
            count = 0

     else:
        print("no free space")
    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
    prvs = next
cap.release()
cv2.destroyAllWindows()

Credits

Geet ji

Geet ji

2 projects • 4 followers
Deepak Agarwal

Deepak Agarwal

0 projects • 2 followers
Tsering Losel

Tsering Losel

0 projects • 5 followers

Comments