Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Apr 12, 2018

Raspberry Pi: Headless Setup Notes - For beginner & pre-configuration

How to

2 solutions:

  1. Create an empty file "ssh" or "ssh.txt" (case sensitive, must lower case) in the root folder of SD card created for OS installation.
  2. Plug HDMI to your raspberry pi to a monitor and follow steps below

HDMI + Monitor solution

1. SSH is disabled by default (default setting of a rpi)
2. USB or through HDMI use your rpi
3. enable SSH in your raspi-config or through terminal
4. follow steps below to enable remote SSH in your rpi

Select 7 for advanced options


Select SSH
Select Yes to enable remote SSH for Headless environment

Mar 14, 2018

Raspberry Pi: Send Email as your personal Notifier!

Configurations

you need smtp installed, to get it, you need (smtp and mail):
  
    sudo apt-get install smtp mail
  

Setup email server configuration (edit smtp config):
  
    /etc/ssmtp/smtp.config
  

into format as below:
  
    root=your@email.com
    mailhub=mail_service_provider #for example "smtp.gmail.com:465"
    FromLineOverride=YES
    rewriteDomain=gmail.com
    AuthUser=your@email.com
    AuthPass=yourpassword
    #UseSTARTTLS=YES
    UseTLS=YES
  

Sending Email in Plaintext

  
    echo "the content of the email body" | mail -s "This is the subject" your@email.com
  

Troubleshooting

Just in case you run into Gmail authorization problems:
1. mail: cannot send message: Process exited with a non-zero status
Probably your smtp.config has it configured incorrectly

2. ssmtp: Cannot open smtp.gmail.com:465
Check if your port number is entered correctly

3. ssmtp: Authorization failed (for Gmail, if you have 2FA activated)
You might have to follow this 2FA Gmail Solution to add an app-specified password for that particular app.

Send Email with attachment (Coming soon...)

Content coming soon... (be patient)

Sep 7, 2017

Access raspberry remotely without password

Solution is simple, just 3 steps are required:

On your local machine (which you will access your remote server from)
1. Run:
ssh-keygen (and the following configurations are guided)
2. Configure your config file (~/.ssh/config) with your created public key directory location, for example:
 
Host 192.168.0.2 # your rpi ip address
HostName 192.168.0.2 # your rpi ip address
User pi
IdentityFile ~/.ssh/yourkey
 
3. After done creating public key, copy your public key file content
Example content of public key file
You can copy your public key content with:
cat ~/.ssh/yourkey.pub | pbcopy (for mac OS)

On raspberry pi (remote server)
3. Paste the copied content from step 2 into ~/.ssh/authorized_keys (it is the directory by default) or append to the file if existing content available.

Learning source: How to set up ssh so you aren't asked for a password

Feb 7, 2017

Raspberry Pi - The problem about "cannot change locale"

After having problem at configuring Internationalisation to en_US.UTF-8 with raspi-config,
error messages below keep popping up every time I login to my raspberry pi.

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
and

pi@raspberrypi:~ $ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = "en_US.UTF-8",
 LC_CTYPE = "UTF-8",
 LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory


And there are bunch of locale warning during my apt-get install which is really annoying even though I am not sure how it does affect my apt-get installation even when the installation is successful.

Raspi-config internationalisation options screen
Every retry of locale change end up here in the error message below, you stuck here forever and that's it!
Change Locale Error
I've tried looking for solution, and I am lucky enough end up in the links at the bottom of this article.
The solution is simple:

  1. sudo nano /etc/locale.gen
  2. uncomment your preferred locale, for example en_US.UTF-8
  3. sudo locale-gen en_US.UTF-8
  4. sudo update-locale en_US.UTF-8

Even though it help getting rid of the annoying 'cannot change locale' or '' error message in your terminal,
it doesn't fix the "There was an error running option I1 Change Locale" issue.
As I tried reconfigure Locale changes, raspi-config will still return me to the same error as in Change Local Error screenshot above.

So until now, I'm still looking for the root cause of this problem.

TL; DR
Solution on StackOverflow - Unable to reconfigure locale in raspberry pi
Original solution source was blog years ago Raspberry Pi -- Fixing your Locale

Dec 30, 2016

Simplified way to get Shairport-sync works in your raspberry pi

The tutorial here is quite straight forward.
Sometimes you do need "fast-track" to get something done right away.

For deep diving purpose, please head to https://github.com/mikebrady/shairport-sync for full (useful) explanation about the setup.

The steps below was tested and might only work for:
- New installation (with no shairport-sync installed before)
- Raspbian (version 8, Jessie) check with cat /etc/os-release
- no external sound card attached (my case)
- tested on streaming through iTune from Macbook (macOS Sierra, 10.12.1)

I'm too will look for the simplest (easiest) approach first, so don't guilt about it, let's get start.
  1. As usual, update your rpi first
    1. sudo apt-get update & sudo apt-get upgrade
    2. sudo rpi-upgrade
  2. Install dependencies,
    1. sudo apt-get install build-essential git autoconf automake libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev libpolarssl-dev libssl-dev avahi-daemon libavahi-client-dev
  3. Download/clone shairport-sync and configurations
    1. git clone https://github.com/mikebrady/shairport-sync.git
    2. cd shairport-sync
    3. autoreconf -i -f
    4. sudo ./configure --sysconfdir=/etc --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-systemd
    5. sudo make
    6. sudo getent group shairport-sync &>/dev/null || sudo groupadd -r shairport-sync >/dev/null
    7. sudo getent passwd shairport-sync &> /dev/null || sudo useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null
    8. sudo make install
    9. sudo systemctl enable shairport-sync
    10. sudo update-rc.d shairport-sync defaults 90 10
I've got the shairport-sync working well in my Debian build raspberry pi
And hope to add more explanation about the steps above once I manage to spend more time playing shartport-sync in the rpi.

You should visit the references below:
A guide from setting up WiFi to shairport-sync - Multiroom audio Rpi (2015)
Use of shairport (earlier version of shairport-sync) and mentioned alsamixer - hifi audio via airplay on Rpi (2013)

Mar 23, 2014

raspberry pi for dummy: WPA_SUPPLICANT: /SBIN/WPA_SUPPLICANT DAEMON FAILED TO START

Monday, 27 March 2017 UPDATE:
- please refer to this official Raspberry Pi Wifi configuration documentation

After you have the USB Wifi dongle plugged into your RPI, you can scan wifi sign near you with
sudo iwlist wlan0 scan 
command (if this work, that mean you are close to setup wifi successfully)

Finally, if you haven't added any network config in your wpa_supplicant.conf (/etc/wpa_supplicant/wpa_supplicant.conf) insert wifi detail using:
wpa_passphrase "your wifi SSID" "your wifi password" >> /etc/wpa_supplicant/wpa_supplicant.conf

Note: please refer official link attached above for detailed explanation.


If you face problems stated below:
- WPA_SUPPLICANT: /SBIN/WPA_SUPPLICANT DAEMON FAILED TO START


You may first look at this Setting up Wifi (EDIMAX) on Raspberry Pi,
if you're still fail to configure a successful connection to your access point (AP or wifi router),
please remove the quote symbol to your psk value like this in your wpa_supplicant.conf:
network={
    ssid="Your SSID Here"
    key_mgmt=WPA-PSK
    psk=YourPresharedKeyHereWithoutQuote
}
get your PSK value from WireShark WPA-PSK Generator.

Once done:
apply commands and restart network or your RPI (sudo reboot):
sudo service networking restart
sudo ifup wlan0 (or sudo ifdown wlan0 then sudo ifup wlan0)

I wrote this because I saw too many tutorial out there didn't mention/emphasize about removing the quote symbol for psk value.
examples
Circled quotes symbols should not be around your psk value

wireless setup command reference: Useful Linux Wireless Commands