The first thing you need to do when you get your raspberry pi, is get a case? Well you can 3D print one. Here is a good example for the B+ Raspberry Pi B+ Face Case by adafruit – Thingiverse
Additionally you need to buy a micro SD card. I got an 8GB one and I have my primary RPi which a download server and WebIOPi server with a 16GB one.
Install an OS and setup things
Next you need to install an OS. Go to raspbian.org and download the latest version. I recommend the torrent way. Depending on what you are using on your computer, you need a way to write the OS image to your sdcard. NO you cannot simply copy it to the card and be done with it. For windows, you need win32disk imager and for linux you need either dd or imagewriter. Check out this link for the “official” methods. http://www.raspberrypi.org/documentation/installation/installing-images/README.md
The first time you put this card in the pi will start the configuration util automatically. Hence you need to attach a display and keyboard the first time. I suggest the following things be done.
- Expand the file system to use the entire card.
- Enable SPI
- Enable SSH
Most of the above is menu based so should not be a problem.
Setting up OpenHAB
Now the default method is to install OpenHAB is to download it and unzip it to /opt/OpenHAB and then do all the stuff. Now I don’t think that is compulsory since there will be only one user for our tests. Hence I installed it directly in /home/pi/OpenHAB. Copy the code below into a file setup openhabset.sh and save it in /home/pi
#!/bin/bash # Create a folder mkdir /home/pi/OpenHAB wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console -O /usr/bin/rpi-serial-console sudo chmod +x /usr/bin/rpi-serial-console echo "Disable serial Console so that we can use it for EnOcean Pi" rpi-serial-console disable echo "Downloading Runtime" wget https://github.com/openhab/openhab/releases/download/v1.5.0/distribution-1.5.0-runtime.zip -O /home/pi/OpenHAB/ echo "Installing..." unzip /home/pi/OpenHAB/distribution-1.5.0-runtime.zip -d /home/pi/OpenHAB/ echo "Getting addons" wget https://github.com/openhab/openhab/releases/download/v1.5.0/distribution-1.5.0-addons.zip -O /home/pi/OpenHAB echo "Installing addons" unzip /home/pi/OpenHAB/distribution-1.5.0-addons.zip -d /home/pi/OpenHAB/addons/ echo "Default Configuration" cp /home/pi/OpenHAB/configurations/openhab_default.cfg /home/pi/OpenHAB/configurations/openhab.cfg
Run the above script by executing the following command at the terminal
sudo sh openhabset.sh
At this point, you have all that you need. You can download the demo setup from the website as well. The link is openHAB – empowering the smart home
In order to start OpenHAB, cd to the OpenHAB directory and type sudo sh start.sh . I made a change in the start.sh file as per the link https://github.com/openhab/openhab/wiki/Samples-Tricks
The serial port needs to be pointed to for the EnOcean Pi to work. I recommend a reboot at this time.
Installing Samba and Sharing OpenHAB
Now I use windows has my primary laptop OS hence I would like to make changes to the OpenHAB system and develop then and there. I have already setup a static IP which means everytime my RPi boots up, it’s IP address is the same. I can ssh and then use nano to edit files BUT there is a better option- OpenHAB Designer. The OpenHAB designer is based on eclipse and all you need to do it tell it to open the configuration folder in OpenHAB. But If I use Windows and I want to access the folder, how is it possible?
This is where Samba comes in. It allows us to share the OpenHAB folder we created and share it like a windows share. Then on my windows laptop(which is on the same local network) I can simply “Map network drive” and use the same username and password to access the folder if it was a drive somewhere. Then point OpenHAB designer to it and viola!
To install Samba, you need a terminal on the RPi. SSH to you RPi and then type the following commands…
sudo apt-get install samba samba-common-bin sudo nano /etc/samba/smb.conf
At this point you will have nano editor open and the file smb.conf open in it. Find the entry workgroup and wins support in the file. Set them up as follows
workgroup = WORKGROUP wins support = yes
If you have a different workgroup name, please feel free to make changes but the default workgroup name is WORKGROUP. Also add the following lines to the file where it says “Share Definitions”
[OpenHAB] comment= OpenHAB Home path=/home/pi/OpenHAB browseable=Yes writeable=Yes only guest=no create mask=0777 directory mask=0777 public=no
At this point use ctrl+x to exit. press y and enter. That should exit nano.
Now we need to set the password for the for the share.
sudo smbpasswd -a pi
Now in your windows machine, point to the ip address of your Pi and map it as a network drive. Download the OpenHAB designer from it’s website and point it to the shared folder and you should be good.
At this point you can download the demo file, copy em to the share and OpenHAB do it’s thing.
Hope this helps.