Safe Off Switch to Power Down Your Raspberry Pi

Some time it is hard to find solution for raspberry pi.

This time we are solving issue : how to Power Down Your Raspberry Pi using GPIO.

Step1:

copy script from power_hold.py

Step2:

sudo apt install python3-gpiozero

#connect button GPIO 21 and GND

#run below command to test

python3 power_hold.py

# hold button(gpio21 and GND) for 2 second . your pi will be shutdown.

If it is ok then power on your pi3 again

Step3:

Now execute your script ,when raspberry pi power on every time.

sudo nano /etc/rc.local

in rc.local file at the end your code must be look like this

python3 /home/pi/power_hold.py &

exit 0     

Thats it now . restart your pi again and test it….

Adding GPS tracking to your Raspberry Pi-based projects

Hi geeks some time it is hard to manage gps connection to Raspberry PI.

dont worry we need following item needs for connectivity

  1. Raspberry pi 3
  2. USB to TTL adapter (Prolific PL2303)
  3. Neo 6M-0-001 Ublox GPS Module

Step:1

Connect your GPS module to USB to TTL adapter(Tx and Rx cross connection Required dont get confused)

GPS Module USB to TTL adapter
5v 5v
VCC 5v
Rx Tx
Tx Tx

Step:2

connect USB to TTL adaptor to raspberry pi and login to raspberry pi using putty or terminal.

Step:3

Now run following command to detect usb to ttl

ls /dev/ttyUSB*
sudo lsusb

I am assuming that USB to TTL connected on /dev/ttyUSB0. so run following command to get data from GPS.

sudo cat /dev/ttyUSB0

you will get data like above screenshot.Ctrl+C to stop output.

Optional Steps

Step 3

Installing a GPS Daemon (gpsd)
sudo apt-get install gpsd gpsd-clients python-gps

The next step is installing some software on your Raspberry Pi that understands the serial data that your GPS module is providing via /dev/ttyUSB0.

then run

//this command with tell actual gps data
gpsmon /dev/ttyUSB0

sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

above will run gps data service in background

now see the data

cgps -s

 

article source 

 

How to create QR code in Python

What is a QR Code in nutshell?

A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric)

its very simple on console (tested on mac, debian and ubuntu latest OS)

below command will install all required module including pil (Python Imaging Library):pillow

pip install qrcode[pil]

then

Usage form command line

qr "Some text" > image_name_with_extention
qr "makerspacekanpur.com" > msk.png

or

Sample example to generate QR code and save in png file in python.

import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('http://makerspacekanpur.com')

qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")

img.save('msk-site.png') 

Sample example to instant preview of QR code in python.

import qrcode
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('Some data')
qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")

img.show()

 

source : Python.org

join our python training in kanpur for Zero to Hero in Python.

How to Connect LCD to Raspberry PI

This code will tested on this product of iotwebplanet.

sudo rm -rf LCD-show
git clone https://github.com/vivekaris/LCD-show.git
chmod -R 755 LCD-show
cd LCD-show/

Then Run Following command as per you screen size.

In case of 2.8″ LCD
sudo ./LCD28-show

In case of 3.2″ LCD
sudo ./LCD32-show

In case of 3.5″ GPIO Display
sudo ./LCD35-show

In case of 3.5″ HDMI Display-MPI3508
sudo ./MPI3508_480_320-show
or
sudo ./MPI3508_600_400-show
or
sudo ./MPI3508_720_480-show
or
sudo ./MPI3508_810_540-show
or
sudo ./MPI3508_960_640-show

In case of 3.5″ DPI Display-MPI3510
sudo ./MPI3510-show

In case of 3.97″ LCD
sudo ./LCD397-show

In case of 4.3″ LCD
sudo ./LCD43-show

In case of 5″ LCD
sudo ./LCD5-show

In case of 7inch(B)-800X480 RPI LCD
sudo ./LCD7B-show

In case of 7inch(C)-1024X600 RPI LCD
sudo ./LCD7C-show

If you need to switch back to the traditional HDMI display
sudo ./LCD-hdmi

Wait a few minutes,the system will restart automaticall , enjoy with your LCD.

 

Flutter and its Setup

What is Flutter

Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.


Join MakerSpace Kanpur

Who is it for?

Programmers
Students and Teachers
Beginners

System requirements for (Mac)

  • Operating Systems: macOS (64-bit)
  • Disk Space: 700 MB (does not include disk space for Xcode or Android Studio).
  • Tools: Flutter depends on these command-line tools being available in your environment.
    • bashmkdirrmgitcurlunzipwhich
  • Clone the repo

    If this is the first time you’re installing Flutter on this machine, clone the beta branch of the repository and then add the flutter tool to your path:

  • git clone -b beta https://github.com/flutter/flutter.git
    $ export PATH=`pwd`/flutter/bin:$PATH
  •  flutter doctor
  • export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH