Category Archives: raspberry pi

Enable I2C on rPi

1-
sudo nano /etc/modules

2-
To the bottom
snd-bcm2835
i2c-bcm2708
i2c-dev

3-
If so check blacklist file. It depends on your board type
sudo nano /etc/modprobe.d/raspi-blacklist.conf

Comment out following lines as follows;
#blacklist spi-bcm2708
#blacklist i2c-bcm2708

4-
sudo apt-get install python-smbus
sudo apt-get install i2c-tools

5-
sudo nano /boot/config.txt
Add these line at the bottom of the file
dtparam=i2c1=on
dtparam=i2c_arm=on

sudo raspi-config

->Advanced options->enable i2c

6-
Do not forget to reboot
sudo reboot

7-
Check whether it works or not
sudo i2cdetect -y 0 (for a Revision 1 board like mine)
or
sudo i2cdetect -y 1 (for a Revision 2 board)

8-
then you should see output showing any I2C devices that are attached and their addresses

0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — — — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — 68 — — — — — — —
70: — — — — — — — —

Install Samba Server on Raspberry Pi to access over network

1-
sudo apt-get install samba samba-common-bin

2-
The directory that we will share out will act as a mount point for external storage. So we will need to create the directory and set appropriate permissions to the directory. Using mkdir(/bin/mkdir) we can both create the directory and set the permissions in the one command. The -m option will allow you to set the mode or permissions of the directory.

sudo mkdir -m 1777 /data

From the above command we can see the easy part, creating the directory /data. As it is at the root of the file-system we will need administrative permissions to do this so we run it prefaced with the sudo command. The mode of the directory is set with the -m option:

1: sets the sticky bit. This set on a directory ensures that users can only delete files they own.
7: sets RWX read , write and execute for the user owner
7: sets RWX read , write and execute for the group owner
7: sets RWX read , write and execute for others
This directory will be empty at the moment and, of course, the root file-system is limited in size on the Pi to that available from the SD cards. We can use an external drive connected to the USB ports and have this mounted to the /data directory. This then can provide effective storage for your network

3-
Backup conf file and edit as following;
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo rm /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

Add the following lines;
[global]
workgroup = HOME
netbios name = KINETIC
server string = Kinetic Server %v
map to guest = Bad User
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
preferred master = No
local master = No
dns proxy = No
security = User

wins support = yes

[Data]
comment= Pi Home
path=/home/pi
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=yes

4-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart

5-
Create users
The last part of this tutorial will involve us creating samba users. These users must represent Linux users but their password can and should be different to the Linux password for security. This is not enforced though. Using the command smbpasswd(/usr/bin/smbpasswd) as the root user we can add new samba users. A user must have a password in samba to access shares.

sudo smbpasswd -a root
sudo smbpasswd -a pi

6-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart