Lara Nyman

My experiences of technology

Month: December 2016

‘Tis The Season To Be Jolly

As we near the end of the year, I thought I would delve into my ‘box of things’ to create something apt for the festive season;  I came up with Christmas Lights.

What I used

  1. Raspberry Pi (with Raspbian ‘Wheezy’ operating system (OS) on an SD card)
  2. Micro USB cable power supply
  3. Arduino
  4. Breadboard
  5. 8 x 5mm LED’s
  6. 8 x 330Ω resistors
  7. 10 Jumper wires
  8. Either an Arduberry or a Cable A to Cable B USB (to connect the Raspberry Pi to Arduino)
  9. Edimax wifi adaptor ( If wanting to use Raspberry Pi without physical connection to the router )
  10. Ethernet cable ( If network settings have not already been configured on the Raspberry Pi or you do not have a wifi adaptor )
  11. Laptop/PC

Aim

I wanted to create an application that combined the use of my Raspberry Pi with my Arduino; the use of the Raspberry Pi would act as my mini computer whilst the Arduino would be utilised for the output.  I also wanted to use my Raspberry Pi headless i.e. with no keyboard, mouse or monitor.  Therefore I used virtual network computing (VNC) from my laptop to connect to my Raspberry Pi.

Assumptions

I am making the assumption that the OS has already been loaded correctly onto the SD card and inserted into the Raspberry Pi and that the initial setup of the Raspberry Pi has been completed.  As I have a MacBook, these instructions are tailored to a computer with a UNIX environment.

What I did

1.   Configure Raspberry Pi Network Settings

As I connect my Raspberry Pi to the same network each time I use it, I decided to configure the network connection within the wifi protected access (WPA) client and supplicant on my Raspberry Pi; this enables me to get going quickly each time I turn my device on.

To do this, I initially needed to connect the Raspberry Pi directly to the router using the ethernet cable and be able to ssh into the device to be able to configure the correct settings.  However, in order to ssh, I needed to find out what IP address the Raspberry Pi was connecting to.  By running the following command through terminal on my MacBook, I was able to see the different connections:

arp -a

One of the connections showed:

raspberrypi (192.168.1.97) at 74:da:38:54:8c:ae on en0 ifscope [ethernet]

where 192.168.1.97 is the IP address.  The default username on the Raspberry Pi is ‘pi’, so I was able to ssh by running:

ssh pi@192.168.1.97

When connecting to the host for the first time, you might see the following:

The authenticity of host '192.168.1.97 (192.168.1.97)' can't be established. 
RSA key fingerprint is e3:68:b6:5b:27:37:85:57:f6:90:34:81:ae:3b:66:23. 
Are you sure you want to continue connecting (yes/no)?

You should type ‘yes’ in response.  It will then proceed to add the IP address to the list of known trusted hosts.

The default password on a raspberry pi is ‘raspberry’, so when prompted, this should be typed in.

Now that I was connected to my Raspberry Pi, I was able to proceed with editing the WPA settings.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Inside of the conf, make sure that there is the following making sure to replace {WifiName} and {WifiPassword} with your wifi connection settings:

trl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="{WifiName}"
psk="{WifiPassword}"
}

You should now restart your Raspberry Pi safely using:

sudo reboot

2.   SSH into the Raspberry Pi

On restarting, you should disconnect your device from the ethernet cable and plug in the wifi dongle if you wish.  On startup, you should now be able to SSH into the device through your wireless wifi connection.  A reminder of the commands are:

arp -a
ssh pi@192.168.1.97

3.   Housekeeping and Installation of Software

I used the advanced package tool (APT) in order to install software onto the Raspberry Pi.  For a bit of housekeeping, the following should be run:

sudo apt-get update 
sudo apt-get upgrade

N.B There will be much output from these commands in the terminal.  I was then able to install a VNC server and the Arduino IDE onto my Raspberry Pi:

sudo apt-get install tightvncserver
sudo apt-get install arduino

4.   Start VNC server

tightvncserver

The first time that this is run, a password will be required to access the VNC desktop.

5.   Start VNC session

vncserver :0 -geometry 1920x1080 -depth 24

6.   Check out the VNC desktop

You need to go to a web browser and type the following as the URL replacing {ipaddress} with the IP address you identified earlier when SSH’ing into the Raspberry Pi :

vnc://{ipaddress}

In this example, I would direct my browser to vnc://192.168.1.97 .  A pop up may appear; you need to specify your IP address as your VNC server and your password is what you have set in step 4.

Now that the setup of the Raspberry Pi has been completed, the configuration of the Arduino can be carried out.

7.   Plug Everything In

Christmas Lights Circuit

Diagram from SparkFun

Christmas Lights Setup

8.  Write Code

You should navigate to the Raspberry Pi desktop and open the ArduinoIDE.  In a new sketch, type the following:

int ledPins[] = {2,3,4,5,6,7,8,9};

void setup()
{
  for(int i = 0; i <= 7; i++)
  {
    pinMode(ledPins[i],OUTPUT);
  }
}

void loop()
{
  oneAfterAnotherLoop();  
}

void oneAfterAnotherLoop()
{
  int delayTime = 100; 
  for(int i = 0; i <= 7; i++)
  {
    digitalWrite(ledPins[i], HIGH);
    delay(delayTime);                
  }                                  
  for(int j = 7; j >= 0; j--)
  {
    digitalWrite(ledPins[j], LOW);
    delay(delayTime);
  }               
}

9.   Upload to Arduino

The Arduino needs to be connected to the Raspberry Pi.  This was done using a cable A to cable B USB.  To upload the code to the Arduino, you need to make sure that you have specified what board you want to upload to.  Under Tools, navigate to Board and select the type of Arduino you own.  I selected Arduino UNO.  You also need to choose a serial port under Tools –> Port.  You are now ready to upload via Sketch –> Upload

10.   Watch the magic!

Christmas Lights

Attachments

Facebook

30th November

Who wouldn’t jump at the chance to go to the offices that connects more than 1.7 billion people together in an online network?  I certainly did when I received an invite to go to Facebook offices in London.

This sought out opportunity allowed me to experience firsthand what goes on behind the scenes of the largest social networking site.  I was able to hear from a range of departments; from building bridges between clients and customers through advertisement to protecting and caring for user’s data.  I was also fortunate to learn about the latest trend of augmented reality.  This post is an overview of my experience of what I discovered.

cyig6loxaaeompk-jpg-large

Photo taken by Gen Ashley @coderinheels

Solving Business Challenges Through Technology Bruce Hazan, Head of Solutions Engineering in EMEA

Advertisement on Facebook enables connectivity between businesses and their customers. Facebook encourages this behaviour by using Canvas which allows businesses to provide a full-screen experience.  By using Facebook, the advertisements are superior and more engaging as they use inbuilt technology; it also entitles the user to interact with the product being sold by swiping through a carousel, tilting the screen for a panoramic and zooming.

“What would you do if you weren’t afraid?”, Spencer Johnson

A recent retail study by ATKearney mentions that 90% of sales still happen within the physical presence of a shop rather than online which I found to be very surprising.  With this in mind, businesses try to use advertising on Facebook to gauge popularity.  They want to be able to measure their metrics; they want to be able to measure how popular a product might be in advance of footfall so that their supply can meet their demand.  However, the number of times somebody clicks on a Facebook advert is not a very accurate way to measure this.  I was shown the following humorous video that demonstrates this.

One way of being able to generate more online sales is through the use of bots.  Bots inspire brands to create meaningful connections with their consumers in the hope of converting this to a sale.

fullsizerender

An example of a bot used by Nespresso on Facebook

The Importance Of Data, How It Can Improve The Life Of Your End Users Ankita Vimal, Software Engineer

One of the first things that enters my mind when I heard the phrase ‘Protect and Care of Data’ was security.  Security is always a popular news topic of a major international organisation such as Facebook when there has been a breach from hackers.  The thought of your data being leaked to the public is enough to stop you using a service again; this can be detrimental to a company such as Facebook.  However, there are other aspects to protecting and caring of your data such as your privacy settings and being able to report activity.  I was shocked to learn that 75% of reported requests are manually resolved.  I thought this was a significantly high value and not scalable; indeed they have to hire ~5000 people to be able to deal with such requests.

Data driven development also plays a big role at Facebook.  Facebook looks at how the user interacts with their UI by shadowing the movement of the cursor and clicks.  They are also able to get feedback about the user from logging and surveys which provides Facebook with the opportunity to enhance their application accordingly.

“Stay Hungry, Stay Foolish”, Steve Jobs

Bringing Augmented Reality Tech To The Camera in Your Pocket Sammi Krug, Product Manager

Augmented reality readily gets connected with the term wearable technology.  However, this is most certainly not the case at Facebook.  In March 2016, Facebook acquired MSQRD which is an app that produces filters to rival Snapchat’s.  This is a perfect example of augmented reality in your pocket.

MSQRD uses face detection of the eyes, nose and mouth in order to apply an augmented scene around the face.  There are 3 key steps that Sammi mentioned that helped her manage the product:

  1. Decompose the problem

“It’s not complicated, it is just a lot.” This is a phrase that I definitely try to use when tackling a problem.  In terms of augmented reality, the problem is in 3 parts.  There is the 3D object which is the face, there is the high poly mask that is applied to the face and then there is a screen plane that gets placed on top.

2. Play to your strengths

Facebook does this by reaching out to 1.7 billion users on their phones!

3. Look for inspiration everywhere

“Fortune favours the bold”, Cicero

Much like what I saw scattered around the inside of the Facebook building, I have written some of the same motivational quotes on this blog which I found to be inspiring.

© 2019 Lara Nyman

Theme by Anders NorenUp ↑