Monthly Archives: October 2014

Raspberry Pi – Turn your Pi into a Wireless Router

Hello everyone. Today I want to show you how you can turn your Raspberry Pi into a Wireless Router. I know there are many posts of this kind out there in the net but I wanted to show you the easiest solution I found on the net so far since it can be quite troublesome to find a matching Wireless adapter and to set up hostapd.

What do you need?

  • A Raspberry Pi Model B (plus power adapter, SD card and a LAN cable. And I recommend to set up SSH)
  • A Wireless adapter. I used the EDIMAX EW-7811UN Wireless USB Adapter I bought from Amazon (Link here) since it is quite cheap and it worked for me pretty well.
  • Raspbian wheezy as Operating System. You can download it from here.
  • A (wireless) router to download the necessary software packages.

Hardware Setup

Install the Raspbian wheezy Operating System on your SD card and put it into your Raspberry Pi. Next plug your LAN cable into your Raspberry Pi and connect the other end to your (wireless) router you use to access the internet. As mentioned above I would recommend to enable SSH on your Raspberry Pi so you can configure it without having a monitor, keyboard, etc. ready.

Turn your Pi into a wireless router

Now to the most interesting steps.

The first thing you need to do is to update your Raspberry Pi by running the following commands: (It´s always a good idea to update first to prevent issues with outdated versions, etc.)

sudo apt-get update
sudo apt-get upgrade

Next install the software packages for the DHCP server. (Ignore error messages if you receive some. They are normal since you haven´t configured the DHCP server yet.)

sudo apt-get install isc-dhcp-server

The next step is to install hostapd. Since our wireless adapter (EDIMAX EW-7811UN Wireless USB Adapter) needs a driver not supported by hostapd we need to download a custom version of hostapd (Thanks to this guy (http://jenssegers.be/) we have this simple solution. Please give him some credit for his work.). Simply run the following commands to install this custom version:

wget https://github.com/jenssegers/RTL8188-hostapd/archive/v1.1.tar.gz
tar -zxvf v1.1.tar.gz
cd RTL8188-hostapd-1.1/hostapd
sudo make
sudo make install

The above commands will take some time so please be patient.

Next we need to configure our DHCP server.

sudo nano /etc/dhcp/dhcpd.conf

Find the following lines and place a hashtag (#) in front of them to remove them from the configuration file:

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

Now search for the following line and remove the hashtag in front of it:

#authoritative;

Now go to the end of the file and add the following configuration:

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.250;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local-network";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

You can alter the above configuration to fit your needs. The above configuration will set up your DHCP server to hand out IP addresses from 192.168.0.10 to 192.168.0.250 and will set the DNS server to Googles DNS servers 8.8.8.8 and 8.8.4.4.

Don´t forget to save the changes.

Next we need to configure on which Interface our DHCP server will hand out IP addresses. To do so run this command:

sudo nano /etc/default/isc-dhcp-server

Now search for:

INTERFACES=""

And add the name of your WLAN Interface to it like this: (My WLAN Interface is called “wlan0”)

INTERFACES="wlan0"

Next we need to assign a static IP address to out WLAN Interface. To do so run the following command:

sudo nano /etc/network/interfaces

Now assign the IP address you chose as “option routers” in the dhcpd.conf file (in our example: 192.168.0.1) to your WLAN Interface. Your file should now 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

allow-hotplug wlan0

iface wlan0 inet static
address 192.168.0.1
netmask 255.255.255.0

Ok. Now we have finished setting up our DHCP server.

For the next step we need to setup hostapd. To do so run the following command:

sudo nano /etc/hostapd/hostapd.conf

Now search for ssid and wpa_passphrase and enter an SSID Name (for example: MyPi) and Password (for example: Password1) for your future wireless network. That´s it. We finished configuring hostapd.

Next we need to enable NAT. First we need to make sure that our Raspberry Pi will forward packages. To do so we run:

sudo nano /etc/sysctl.conf

And search for:

#net.ipv4.ip_forward=1

Remove the hashtag in front of the line and save your changes.

Run the following command to enable the forwarding immediately:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Next we need to configure rules to forward all traffic from our WLAN Interface (wlan0) to our cable bound network (eth0) to make sure that Clients connected to our WLAN network can access the internet. To do so run the following commands:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

Now run the following command to save the rules otherwise they will be lost when you turn off your Raspberry Pi:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Ok. We finished configuring NAT. The last step is to make sure that all services and configurations we made above will be set up at start so that we do not need to run them every time we start our Raspberry Pi.

To automatically start our DHCP server at start run the following command:

sudo update-rc.d isc-dhcp-server enable

To automatically start hostapd at start run the following command:

sudo update-rc.d hostapd enable

Unfortunately I received the following error:

update-rc.d: using dependency based boot sequencing
update-rc.d: error: no runlevel symlinks to modify, aborting!

If you receive the same error run the following commands:

sudo ln -s /etc/init.d/hostapd /etc/rc2.d/S02hostapd
sudo update-rc.d hostapd enable

After I did that it worked for me. (Thanks to this thread I was able to solve this problem: http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=37898)

Now we need to make sure that the traffic forwarding rules will also get loaded at start. To do so open the interfaces file by running:

sudo nano /etc/network/interfaces

Add the following line to the end of the file:

up iptables-restore < /etc/iptables.ipv4.nat

Ok. We are almost there. Now reboot your Raspberry Pi by running:

sudo reboot

Wait till your Raspberry Pi has rebooted. You should now find a new SSID with the name you chose (for example: MyPi). If everything worked you should be able to connect to it by entering your Password (for example: Password1) and you should be able to access the internet.

Well, that´s it. Your Raspberry Pi is now a wireless router. I hope you liked my post and I hope to see you again next time 🙂

By the way my configuration files are stored here if you want to have a look at them. And please have a look at the sources if you want to know more about this topic.

Sources:

http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/

http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=37898

http://www.maketecheasier.com/set-up-raspberry-pi-as-wireless-access-point

http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/

http://elinux.org/RPI-Wireless-Hotspot

http://jacobsalmela.com/raspberry-pi-and-routing-turning-a-pi-into-a-router/

Tagged

SharePoint – How to use mathematical formulas on your pages

Hello everyone. Today one of my clients asked me if it is possible to add mathematical formulas to SharePoint pages. I found a solution here that gives you the possibility to generate gif images from Latex code. Please give the guys from codecogs some credit for their awesome solution and donate some money if you liked this solution.

Now lets get down to business 🙂

Here is the example code I used to add the Theorem of Pythagoras to my SharePoint page:

<html>
<head>
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>
</head>
<body>
<h1>Theorem of Pythagoras</h1>
<div lang="latex">a^2 + b^2 = c^2</div>
</body>
</html>

Upload the above script to your SharePoint site and add a Content Editor Web Part to the page. Add the link to your script to the Content Editor Web Part.

sharepoint_math_formula_editor

The result will look like this:

sharepoint_math_formula_finished

Pretty simple right? This way you can add all kinds of mathematical formulas to your SharePoint pages.

I hope you liked my post and I hope to see you again next time 🙂

Sources:

http://www.codecogs.com/latex/integration/htmlequations.php

http://stackoverflow.com/questions/11824093/how-to-integrate-a-shortcode-feature-in-sharepoint-wikis

Tagged ,

Raspberry Pi – Automatic Number/License Plate Recognition (ANPR/ALPR)

Hello everyone. Today I want to show you how you can use your Raspberry Pi and Javaanpr to automatically extract a license plate number from a picture. You can use this technology to open your garage door for example.

To make this work run the following commands to update your Raspberry Pi and to install Java on it: (Oracle Java 7 JDK did the best job in my tests)

sudo apt-get update
sudo apt-get install oracle-java7-jdk

After the update and installation have finished you need to download Javaanpr.

Now use a test picture of a license plate and run the following command:

time java -jar javaanpr.jar -recognize -i test.jpg

Here is a screenshot of my test: (I used the Raspberry Pi B Model and I did not overclock it.)

raspberry_pi_javaanpr

It took about 10 seconds for Javaanpr to get the license plate number. Pretty fast in my opinion.

Well, that´s it. You can now use this knowledge for you projects. For example an automatic garage door opener. I hope you liked my post and I hope to see you next time 🙂

Update: I forgot to mention the following: To use Javaanpr all you need to do is to place the jar you downloaded from here into some directory on your Raspberry Pi and run the command

java -jar javaanpr.jar -recognize -i test.jpg

 to execute it. That´s all.

Sources:

http://object-network.blogspot.co.at/2014/02/seven-uses-of-raspberry-pi-camera.html

http://www.raspberrypi.org/forums/viewtopic.php?f=37&t=58257

http://javaanpr.sourceforge.net/

http://www.raspberrypi.org/forums/viewtopic.php?t=44080&p=374054

http://scruss.com/blog/2013/09/26/faster-java-on-raspberry-pi/

Tagged ,

SharePoint – Use JQuery to highlight rows

Hello everyone. Today I want to show you how you can use jQuery and SPServices to conditionally highlight rows of your SharePoint Web Parts.

Here is the script you need:

<script type="text/javascript" src="/sites/test2/Script/jquery.min.js"></script>
<script type="text/javascript" src="/sites/test2/Script/jquery.SPServices.min.js"></script>

<script language="javascript" type="text/javascript">

$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Test",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='YesNoField' /><Value Type='Integer'>1</Value></Eq></Where></Query>",
CAMLViewFields: "<ViewFields> <FieldRef Name='ID' /> </ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {

$("tr[iid*='"+ $(this).attr("ows_ID").toString() + "']").css("background-color", "#A3F02E");

});
}
});
});

</script>

The above Script will check the value of the “YesNoField” column in your “Test” List and if the value is “Yes” (1) it will highlight the row. If the value is “No” (0) it will do nothing.

To use the script click on Edit Page on your website and add your List Web Part and a Content Editor Web Part and add a link to your script to the Content Editor Web Part. (You need to store the script somewhere on your website in a Library.)

sharepoint_setup_highlighted_row

If you set up everything correctly the result will look like this:

sharepoint_highlighted_row

That´s it. You can now use this method to highlight specific rows. I hope you liked my post. See you next time 🙂

And as always you can download my script from here.

Sources:

http://mekalikot.blogspot.co.at/2014/01/highlight-sharepoint-task-list-row.html

http://spservices.codeplex.com/wikipage?title=GetListItems

http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1905cd40-c66b-4865-a036-299c88b8bc51/how-to-write-caml-query-for-yes-no-field

http://mekalikot.blogspot.co.at/2014/07/highlight-row-change-font-color-and.html

Tagged ,

SharePoint – Use JQuery to hide columns based on a Users Group Membership

Hello everyone. Today I want to show you how you can use jQuery and SPServices to hide SharePoint columns based on a users group membership.

In a previous post I explained how you can use jQuery and SPServices to Auto-Fill fields. Please follow the instructions in this post but use the script below instead in your NewForm.aspx and/or EditForm.aspx pages.


<script type="text/javascript" src="/sites/test/Script/jquery.min.js"></script>
<script type="text/javascript" src="/sites/test/Script/jquery.SPServices.min.js"></script>

<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
var xml = xData.responseXML.xml;
if(xml.search('SharePoint Group') != -1)
{

$('nobr:contains("TestColumn")').closest('tr').hide();

}
}
});
});
</script>

Replace “TestColumn” with the Name of your column you want to hide. And replace “SharePoint Group” with the Name of your SharePoint Group. If you configured everything correctly your column will be hidden for members of the SharePoint Group you defined in the script. (To hide a column for everyone except a specific group replace

if(xml.search('SharePoint Group') != -1)

with

if(xml.search('SharePoint Group') == -1)

)

That´s it. Now you are able to hide columns from specific user groups. I hope you liked my post. See you next time 🙂

And as always you can download my script from here.

Sources:

http://www.sharepointnadeem.com/2011/09/hide-sharepoint-list-field-based-on.html

http://sharepointroot.com/2011/09/23/sharepoint-2010-how-to-hide-blog-fields-using-jquery/

https://theezitguy.wordpress.com/2014/05/26/sharepoint-auto-fill-fields-using-jquery-and-spservices/

Tagged ,