Raspberry Pi

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
m (Added putty details for windows users)
(Added Stretch info)
 
(32 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[File:Pi2B1.jpeg|right]]This is a full walk-through example install on a headless Raspberry Pi.
+
[[File:Pi2B1.jpeg|right]]
 +
= Installation with readymade images =
 +
== Raspberry Pi 1 / RPiB+ (ARMv6) ==
  
= Installation =
+
Jessie image created from raspbian-ua-netinst v1.0.7, based on the guide below to get Agocontrol installed and working, then updated Wheezy to Jessie. Details how to to the update, see [http://www.circuidipity.com/minimal-raspbian-jessie.html]
 +
user: pi password: raspbian (Note root account also enabled: root/raspbian) Locale to en_DK and city to Copenhagen, change for your need. You must minimum use an 8GB SD card.
 +
 
 +
Link to RPI B+ AMRv6 image: [http://git.agocontrol.com/bjacobse/rpi-rasbian-jessie-image/blob/master/raspbian_jessie_agocontrol_ver01.img.xz] (Older: [http://git.agocontrol.com/bjacobse/rpi-rasbian-jessie-image/tree/master])<br/>
 +
Verify the download with:
 +
md5sum raspbian_jessie_agocontrol_ver01.img.xz
 +
396e7df1ca9cda1220edd86e6645f477  raspbian_jessie_agocontrol_ver01.img.xz
 +
 
 +
This will copy your image to your 8GB SD card. the "--keep" ensure your original image isn't deleted after decompressing
 +
sudo xzcat --keep raspbian_jessie_agocontrol.img.xz |  sudo dd of=/dev/sdb
 +
sync
 +
You might have another /dev/sdb, check in a console "demsg |grep sd"
 +
 
 +
== Raspberry Pi 2 / RPiB2 (ARMv7) ==
 +
 
 +
Download Debian Jessie image at: [http://mirror.at.agocontrol.com/wandboard/wandboard-jessie.img.bz2]
 +
 
 +
The apt sources list is already configured. So no need to mess with it. But if you change it, make sure to use our regular repository, not the raspbian one.
 +
 
 +
User: root<br/>
 +
Password: agocontrol
 +
 
 +
The image recognized my NIC on the 1st boot, but assigned it to eth1.  I did not have internet until editing the udev by commenting out the NIC ending c3:12 and changing my NIC from eth1 to eth0.
 +
nano /etc/udev/rules.d/70-persistent-net.rules
 +
 
 +
= Installation from scratch =
 +
This is a full walk-through example install on a headless Raspberry Pi.<br/>
 
== OS (headless) ==
 
== OS (headless) ==
Download Raspian from [http://downloads.raspberrypi.org/raspbian_latest]<br/>
+
 
 +
=== Jessie ===
 +
 
 +
N.B. The latest versions of Jessie seems to have SSH disabled; so the first steps needs to be performed with a keyboard and monitor attached.
 +
 
 +
I recommend using Raspian Jessie lite (minimised image, no GUI etc.) [https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2015-11-24/2015-11-21-raspbian-jessie-lite.zip]
 +
Full version [http://downloads.raspberrypi.org/raspbian_latest]<br/>  
 +
 
 +
=== Get files onto SD card ===
 
Get the image to an SD card, e.g. using one of these tutorials: [http://www.raspberrypi.org/documentation/installation/installing-images/windows.md Windows], [http://n00blab.com/how-to-create-raspberry-pi-sd-card/ Linux], [http://www.raspberrypi.org/documentation/installation/installing-images/mac.md Mac]<br/>
 
Get the image to an SD card, e.g. using one of these tutorials: [http://www.raspberrypi.org/documentation/installation/installing-images/windows.md Windows], [http://n00blab.com/how-to-create-raspberry-pi-sd-card/ Linux], [http://www.raspberrypi.org/documentation/installation/installing-images/mac.md Mac]<br/>
 +
 +
 +
=== Jessie ===
 
Insert the SD card, connect an ethernet cable and power up the RPi.<br/>
 
Insert the SD card, connect an ethernet cable and power up the RPi.<br/>
 
Find the IP adress it has received, e.g. look at the DHCP table in your router<br/>
 
Find the IP adress it has received, e.g. look at the DHCP table in your router<br/>
Open a term window (on windows use [http://www.putty.org Putty] and ssh into the RPi
+
Open a term window (on windows use [http://www.putty.org Putty]) and ssh into the RPi
 
  ssh pi@192.168.x.xx
 
  ssh pi@192.168.x.xx
 
login: pi
 
login: pi
 +
 
password: raspberry
 
password: raspberry
  
 +
=== Stretch ===
 +
To enable SSH:
 +
- Create an empty file named ssh in the boot partition
 +
touch ssh
 +
 +
To enable Wifi:
 +
- Create a config file named  wpa_supplicant.conf in the boot partition. Example content:
 +
 +
country=US
 +
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 +
update_config=1
 +
network={
 +
    ssid="your_real_wifi_ssid"
 +
    scan_ssid=1
 +
    psk="your_real_password"
 +
    key_mgmt=WPA-PSK
 +
}
 +
 +
Now, insert the SD card, optionally connect an ethernet cable and power up the RPi.<br/>
 +
 +
ssh pi@raspberrypi.local
 +
login: pi
 +
 +
password: raspberry
 +
 +
 +
=== Common ===
 
Set the password to something new
 
Set the password to something new
 
  sudo passwd pi
 
  sudo passwd pi
 +
 +
install raspi-config
 +
apt-get install raspi-config
  
 
Start the RPi configuration
 
Start the RPi configuration
Line 21: Line 91:
 
* 1 (expand filesystem)
 
* 1 (expand filesystem)
 
* 3 (boot options) -- console
 
* 3 (boot options) -- console
* 8 (Advanced options)
+
* 4(Locale) Add your local country/langage besides the default
 +
* 7 (Advanced options)
 
** A2 (change name) -- Set whichever host name you like
 
** A2 (change name) -- Set whichever host name you like
** A3 (memory split) – 16
+
** A3 (memory split) – 0 (16 in older version)
** A0 (update)
+
** A4 (SSH) likely you'll want to enable it
 +
 
 +
* Finish
 +
 
 +
Reboot so filesystem is expanded to avoid issues later
 +
 
 +
sudo reboot
 +
 
 +
Log back in using new password
 +
 
  
 
Go into sudo-mode
 
Go into sudo-mode
Line 31: Line 111:
 
Set your time zone:
 
Set your time zone:
 
  dpkg-reconfigure tzdata  
 
  dpkg-reconfigure tzdata  
 +
 +
=== Wifi setup (for Raspberry Pi 3) ===
 +
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 +
 +
Add these lines at the end:
 +
<pre>
 +
network={
 +
    ssid="Your ESSID"
 +
    psk="Your_wifi_password"
 +
} </pre>
 +
 +
Also check the country setting. In my case I changed to:
 +
Country=SE
 +
 +
To enable the new settings:
 +
sudo ifdown wlan0
 +
Wait some seconds
 +
sudo ifup wlan0
 +
 +
Ensure you get an IP adress with:
 +
ifconfig wlan0
 +
 +
If it doesn't work, check the syslog:
 +
tail -100 /var/log/syslog | grep wlan0
  
 
== Remove some unneeded packages ==
 
== Remove some unneeded packages ==
(( Experimental - still doing verifications that nothing broke! ))
 
 
  sudo apt-get remove --purge x11-common -y
 
  sudo apt-get remove --purge x11-common -y
 
  sudo tasksel remove gnome-desktop
 
  sudo tasksel remove gnome-desktop
Line 47: Line 150:
 
== Upgrade the OS to latest version ==
 
== Upgrade the OS to latest version ==
 
  apt-get update
 
  apt-get update
  apt-get upgrade
+
  apt-get dist-upgrade
 
+
  
 
== Get automatic updated date/time ==
 
== Get automatic updated date/time ==
Line 56: Line 158:
 
  sudo nano  /etc/ntp.conf
 
  sudo nano  /etc/ntp.conf
  
Remember to add a time server in this file. I have added "time.nrc.ca"
+
Remember to add a time server in this file. I have added " 0.se.pool.ntp.org" - take a look at [http://www.pool.ntp.org/en/use.html] for more servers close to you.
 
  <nowiki>#You do need to talk to an NTP server or two (or three).</nowiki>
 
  <nowiki>#You do need to talk to an NTP server or two (or three).</nowiki>
 
  <nowiki>#server ntp.your-provider.example</nowiki>
 
  <nowiki>#server ntp.your-provider.example</nowiki>
  time.nrc.ca
+
  0.se.pool.ntp.org
  
 
== aGo Control ==
 
== aGo Control ==
Line 65: Line 167:
 
  wget http://mirror.at.agocontrol.com/debian/conf/agocontrol.gpg.key
 
  wget http://mirror.at.agocontrol.com/debian/conf/agocontrol.gpg.key
 
  apt-key add agocontrol.gpg.key
 
  apt-key add agocontrol.gpg.key
  echo "deb http://mirror.at.agocontrol.com/raspbian testing main" >> /etc/apt/sources.list
+
  echo "deb http://mirror.at.agocontrol.com/raspbian unstable main" >> /etc/apt/sources.list
 
Install aGo Control (Currently approx. 180 MB additional disk)
 
Install aGo Control (Currently approx. 180 MB additional disk)
 
You'll be asked for a QPID daemon password during the install: Set it to something
 
You'll be asked for a QPID daemon password during the install: Set it to something
Line 91: Line 193:
 
password: the new password you set before
 
password: the new password you set before
  
Add your location to the config file
+
Edit the config file
  nano /etc/opt/agocontrol/conf.d/system.conf
+
  sudo nano /etc/opt/agocontrol/conf.d/system.conf
add eg:
+
add e.g. location, (Or use the Home Position tab in the System configuration found under http://your_ip:8008/#config/System):
 
  lat= 56.05
 
  lat= 56.05
  lon=12.7
+
  lon= 12.7
 +
press [CTRL]X to save
  
 
Side note- do not use the absolute value of the coordinates (12.7 != -12.7).  Here's a great resource for finding your position (http://itouchmap.com/latlong.html).
 
Side note- do not use the absolute value of the coordinates (12.7 != -12.7).  Here's a great resource for finding your position (http://itouchmap.com/latlong.html).
 
press [CTRL]X to save
 
  
 
== start / stop / autostart services ==
 
== start / stop / autostart services ==
Line 138: Line 239:
 
== Troubleshoot ==
 
== Troubleshoot ==
 
=== Agocontrol doesn't start ===
 
=== Agocontrol doesn't start ===
 +
But shows "404 not found" in the webbrowser pointing to your rpi ip address running Agoncontrol new install.
 +
then you shall get localisation in place
 +
sudo apt-get install raspi-config
 +
sudo raspi-config
 +
*Choose section 5, internationalisation options
 +
*change locale
 +
*change timezone
 +
 +
 
Make sure user agocontrol is the owner of these directories (and content):
 
Make sure user agocontrol is the owner of these directories (and content):
 
* /opt/agocontrol
 
* /opt/agocontrol

Latest revision as of 11:35, 6 November 2017

Pi2B1.jpeg

Contents

[edit] Installation with readymade images

[edit] Raspberry Pi 1 / RPiB+ (ARMv6)

Jessie image created from raspbian-ua-netinst v1.0.7, based on the guide below to get Agocontrol installed and working, then updated Wheezy to Jessie. Details how to to the update, see [1] user: pi password: raspbian (Note root account also enabled: root/raspbian) Locale to en_DK and city to Copenhagen, change for your need. You must minimum use an 8GB SD card.

Link to RPI B+ AMRv6 image: [2] (Older: [3])
Verify the download with: md5sum raspbian_jessie_agocontrol_ver01.img.xz 396e7df1ca9cda1220edd86e6645f477 raspbian_jessie_agocontrol_ver01.img.xz

This will copy your image to your 8GB SD card. the "--keep" ensure your original image isn't deleted after decompressing

sudo xzcat --keep raspbian_jessie_agocontrol.img.xz |  sudo dd of=/dev/sdb
sync

You might have another /dev/sdb, check in a console "demsg |grep sd"

[edit] Raspberry Pi 2 / RPiB2 (ARMv7)

Download Debian Jessie image at: [4]

The apt sources list is already configured. So no need to mess with it. But if you change it, make sure to use our regular repository, not the raspbian one.

User: root
Password: agocontrol

The image recognized my NIC on the 1st boot, but assigned it to eth1. I did not have internet until editing the udev by commenting out the NIC ending c3:12 and changing my NIC from eth1 to eth0.

nano /etc/udev/rules.d/70-persistent-net.rules

[edit] Installation from scratch

This is a full walk-through example install on a headless Raspberry Pi.

[edit] OS (headless)

[edit] Jessie

N.B. The latest versions of Jessie seems to have SSH disabled; so the first steps needs to be performed with a keyboard and monitor attached.

I recommend using Raspian Jessie lite (minimised image, no GUI etc.) [5] Full version [6]

[edit] Get files onto SD card

Get the image to an SD card, e.g. using one of these tutorials: Windows, Linux, Mac


[edit] Jessie

Insert the SD card, connect an ethernet cable and power up the RPi.
Find the IP adress it has received, e.g. look at the DHCP table in your router
Open a term window (on windows use Putty) and ssh into the RPi

ssh pi@192.168.x.xx

login: pi

password: raspberry

[edit] Stretch

To enable SSH: - Create an empty file named ssh in the boot partition

touch ssh

To enable Wifi: - Create a config file named wpa_supplicant.conf in the boot partition. Example content:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
   ssid="your_real_wifi_ssid"
   scan_ssid=1
   psk="your_real_password"
   key_mgmt=WPA-PSK
}

Now, insert the SD card, optionally connect an ethernet cable and power up the RPi.

ssh pi@raspberrypi.local

login: pi

password: raspberry


[edit] Common

Set the password to something new

sudo passwd pi

install raspi-config

apt-get install raspi-config 

Start the RPi configuration

sudo raspi-config

Use these options:

  • 1 (expand filesystem)
  • 3 (boot options) -- console
  • 4(Locale) Add your local country/langage besides the default
  • 7 (Advanced options)
    • A2 (change name) -- Set whichever host name you like
    • A3 (memory split) – 0 (16 in older version)
    • A4 (SSH) likely you'll want to enable it
  • Finish

Reboot so filesystem is expanded to avoid issues later

sudo reboot

Log back in using new password


Go into sudo-mode

sudo bash

Set your time zone:

dpkg-reconfigure tzdata  

[edit] Wifi setup (for Raspberry Pi 3)

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add these lines at the end:

network={
    ssid="Your ESSID"
    psk="Your_wifi_password"
} 

Also check the country setting. In my case I changed to:

Country=SE

To enable the new settings:

sudo ifdown wlan0

Wait some seconds

sudo ifup wlan0

Ensure you get an IP adress with:

ifconfig wlan0

If it doesn't work, check the syslog:

tail -100 /var/log/syslog | grep wlan0

[edit] Remove some unneeded packages

sudo apt-get remove --purge x11-common -y
sudo tasksel remove gnome-desktop
sudo apt-get remove x11-* -y
sudo apt-get autoremove -y

((so far it seems OK, but the 2 below commands seems to have broken df. ago control still OK))

sudo apt-get purge lxappearance* lxde-common* lxde-icon-theme* lxpolkit* lxrandr* lxtask*
 lxterminal*
sudo apt-get purge desktop-base desktop-file-utils gnome-icon-theme gnome-themes-standard leafpad menu-xdg omxplayer scratch xarchiver zenity

Approx 1 GB will be removed

[edit] Upgrade the OS to latest version

apt-get update
apt-get dist-upgrade

[edit] Get automatic updated date/time

Since the rpi doesn't contain a hwclock. you can install ntppdate. This will right after a netork is up, update to the current date/time

sudo apt-get install ntpdate
sudo nano  /etc/ntp.conf

Remember to add a time server in this file. I have added " 0.se.pool.ntp.org" - take a look at [7] for more servers close to you.

#You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
0.se.pool.ntp.org

[edit] aGo Control

Get the installation key & add installation source

wget http://mirror.at.agocontrol.com/debian/conf/agocontrol.gpg.key
apt-key add agocontrol.gpg.key
echo "deb http://mirror.at.agocontrol.com/raspbian unstable main" >> /etc/apt/sources.list

Install aGo Control (Currently approx. 180 MB additional disk) You'll be asked for a QPID daemon password during the install: Set it to something

apt-get update
apt-get install agocontrol
apt-get install systemd systemd-sysv (optional, see "Sysvinit" section below)
reboot

Optional RPI packages:
RaspberryPi1Wire
RaspberryPiGPIO

Optional packages for hardware and extra feature support:

  • agocontrol-cloud - ago Cloud automation system suport on cloud.agocontrol.com
  • agocontrol-owfs - Device for 1-Wire Hardware
  • agocontrol-zwave - Device for Z-Wave Hardware
  • agocontrol-meloware - Device for Meloware iPhone App
  • agocontrol-mysensors - Device for Mysensors Hardware
  • agocontrol-alert - Device for to communicate via sms, email, tweet, push notifications
  • NOTE: This might not be needed anymore: agocontrol-rrdtool - Device for RRDtool graphs, plot, and lists of your measuring sensors


After reboot, ssh into the RPI again

ssh pi@192.168.x.xx

password: the new password you set before

Edit the config file

sudo nano /etc/opt/agocontrol/conf.d/system.conf

add e.g. location, (Or use the Home Position tab in the System configuration found under http://your_ip:8008/#config/System):

lat= 56.05
lon= 12.7

press [CTRL]X to save

Side note- do not use the absolute value of the coordinates (12.7 != -12.7). Here's a great resource for finding your position (http://itouchmap.com/latlong.html).

[edit] start / stop / autostart services

Configue service autostart This will enable all services:

/opt/agocontrol/bin/agoctrl.sh enable

You can also use "systemctl enable <service>" to manually enable specific services. ""Start components"" This will start all installed components:

/opt/agocontrol/bin/agoctrl.sh start


Now open http://192.168.x.xx:8008 on another machine
In the Web UI, add rooms & floorplans

If you get some strange problems with sudo:

PATH=$PATH:/usr/bin
echo $PATH

[edit] Sysvinit

By default, raspi is pre-installed with sysv-init. You can replace it by systemd as explained above.

But if you don't want, you can copy this script into /etc/init.d/agocontrol file.

wget "http://git.agocontrol.com/agocontrol/agocontrol/raw/develop/conf/sysvinit/agocontrol.in" -O /etc/init.d/agocontrol
chmod +x /etc/init.d/agocontrol

And execute this command to start agocontrol at raspi startup:

update-rc.d agocontrol defaults

Also make sure all your installed plugins are listed in APPS variable.

nano /etc/init.d/agocontrol
APP="agorpc agodatalogger agoevent agoresolver agoscenario agotimer <add here all your plugins bin name>"
[CTRL]X to save changes

If you want to remove agocontrol from startup execute this command

update-rc.d -f agocontrol remove

[edit] Troubleshoot

[edit] Agocontrol doesn't start

But shows "404 not found" in the webbrowser pointing to your rpi ip address running Agoncontrol new install. then you shall get localisation in place

sudo apt-get install raspi-config
sudo raspi-config
  • Choose section 5, internationalisation options
  • change locale
  • change timezone


Make sure user agocontrol is the owner of these directories (and content):

  • /opt/agocontrol
  • /var/opt/agocontrol
  • /etc/opt/agocontrol

If not execute command:

chown -R agocontrol:agocontrol <dir>

[edit] Agocontrol doesn't start (sysvinit)

If you use sysvinit, make sure BIN_PATH variable of /opt/init.d/agocontrol is correct

BIN_PATH=/opt/agocontrol/bin/

[edit] Some processes stops just after launch

If some processes stops just after launch with this error:

pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed

Please make sure you aptitude source list is pointing to raspbian repository and not debian.

Personal tools