Friday, November 6, 2015

Sending an email using CLI and Python on Onion Omega

I received my Onion Omega which I backed on Kickstarter in  April, today and being a weekend wanted to start off with something simple. I've programmed in python before and while browsing the FAQ and eventually the OpenWRT pages about installing python I saw the python-email library. So I decided to write a python script to send an email from the Onion Omega to my Gmail address. The idea being that once I connect some hardware like a switch or my home door bell to the Onion, it can email me if there is a new activity.
The first thing I searched for was how to send email using the CLI. I found this useful link (http://wiki.openwrt.org/doc/howto/smtp.client) and decided to use mailsend to try and send an email. Here are the steps that I followed:
Step 1: Install mailsend
opkg –install mailsend
Step 2: Use mailsend to send an email to my account. I had to experiment with different options but eventually the following worked
mailsend -to recipient@gmail.com -from youruserid@yourhost.com -ssl -port 465 -auth-login -smtp host236.hostmonster.com -sub test +cc +bc -v -useryouruserid@yourhost.com -pass “yourpassword” -M "Your message here"
Somehow I’m unable to send an email from my Gmail account so I used another host that my company uses.
Sending emails via Python Script
Step 1: Install Python (http://wiki.openwrt.org/doc/software/python)
Install python on Onion. I tried installing python-email only but the library had dependencies to many other libraries and after fixing those dependencies, I still had more dependencies. So I decided to install complete python instead of python-light
opkg -update
opkg –install python
Step 2: Write the script to send an email
#!/usr/bin/python
import smtplib
sender = ' youruserid@yourhost.com '
toaddrs = “recipient@gmail.com '
message = """From: Onion Omega Onion@onionomega.com
To: Recipient < recipient@gmail.com >
Subject: SMTP e-mail test
This is a test e-mail message.
"""
#Credentials
password = 'yourpasswordhere'
#The actual mail send
server = smtplib.SMTP_SSL('Your SMTP server address here :465') #(‘Host:Port’)
server.login(sender,password)
server.sendmail(sender, toaddrs, message)
server.quit()
print "done"
Success!
gmail.JPG
Links:
http://www.tutorialspoint.com/python/python_sending_email.htm
Another example to send email using SSL via python
http://stackoverflow.com/questions/24672079/send-email-using-smtp-ssl-port-465

UPDATE: The tutorial is now part of the official Onion Tutorials list! You can find it on https://wiki.onion.io/Tutorials/Sending-Emails-With-Python 

Sunday, February 22, 2015

The story of LearnOBots {So far}

So once again I have been very slow in putting my thoughts here. This time I have a good reason. I have been busy and this busy-ness has yielded some interesting results. In my lab I started off developing 3d printed robots for teaching and learning. Starting last summer I partnered with a friend and launched an experiment. Could we scale up our idea and use it to teach about STEAM (Science, Technology, Engineering, Arts and Mathematics) to school going kids? Would parents be interested and more importantly would kids be interested in learning about robotics. We started off with a workshop at Minerva which is an event's place in Islamabad. We had a great response and attracted people of all ages. Our youngest participant was 6 years old and the oldest was 26! Everyone had absolute fun including us, as this was our first experience. So began our journey with LearnOBots. Following are a few snapshots from our first and second workshops. More pictures are available on our facebook page.


 

After the first workshop we knew that the idea had traction and could be scaled up. With very little money to bootstrap we went about planning our next workshop. This time we changed places and still attracted some participants. We managed to save on a few expenses as well. We also managed to create our first product the LearnOBots 3d printed mobile robot kit.


Our second workshop included more girls and some more challenging activities. Here are a few pictures from the second workshop.



As you can see from the pictures the workshop also attracted girls along with boys. This helped us in understanding the market need which clearly showed that such activities are not only required for boys but are equally relevant for girls. So we went about designing workshops for girls as well.

After launching our workshops and our product in the form of the 3d printed mobile robot kit, we partnered with NUST-SEECS, which is one of the top computer science schools of Pakistan. The partnering meant we could be based at their wonderful campus and we could show the kids exactly how it is like to be at an engineering university which attracts the top talent of Pakistan. With this partnership we designed and executed our 3rd workshop which included many new activities. These included robotics using Lego Mindstorm Kits, electronics using Snap Circuits, and another new product that we developed for this workshop called the Solar House. The Solar House is a very interesting product that teaches kids about arts, crafts as well as electronics. We also introduced 3d modeling and printing in the 3rd edition of our workshop. This turned out to be a lot of fun for everyone as not only did the kids learn to model in 3d they also got to print their own makings and take them home with them. Following are some pictures from the third workshop.






We are well and truly on are way to inspire the kids of Pakistan towards STEAM. In recent months we have received a bit of web media attention as well. A few good blogs have written about our initiative, here are some very interesting articles about LearnOBots. 


The best one that we (myself and my co-founder) like is someone in the US writing about LearnOBots in his personal blog. 

"Could you imagine seeing an article like this even 5 years ago? 3D technology... robots programmed by kids....... in Pakistan!?!?!?

My daughter recently started her first economics project in her 4th grade class. What technology is being utilized by the teacher to teach such an important and complex subject? Play-doh. Kids the same age in a "3rd world" country of Pakistan are programming robots while my child makes a dog and a dollar sign out of play-doh. Something is not right here! "

For the full blog post have a look at 
The LearnOBots journey has just started and let's hope it is a long and successful one. I'll keep posting updates about my startup. Hopefully!
For updates about learnOBots you can follow it on