admin

admin

Wednesday, 18 June 2014 23:34

Removing Applications from Raspberry Pi

You might want to remove some applications to free up some space on SD card. Use the following syntax to uninstall a program
sudo apt-get –purge remove APPNAME #replace APPNAME with the name of the app you want to remove
An example to remove Scratch program 
sudo apt-get remove scratch
Tuesday, 10 June 2014 14:52

Raspberry Pi Digital Signage

Raspberry Pi (Model B) is a single-board computer that uses an ARM 11 (ARM1176JZF-S core) processor running at 700MHz (it can overclock up to 1GHz) with 512MB RAM.
 
This article shows you how to turn your Raspberry Pi into a cheap, browser based digital signage solution. It covers setting up a mini webserver on using the lighttpd+PHP web server and also how to start a web browser without a desktop environment.
 
I will use Midori as the web browser since it is a default browser that is found in Raspbian (a free operating system based on Debian optimized for the Raspberry Pi).
Edit the crontab file
sudo su - #switch to supuer user
crontab -e #edit crontab file

Put this line at the end of the file. This will turn off display at 5.30PM and turn on display at 8.30AM

30 17 * * * tvservice -o

30 8 * * * tvservice -p; fbset -depth 8; fbset -depth 16

 
Crontab syntax:
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0-6) (Sunday=0)
|     |     |   +------- month (1-12)
|     |     +--------- day of month (1-31)
|     +----------- hour (0-23)
+------------- minute (0-59)
Wednesday, 21 May 2014 12:46

Raspberry Pi Schedule Reboot

Edit the crontab file
sudo su - #switch to supuer user
crontab -e #edit crontab file

Put this line at the end of the file. This will reboot the Raspberry Pi at 1.30PM every day.
30 13 * * * sudo reboot
 
Crontab syntax:
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0-6) (Sunday=0)
|     |     |   +------- month (1-12)
|     |     +--------- day of month (1-31)
|     +----------- hour (0-23)
+------------- minute (0-59)
Example Configuration
  • Raspberry IP: 192.168.0.123
  • Router IP (Gateway): 192.168.0.254
  • Subnet Mask: 255.255.255.0
  
List the network interface we currently have available:
cat /etc/network/interfaces
The output should look like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
The line iface eth0 inet dhcp shows that it is currently getting out IP address via DHCP. We need to change this line to iface eth0 inet static.

Edit /etc/network/interfaces
sudo nano /etc/network/interfaces
Change  iface eth0 inet dhcp to iface eth0 inet static and add the following settings just below it:
address 192.168.0.123
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
Here is an example:

auto lo

iface lo inet loopback
iface eth0 inet static
address 192.168.0.123
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Finally, reboot the Raspberry Pi.
 
 
Fixing DNS problems
DNS is the service that converts the website URL, i.e. www.goggle.com into the IP address (173.194.126.36) that is needed for actual communication. 
 
Check your DNS entrie
cat /etc/resolv.conf
 
Here is an example of the output
nameserver 192.168.0.254
The nameserver should same as your gateway (your modem IP). If the nameserver and the gateway is different, you should modify the /etc/resolv.conf file and change the nameserver to your gateway IP.
sudo nano  /etc/resolv.conf
 
 
View the current display configuration
tvservice -s
 
View the /boot/config.txt settings
vcgencmd get_config int
 
Get the list of what is supported by your monitor:
tvservice -d dataFile #dump information to dataFile
edidparser dataFile #load dataFile & display on screen

Midori is a lightweight browser using the WebKit rendering engine and it is a default browser that is found in Raspbian. This is a quick quide to start the Midori browser from the command line without a desktop manager.

 
To start the Midori in full screen mode, use the following command:
xinit /usr/bin/midori -e Fullscreen -a http://domain/homepage.html
 
However it is not in full screen mode, it just fill up about quarter size of the screen. To fix this problem, Midori must run on a windows manager. Here is the solution:
Sunday, 04 May 2014 20:43

Setup a Raspberry Pi PHP web server

Lighttpd is a lightweight web server, with all the essential functions of a web server, PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. This is a quide on how to install Lighttpd and PHP on a Raspberry Pi.
 
Prerequisite
Sunday, 04 May 2014 11:02

Some useful javascript

Some useful javascript
Create an XML HTTP Request (XHR) object
  1. function create_XMLHttpRequest() { //create new XHR object
  2. if (window.XMLHttpRequest)
  3. {// code for IE7+, Firefox, Chrome, Opera, Safari
  4. xmlhttp=new XMLHttpRequest();
  5. } else {// code for IE6, IE5
  6. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  7. }
  8. return xmlhttp;
  9. }
 
 
Send request to Server and receive response from server
  • Get replay from php web server: serverResponseInfo=httpGetRequest("http://domain/myReply.php")
  • Read content from a text file: serverResponseInfo=httpGetRequest("myTextFile.txt")
  • Read content from a text file: document.getElementById("myDiv").innerHTML=loadXMLDoc("myTextFile.txt");
function httpGetRequest(url)
{
   xmlhttp= create_XMLHttpRequest();
   xmlhttp.open("GET",url,false);
   xmlhttp.send();
   return xmlhttp.responseText;
}
 
 
Check if file exist
  • To check a file if exist in www root directory: fileExists("/settings.xml")
  • To check a file if exist in the current directory: fileExists("settings.xml")
  1. function fileExists(filename) {
  2. xmlhttp= create_XMLHttpRequest(); //create new XHR object
  3. if(!xmlhttp) return false;
  4. try
  5. {
  6. xmlhttp.open("HEAD", filename, false);
  7. xmlhttp.send(null);
  8. return (xmlhttp.status==200) ? true : false;
  9. }
  10. catch(er)
  11. {
  12. return false;
  13. }
  14. }
 
 
Load an XML file using XML HTTP Request
Eg. loadXML("settings.xml")
  1. function loadXML(XML_filename) {
  2. xmlhttp= create_XMLHttpRequest();
  3. xmlhttp.open("GET",XML_filename ,false);
  4. xmlhttp.send();
  5. return xmlhttp.responseXML;
  6. }
 
 
Convert XML to string
  1. function xmlToString(xmlDoc){
  2. if(xmlDoc.xml){
  3. // MSIE
  4. xmlString = xmlDoc.xml;
  5. }else{
  6. xmlString = (new XMLSerializer).serializeToString(xmlDoc);
  7. }
  8. return xmlString;
  9. }
 
 
Create a string based on date
Example of output: 2014_0502
  1. function createString_accordingDate() {
  2. var today = new Date();
  3. var dd = today.getDate();
  4. var mm = today.getMonth()+1;//January is 0!
  5. var yyyy = today.getFullYear();
  6. if(dd<10){dd='0'+dd} ;
  7. if(mm<10){mm='0'+mm};
  8. return (yyyy + "_" + mm + dd);
  9. }
.
Saturday, 15 February 2014 20:38

Wireless Router Remote Control Car

This is my first RC car control by an Arduino and a wirless router running OpenWRT. There are many OpenWRT supported routers, I'm using a TP-Link TL-MR3020 3G/4G Wireless N Router for this project since it is very slim, low power consumption and it is cheap.

 

RC car features

  • A webcam, the car can be driven without line of sight
  • A horn so that you can honk at people.
  • LED Headlights attached to the front of the car
  • Two wheel drive motor
  • Windows GUI application or web interface
  • Future Additions: Control by a smartphone (Android & IOS)
Back to Top