Before first boot

In order to get up and running with your Raspberry Pi, you will first need to flash an SD card

Download Raspian

The first step is to download Raspbian (debian distro..). You can get it from here

Writing SD card

There are several ways to flash an IMG file on an SD-card.
You can read an excellent resource on this topic elinux.org article. Once you’re done with it, we can move to the next step.
I used ApplePi-Baker to flash my SD-card with only a few simple clicks.

Wifi Setup

Mac users: you can’t access EXT4 partitions without 3rd party software.

##FOR IP FROM DHCP
## FILE: /etc/network/interfaces  looks like this

auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

##FOR IP STATIC
## FILE: /etc/network/interfaces  looks like this
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
address 192.168.0.6
netmask 255.255.255.0
gateway 192.168.0.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Wifi Setup credential

ctrl_interface=DIR=/var/run/wpa_supplicant
  GROUP=netdev
  update_config=1
  network={
      ssid="[YOUR SSID]"
      psk="[YOUR PASSWORD]"
      proto=RSN
      key_mgmt=WPA-PSK
      pairwise=CCMP
      group=CCMP
      auth_alg=OPEN
  }

** more configuration examples here

After first boot

Now, put the SD card into the RPi, plug the wifi in and power it up.

Find Raspberry Ip

**from mac download namp and lauch scan to find ip:

#if your IP address is 192.168.1.XXX.
sudo nmap -sP 192.168.1.0/24

Test ssh access

#default user e pass pi and raspberry
ssh pi@[RaspIP]   

After SSH connection

Raspi-config

sudo raspi-config
#expand filesystem
#change user password
#set timezone 

alt

Update

sudo apt-get update && sudo apt-get upgrade

Auto-reboot

The Broadcom BCM2835 SoC on the Raspberry Pi comes with a hardware-based watchdog timer. Its purpose is to automatically reboot the system if it becomes unresponsive. (The watchdog timer is basically a countdown timer that counts from some initial value down to zero.The running software must periodically update the watchdog timer with a new value to stop it from reaching zero and causing a reboot)

#load kernel modules
sudo modprobe bcm2708_wdog

#load the kernel modules on system boots
echo "bcm2708_wdog" | sudo tee -a /etc/modules

# download watchdog daemon
sudo apt-get install watchdog

#config daemon watchdog
sudo nano /etc/watchdog.conf
#############
#uncomment the following:
#max-load-1=24    //reboot if timer over 24 in 60s
#watchdog-device  //enable

# add watchdog daemon to startup applications:
sudo update-rc.d watchdog defaults

#Start watchdog
sudo service watchdog start

Improve stability WiFi

I am using an Edimax EW-7811un WiFi dongle.To improve the stability of your WiFi, it is recommended to disable power management Alternatively, ping your router every minute to keep the connection alive.

sudo crontab -e

#ping every minute google dns 
##add this line:
* * * * * ping -c 1 8.8.8.8

Auto Restart Wifi

sudo nano /usr/local/bin/alivewifi.sh
sudo chmod 775 /usr/local/bin/alivewifi.sh

sudo crontab -e
#ADD THIS LINE
*/5 * * * * /usr/local/bin/alivewifi.sh >> /dev/null 2>&1

################################
#FILE /usr/local/bin/alivewifi.sh
################################

  #!/bin/bash
  NOW=$(date +"%Y-%m-%d %H:%M:%S")
  ping -c4 8.8.8.8 > /dev/null
  if [ $? != 0 ] 
  then
    echo "[$NOW] network down restarting wlan0"
    /sbin/ifdown 'wlan0'
    sleep 5
    /sbin/ifup --force 'wlan0'
  fi

And now??? read the "from boot to nodejs" to write the first web application with local database..

© 2018. All Rights Reserved.

Ghostium Theme by @oswaldoacauan

published with Ghost

Privacy Policy