Showing posts with label Spark. Show all posts
Showing posts with label Spark. Show all posts

Thursday, July 14, 2016

Raspberry Pi Cam + Cisco Spark - Motion Detection Demo

In the previous post, I've setup a Raspberry Pi Surveillance camera with Live streaming capability, and it can also save a video file when motion is detected.

http://pandaeatsbamboo.blogspot.com/2016/07/live-streaming-video-from-raspberry-pi.html

Spark integration is done too so that when motion is detected, a Spark message is posted with video files.  This is how it works:



Sunday, July 10, 2016

Using Web and Cisco Spark to control a Lego EV3 Robot


I have bought the Lego Mindstorms EV3 robot for more than 2 years, however I didn't spend any time on it until recently.  My daughter was sick and she has to stay at home, to keep her busy I built the EV3 together with her and we had run some pre-set missions to make the robot move and did some simple tasks.  It works great, except that I have to use the Mindstorm software to program it.


There is also another iPhone app to give you basic control of your robot, however it only accepts bluetooth connection, which makes me a lot less flexible compare with Wifi.




I have done some googling and find this post:
http://programmablebrick.blogspot.hk/2014/11/seanbot-ev3-robot-controlled-via-web.html

It looks interesting to me and I would want to make it my first EV3 project.  This is what I've done:

1. Get an microSD card.  So happen I've found one old 2GB card at home and I've used that for this project.  Flash it with the ev3dev OS following the instruction in this page, it is based on Debian Linux:
http://www.ev3dev.org/docs/getting-started/

2. Putting the microSD card into my EV3 and power it on.  It will not affect your original firmware in EV3, it is just like dual booting another OS.




3. Setting up the wireless network.  I've bought a wireless USB dongle from a local computer store, and it is less than US$9.  It works like a charm.  I did purposely pick one without 802.11ac, older model, claim to have Linux support.  Just bet on it, provided that it is so cheap.


4. Plug that into the USB port of EV3.  Use the screen on EV3 to choose my home wifi network, and entered the WPA PSK.  It is now connected, and able to access the Internet.


5. SSH to the box.  Use apt-get to get the packages, make sure you did a apt-get upgrade and update before you download the other packages.


sudo apt-get update; sudo apt-get upgrade
sudo apt-get install apache2 libapache2-mod-php5 unzip

6. Download the files in zip in this github project -  https://github.com/dwalton76/LegoEV3D4.  Unzip and copy these contents into your apache document root, in my case it is /var/www/html.  I download it to my Mac and then scp to the EV3, unzip it then copy it to the document root.

7. Install the python-ev3 on EV3 - https://github.com/topikachu/python-ev3.  My version of python is 2.7, therefore these are the commands that I've issued to my EV3.

Python 2.7

apt-get update
apt-get install virtualenv virtualenvwrapper python-setuptools python-smbus python-pil
source /etc/bash_completion.d/virtualenvwrapper
mkvirtualenv ev3_py27 --python=/usr/bin/python2.7 --system-site-packages
workon ev3_py27
easy_install -U python-ev3
type deactive to exit

8. Download the python-ev3 project in zip file - https://github.com/topikachu/python-ev3.  Similar to step 6, copy the content to the EV3.  In python-ev3, there is a ev3 folder.  Make sure this folder is copied to /var/www/html.  You will need to make sure you do this otherwise your LegoR2D2.py will not work.

9. Some python libraries dependencies need to be resolved, and this is what I've done:
easy_install web.py

10.  Start your apache using the command /etc/init.d/apache2 start.  Run the LegoR2D2 python scripts with sudo.  tcp/8080 will be listened after you run the script.


11. Launch your web browser.  I have tried Chrome and Firefox, for some reasons it only works on my Firefox, probably it is something specific to my laptop.  By the way this is what you will see:



12.  Click on the arrows to move your robot!  Is that it?  No!  How about we using a Cisco Spark Chatbot to control the EV3?











Friday, July 8, 2016

Raspberry Pi 3 + Cisco Spark - My home presence check

Just got my Raspberry Pi 3 a few days ago.  I know there are loads of projects that I can do with that, before knowing what I actually want to do, I want to try something quick and simple to keep the box warm.  I've an python scripts based on the post here:

http://www.instructables.com/id/Raspberry-Pi-Bluetooth-InOut-Board-or-Whos-Hom/

I modified it slightly to send a message to a Spark room when the Raspberry Pi detects my iPhone bluetooth mac address:

#!/usr/bin/python

import bluetooth
import time
import pyCiscoSpark

print "Home Attendance"

accesstoken="Bearer "
roomid=""

while True:
        currenttime=time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        print "Checking " + currenttime

        result = bluetooth.lookup_name('ff:ff:ff:ff:ff:ff', timeout=5)
        if (result != None):
                print "Danny: in"
                resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is at home now - " + currenttime)
                #print (resp_dict)
        else:
                print "Danny: out"
                resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is NOT at home now - " + currenttime)

        time.sleep(60)

Replace ff:ff:ff:ff:ff:ff with your phone Bluetooth mac address.  I've also used the pyCiscoSpark.py in Github for posting a message to the Spark room:

https://github.com/brbester/pyCiscoSpark

So this is how it looks like when the script is running:



Spark room:

Monday, July 4, 2016

CE8.2 - Cisco Spark on-boarding

SX10N is the first endpoint that is supported to register to Cisco Spark cloud service.  Starting from CE8.2, all the remaining SX, MX and DX endpoints are supported to register to Cisco Spark cloud.  There are some considerations that you need to take if you want to register the endpoints to the Spark cloud.  According to the release notes:
http://www.cisco.com/c/dam/en/us/td/docs/telepresence/endpoint/software/ce8/release-notes/ce-software-release-notes-ce8.pdf

So it means that SX10 and SX20 are supported only when using TRC6 remote, but not Touch 10.  On SX80 only directing pairing of Touch 10 is supported, but not network pairing.  This is something that people will possibly miss out if not reading the release notes carefully.

Thursday, June 30, 2016

Getting Surveillance Camera Snapshot with Spark Chatbot

Bear with me if it is just too much.  I am developing different use cases with Spark that might be useful for myself.  Yesterday I had posted these two use cases:

Device monitoring:
http://pandaeatsbamboo.blogspot.hk/2016/06/using-spark-to-monitor-device.html

Config backup:
http://pandaeatsbamboo.blogspot.hk/2016/06/using-spark-for-my-routers-and-switches.html

Another use case is I can ask the chatbot to send my home surveillance camera snapshot to me via Spark.  In a lot of time I don't need the live video as it consumes cellular bandwidth.  A snapshot is usually work to get a feeling what my children are doing at home.



Previous use cases:
Network monitoring - http://pandaeatsbamboo.blogspot.com/2016/06/using-spark-to-monitor-device.html
Config backup - http://pandaeatsbamboo.blogspot.com/2016/06/using-spark-for-my-routers-and-switches.html
Energywise demo with bot - http://pandaeatsbamboo.blogspot.com/2016/06/cisco-spark-bot-energywise-demo.html

Wednesday, June 29, 2016

Using Spark to monitor device availability

This is another use case I used Spark in my lab, to check the availability of my lab devices.  When there is outage, the chatbot will alert me proactively so that I can check and troubleshoot the issue earlier rather than later.

Using Spark for my routers and switches config backup

Not the most innovative idea in the world, but it works for me.  In my home and lab there are quite a number of routers and switches.  This is what I've configured on the devices to periodically upload the config to the FTP server

ip ftp source-interface
ip ftp username nms
ip ftp password nms
file prompt quiet
!
kron policy-list backup
 cli copy running-config ftp://10.1.5.98
!
kron occurrence daily-backup at 0:30 recurring
 policy-list backup

There is another script running on my Linux host to post these config files to Spark using the Spark Message API.  Good thing for Spark is it is persistent, and I can store the config files there as long as I want.


I do it for my development source code too, similar concept.


A script will be executed every night using the linux box cron job to get this done.  Or do it manually, by asking my chatbot to do it.

Saturday, June 18, 2016

Cisco Spark Bot + Energywise Demo

I have developed a very basic bot and one of the use case that was developed is the energy control use case.  I can talk to my bot and ask the bot to switch off / on the energy of my Cisco DX650 phones using the energywise command of the Cisco switch.

This bot is based on the Flint project in Github, for more information please check it out here:
https://github.com/nmarus/flint


Friday, June 17, 2016

Phone registration to Spark Call Services

My lab 8861 registers to the Spark Call Services in the cloud.  I am using a Cisco dCloud setup that has recently updated with this Spark Call capability.  The experience will be even better if I have a 8865 / 8845 video phone to recognise the QR code to get the activation code, which I don't have it with me.




Clean and nice user interface!


More info:
http://www.cisco.com/c/en/us/solutions/collateral/unified-communications/hosted-collaboration-solution-hcs/datasheet-c78-736823.html