Saturday, May 9, 2015

Raspberry Pi How to


Here is my work summery on the Raspberry Pi.  As I start working on it and put it all together, this efforts are made to collect all the information I need, it is wise to save all my work notes.

So, first of all you should have the following items on your desk to start working on the Raspberry Pi:
I like this image from Element 14 Community.






I am done writing all the drivers and some apps that use I2C, SPI, GPIO, and other resources on the board. so, I will be updating this page soon.

Setting up the RaspberryPi:
to start here is the ID and password for the default user
ID: pi
Password: raspberry




GPIO:
There are at least two options to work with GPIOs. One is mapping a pointer to the GPIO registers and using that to manipulate IOs. Two is to use file system by opening the proper file and manipulating that.

Note:
There is a change on Raspberry pi 2 that affected the addressing of GPIO address, originally the following mapping was used on the Raspberry pi
#define BCM2708_PERI_BASE        0x20000000   
#define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000)  
/* GPIO controller */

the following change will be used to map to the new Raspberry pi 2
#define BCM2708_PERI_BASE        0x3F000000  
#define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000) 
/* GPIO controller */


I2C:

Will need to install:
sudo apt-get install libi2c-dev
sudo apt-get install i2c-tools

Then you will be able to run:
sudo i2cdetect -y 1
i2cget
i2cset

Now, How to read/write to I2C:




SPI:
Great news, SPI is functioning now, I am working on learning more about the process and customizing the code to work with my need as a general SPI master that can communicate with different SPI resources.


Read and Write files on micro SD Card
You can read/write files on the SD card or on a mounted USB Flash drive.
to do, you need to know first the mount point for this device.



Sound:



How to sync time with NTP server on login:
We need to edit the NTP time server list.
well, the command is
ntpdate ntp_server_address
but, I found out on the Rasspberry pi I get this message
the NTP socket is in use, exiting
So, I need to do this
sudo service ntp stop
sudo ntpdate ntp_server_address
sudo service ntp start
and now it works just fine....
You can test to see if ntpd is running,
ntpd -p
Also, need to select your proper time zone:
need to remove the timezone file first
rm localtime
now link to the correct file for your time zone
cd /etc
ln -s /usr/share/zoneinfo/US/Eastern localtime
Now when you sync it will show the correct time for your zone.


Start App automatically on boot:

to be able to run a script automatically after login, we need to edit the following file
sudo nano /etc/profile
then add the executable at the end of this file such as the commands needed to automatically execute ntp sync at login
sudo service ntp stop
sudo ntpdate ntp_server_address
sudo service ntp start

There is also cron:
cron is a software utility that is time based to run scripts in a Linux like environment.
crontab is cron table that contains all these scripts
a link is provided to read more about cron on Wikipedia web site, very good information


Bluetooth management:
Some more details to be added here once I am finished with it...



Links to resources:



http://askubuntu.com/questions/244526/unable-to-synchronize-time-using-ntp

http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html

http://en.wikipedia.org/wiki/Cron

How to configure your Raspberry pi WiFi and Bluetooth

No comments:

Post a Comment