Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Installation
- ============
- Cek microSD card
- $ lsblk
- Unmount
- $ umount /dev/sdb1
- Install
- $ unzip -p 2018-04-18-raspbian-stretch.zip | dd bs=4M of=/dev/sdX status=progress conv=fsync
- $ sync
- Now go to the SD card /boot
- $ cd /media/gungsukma/boot
- $ touch ssh
- $ nano wpa_supplicant.conf
- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
- network={
- ssid="YOUR_NETWORK_NAME"
- psk="YOUR_PASSWORD"
- key_mgmt=WPA-PSK
- }
- Okay. Installation finished.
- Setup
- - Ubah password, aktifkan WiFi
- - Aktifkan kamera, SSH, serial, remote GPIO
- - Pilih timezone, keyboard layout
- $ sudo raspi-config
- $ sudo apt-get update
- $ sudo apt-get upgrade
- GPIO
- ====
- old/new
- #1 3V3 #2 5V
- #3 0/2(SDA0/1) #4 5V
- #5 1/3(SCL0/1) #6 Gnd
- #7 4 #8 14(TX)
- #9 Gnd #10 15(RX)
- #11 17 #12 18
- #13 21/27 #14 Gnd
- #15 22 #16 23
- #17 3V3 #18 24
- #19 10(MOSI) #20 Gnd
- #21 9(MISO) #22 25
- #23 11(SCLK) #24 8
- #25 Gnd #26 7
- $ sudo python
- > import RPi.GPIO as GPIO
- > GPIO.RPI_INFO
- > GPIO.RPI_INFO['P1_REVISION']
- > GPIO.VERSION
- > GPIO.setwarnings(False)
- > GPIO.setmode(GPIO.BCM)
- > GPIO.setup(23, GPIO.IN)
- > GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- > GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- > if GPIO.input(23) == 1:
- > pass
- > GPIO.wait_for_edge(23, GPIO.RISING)
- > GPIO.wait_for_edge(23, GPIO.FALLING)
- > GPIO.setup(23, GPIO.OUT, initial=GPIO.HIGH)
- > GPIO.output(23, GPIO.LOW)
- > GPIO.cleanup()
- Kamera
- ======
- Hidupkan kameranya
- $ sudo raspi-config
- Tiga ribu milidetik menuju cheese
- $ raspistill -t 3000 -o test.jpg
- JPEG quality 10% ukuran VGA
- $ raspistill -w 640 -h 480 -n -t 100 -q 10 -e jpg -th none -o vga_100ms_jpg10.jpg
- Biar punya /dev/video0
- $ sudo modprobe bcm2835-v4l2
- $ sudo nano /etc/modules
- tambahkan baris bcm2835-v4l2
- RPI-Clone
- =========
- $ wget https://github.com/billw2/rpi-clone/archive/master.zip
- $ unzip master.zip
- $ cd rpi-clone
- $ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
- $ sudo rpi-clone sdb
- $ sudo rpi-clone sdb -s new_hostname
- Save SD Card Life
- =================
- $ sudo nano /etc/fstab
- Tambahkan ini
- none /var/log tmpfs size=1M,noatime 0 0
- tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=30m 0 0
- $ sudo dphys-swapfile swapoff
- $ sudo dphys-swapfile uninstall
- $ sudo update-rc.d dphys-swapfile remove
- Python Get CPU Temperature
- ==========================
- def getCPUtemperature():
- res = os.popen("vcgencmd measure_temp").readline()
- temp =(res.replace("temp=","").replace("'C\n",""))
- return int(float(temp))
- Python Get Raspi Serial Number
- ==============================
- http://www.raspberrypi-spy.co.uk/2012/09/getting-your-raspberry-pi-serial-number-using-python/
- def getserial():
- # Extract serial from cpuinfo file
- cpuserial = "0000000000000000"
- try:
- f = open('/proc/cpuinfo','r')
- for line in f:
- if line[0:6]=='Serial':
- cpuserial = line[10:26]
- f.close()
- except:
- cpuserial = "ERROR000000000"
- return cpuserial
- HCSR04
- ======
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO_TRIGGER = 18
- GPIO_ECHO = 24
- GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
- GPIO.setup(GPIO_ECHO, GPIO.IN)
- def distance(): # centimeter
- GPIO.output(GPIO_TRIGGER, True)
- time.sleep(0.00001)
- GPIO.output(GPIO_TRIGGER, False)
- while GPIO.input(GPIO_ECHO) == 0:
- pass
- StartTime = time.time()
- while GPIO.input(GPIO_ECHO) == 1:
- pass
- StopTime = time.time()
- distance = 34300 * (StopTime - StartTime) / 2
- return distance
- WS2812B
- =======
- $ sudo apt-get install python-pip
- $ sudo pip install rpi_ws281x
- $ nano ws2812b.py
- import time
- from rpi_ws281x import x
- LED_COUNT = 12
- #GPIO18 (Pin#12)
- strip = Adafruit_NeoPixel(LED_COUNT, 18, 800000, 10, False, 255, 0)
- strip.begin()
- for i in range(strip.numPixels()):
- strip.setPixelColor(i, Color(255,255,255))
- strip.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement