Tuesday 4 April 2017

A well occupied Weekend (Pyladies and Python-Pune)

Weekend as the word comes to our mind, we are like lot of fun and time to relax. Same I did this weekend, infact lot more than this. As I attended two meetups Pyladies and Python Pune, and it was more fun as they were organised at Reserved Bit, which I personally love to visit.

Saturday(25th March 17) We had our  Pyladies meetup, and for this meet up we had planned to have a discussion among us, so that we can share our experience and discuss about our projects ideas. This meet up was basically organised so that we can get ideas about different projects we can work on. So we all were there by 11 am. When I reached and look around, I realized few known faces were missing from the meetup, later came to know they were having some work in college. But the good part was that we were having lot of new members this time who were working in different organisation. Also we had people who were familiar with embedded( electronics). As this was a discussion session we discussed about Pycon-Pune, which I was not able to attend :(. But most of them attended it and shared their experience. I shared my experience how I stared my journey with Python and so on.. 
Lot of ideas were discussed, also I got to know some of them were interested in automation, so I decided to take a session on it as I am currently working on automation using different framework like Robot Framework, Behave. Anwesha discussed about her project "Bunny Uncle" upon which she worked in Pycon-Pune. So we ended up discussing about the projects which we can work upon in our next meetup.

Sunday(26th March 17) As it was Sunday I want to sleep a little more, but the topic of the meetup made me to wake up that day. Raspberry-Pi as till now I have only heard of it from many people but didn't got a chance to work with it. So this meetup was a platform to start with it. It was also at Reserved Bit. After we all were set Girish and Chandan started with the session. They introduced us to Raspberry-Pi and shared a doc how we can get started with it. So we started with installing raspbian/ubuntu on memory card.
Here are the steps shared by Girish. which we followed:

install raspbian/ubuntu on memory card.
    $ df
    after this you will get the mmcblock file.
then unmount the memorycard partition using umount.
    $ umount /media/<user>/<partition>

format the memorycard with Fat32 filesystem.
    $ sudo mkdosfs -F 32 -v /dev/mmcblk0
now copy the raspbian/ubuntu on memorycard using dd.
    $ sudo dd bs=1M if="osImage.img" of=/dev/mmcblk0

to connect to the wifi network
    $ vim etc/network/interfaces
        auto wlan0
        allow-hotplug wlan0
        iface wlan0 inet manual
            wpa-ssid "reserved-bit"
            wpa-psk "8tn6r23eskasm"
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

to enable ssh
    $ touch /etc/SSHFLAG
    $ vim /etc/rc.local
      if [ -e /etc/SSHFLAG ]; then
          /usr/sbin/update-rc.d -f ssh defaults
          /bin/rm /etc/SSHFLAG
          /sbin/shutdown -r now
      sudo /etc/init.d/ssh start
      exit 0
to start vnc session
    $ sudo apt-get install tightvncserver
    $ vncserver :1 -geometry 1024x768 -depth 24 -dpi 96

      You will require a password to access your desktops.
      Warning: password truncated to the length of 8.
      Would you like to enter a view-only password (y/n)? n

first get update.
    sudo apt-get update

then install python-dev
    sudo apt-get install python-dev

try if RPi.GPIO is there in python packages.
    import RPi.GPIO as gpio

check the version of GPIO

After this we were able to ssh to our pi and were ready to play with it. Upto this it was the time for lunch which was already there from Rajdhani arranged by Python Pune group only.
After this came the electronics part for which Nikhil took over the session. We started with very simple program to glow a led. Then we added a switch to control the led. So it was fun modifying our code and have different pattern in which led was glowing. A simple program for led and button is as below:

from RPi import GPIO as io import time io.setmode(io.BOARD) io.setup(18, io.IN, pull_up_down=io.PUD_DOWN) io.setup(16, io.OUT) def check_button_state(): while True: if io.input(18) == 1: print("pressed") io.output(16, io.LOW) time.sleep(1) io.output(16, io.HIGH) else: pass try: check_button_state() except: print 'except'

A day out with raspberry pi and Python was great Fun!! :) 

No comments:

Post a Comment