viernes, 28 de abril de 2017

Raspberry pi zero W

Enable headless operation

  1. Download raspbian and write to micro-SD card
  2. Mount on PC and, on the boot partition:
  3. Create an (empty) file called ssh (this enable SSH on startup)
  4. Create a wpa_supplicant.conf file with the following content
network={
    ssid="YOUR_WIFI_SSID"
    psk="YOUR_WIFI_PASSWORD"
    key_mgmt=WPA-PSK
}
 

On Off button

Poweroff


To poweroff, follow these instructions:

Essentially:
Connect button between GPIO18 and GND
Write this python script


    1. #!/bin/python  
    2. # Simple script for shutting down the raspberry Pi at the press of a button.  
    3. # by Inderpreet Singh  
    4.   
    5. import RPi.GPIO as GPIO  
    6. import time  
    7. import os  
    8.  
    9. # Use the Broadcom SOC Pin numbers  
    10. # Setup the Pin with Internal pullups enabled and PIN in reading mode.  
    11. GPIO.setmode(GPIO.BCM)  
    12. GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)  
    13.  
    14. # Our function on what to do when the button is pressed  
    15. def Shutdown(channel):  
    16.     os.system("sudo shutdown -h now")  
    17.  
    18. # Add our function to execute when the button pressed event happens  
    19. GPIO.add_event_detect(18, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)  
    20.  
    21. # Now wait!  
    22. while 1:  
    23.     time.sleep(1)  



We need our python script to run automatically every time the RPi starts. For this we need to do a little manual editing of the RPI generated files. Run the following command
  1. sudo nano /etc/rc.local 
This file is what gets executed everytime your RPi boots up. We need to add our python command before the last line which closes the if loop. Therefore, add the following line before the #fi at the end of the file.
  1. sudo python /home/pi/Scripts/shutdown_pi.py & 
Please note that everything is case sensitive so Scripts is not the same as scripts. The & at the end of the command tells it to run the process in the background. If you omit it, then your login prompt probably will not appear.

Poweron


To poweron, place a button across the RUN header of the RPI zero. This is actually a reset button but when halted can bring the Pi on again.


Power Consumption


During boot, I have seen peaks of 240 mA.
After shutdown, power consumption is 30 mA.




 

No hay comentarios:

Publicar un comentario