We are Excited to Get our Pi Zero Model W Up and Running
We have our Raspberry Pi Zero Model W booted up and running. Our interest is to run the device headless, but we must first discover our IP address. This lesson shows a simple tutorial on how to Boot the Pi Zero Model W, and get its IP address. Once you get the IP address, you will want to reserve that IP address for this device. You can do that through your wireless router, or if you are at work, talk to your Network Administrator. We plan to do a really cool project with this, so get your gear ordered now. The best deal we have found that has the two adapters you need can be ORDERED HERE.
This video takes you through setting up your Pi zero W step by step. Enjoy!
In this lesson we give you a step by step tutorial on how to create a low cost IP camera from a Raspberry Pi and the Raspberry Pi camera module. (If you need to get a Raspberry Pi and Camera Module, we recommend this complete starter Kit, which you can order HERE. If you already have a Raspberry Pi, and just need a camera, you can get the camera module HERE.) We are going to assume you already have your Raspberry Pi up and running, and are able to make a connection to it via Putty or SSH. If you are completely new to the Raspberry Pi, you should probably start with the first two lessons on THIS PAGE.
This video will take you through the steps one at a time. In addition, the tutorial below has the commands that you can copy and paste. We recommend you both follow the video, and get the steps from the instructions below, so you do not have to manually type the commands. Be very careful . . . you must be precise in following these instructions for things to work.
OK, now assuming you have your Raspberry Pi up and running, and you can connect via Putty or SSH, These are the steps to get your dandy personal IP camera working. You will type or copy and paste these lines one at a time into the Raspberry Pi command line.
Now you will want to type or paste this info into the nano window.
Apache
1
<?phpphpinfo();?>
STEP 5: Save your nano file with these key strokes:
Arduino
1
2
3
CtrlO
Enter
CtrlX
To be clear, you press the Control key and the letter “O” at the same time. Then press the enter key. Then press the Control and “X” key at the same time.
STEP 6: Restart the Webserver:
Apache
1
sudo/etc/init.d/lighttpdrestart
STEP 7: Check That the WEB Server is Working:
Go to a browser on a Windows computer on your network, and type:
http://10.1.15.94/
(NOTE: You would use your Pi’s IP address above. The number I use above is the IP address of our Pi. Your number will be different. You can find out your IP address on the pi by typing ifconfig into the terminal window.)
If you configured things correctly, you should get an Apache info page pop up.
Also, you should be able to see your php information page by entering:
http:/10.1.15.94/php.php
Again, you should use your IP address. If you did things correctly you should have a page come up with lots of tables describing php configuration
To be clear, you press the Control key and the letter “O” at the same time. Then press the enter key. Then press the Control and “X” key at the same time.
STEP 13: Restart crtmpserver
Apache
1
sudo/etc/init.d/crtmpserverrestart
STEP 14: Remove ffmpeg
We need to make sure we have a clean copy of ffmpeg, so safest thing to do is un-install it in case an old version is on your pi.
Apache
1
sudoaptituderemoveffmpeg
STEP 15: Intall Latest git-core and ffmpeg software
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
readonly=yes
# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
createmask=0700
# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directorymask=0700
# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
validusers=%S
# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
;comment=NetworkLogonService
;path=/home/samba/netlogon
;guestok=yes
;readonly=yes
[home]
path=/
public=yes
readonly=no
writeable=yes
browseable=yes
createmask=0777
directorymask=0777
# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
;comment=Usersprofiles
;path=/home/samba/profiles
;guestok=no
;browseable=no
;createmask=0600
;directorymask=0700
Now save and exit the nano editor with:
Ctrl O
Enter
Ctrl X
At this point, your Raspberry Pi should show up on your Windows computer network on your windows machine. On your windows machine, open a folder, click on “network” on the left, and you should see your raspberry pi show up. Now you can move files to and from your Raspberry Pi from Windows.
STEP 19: Install Strobe Software and WEB Page:
We will want to be able to view the live video stream in a browser, so we need to install the Strobe software. These next steps will install and enable the strobe feature.
Apache
1
cd/var/www/html
Arduino
1
sudomkdirstrobe
Arduino
1
sudochmod-R777strobe
Now the easiest way to get the strobe software is to download it on a windows computer. You can get the software by going to:
and downloading the latest version of strobe media playback.
Now open the zipped folder and drag and drop the folder “for Flash Player 10.1” to your desktop.
Now move the CONTENTS of the unzipped “for Flash Player 10.1” folder onto your Raspberry Pi. You will want to move the CONTENTS of “for Flash Player 10.1” folder into the /home/var/www/html/strobe folder on your Raspberry Pi. If you installed Samba correctly, the Raspberry Pi should show up when you open a folder in Windows and click on “Network”.
Now you have the strobe software installed and you need to create a Strobe WEB page to display your live video.
First, make sure you are in the html folder by typing:
Apache
1
cd/var/www/html
On your raspberry pi, now issue the command:
Apache
1
sudonanoindex.html
Now paste this code into your Nano window. You can paste by copying the code below, and then going to your Raspberry Pi command Window, and right mouse clicking.
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Now you should save and exit nano with these commands:
Arduino
1
2
3
CtrlO
Enter
CtrlX
To be clear, you press the Control key and the letter “O” at the same time. Then press the enter key. Then press the Control and “X” key at the same time.
STEP 20: Enable Raspbery Pi Camera Module:
At the command line enter:
Apache
1
sudoraspi-config
Scroll down and enable the camera.
STEP 21: Start the Camera:
You are now ready to fire up the camera. You can start the camera by issuing this command in the Raspberry Pi command window.
Beaglebone Black connected to the Adafruit Ultimate GPS
If you went through our series of 12 lessons on the Beaglebone black you should be familiar with the basics of this microcontroller. We are now ready to move on to more advanced projects. In our earlier lessons on the Arduino, we built a GPS data logger and integrated it with Google Earth using the Arduino Uno and the Adafruit Ultimate GPS Breakout Board. While that was a great project, we finally ran out of horsepower with the arduino, and what we could do was limited by the memory limitations on the Arduino. Also, it is very hard to parse strings in the Arduino IDE, so interpreting the NMEA sentences is a rather large challenge with the limited string functionality in Arduino.
Python on the other hand makes quick work of string manipulation and the Beaglebone Black has plenty of horsepower for any manipulation of the NMEA sentences we might want to do.
In order to play along with this project, you will need a Beaglebone Black Rev C, which you can get HERE, and the Adafruit Ultimate GPS which you can get HERE. The video below takes you through the project step-by-step, as well as the description below.
Once you get your gear, you will want to hook up the following circuit:
Adafruit Ultimate GPS connected to the Beaglebone Black Rev C Microcontroller
Note that we are working off header P9 and we are using P9_1 as ground, P9_7 as VIN, we are using P9_24 as Tx and P9_26 as Rx. Please note that you can see a detailed Diagram of the Beaglebone Black pinout HERE. Also notice that Tx on the Beaglebone is connected to Rx on the GPS, and Rx on the Beaglebone is connected to Tx on the GPS. Tx is like “talk” and Rx is like “listen, so you want to listen to the pin that is talking, and you want to talk to the pin that is listening.
Our goal in this first lesson is to establish a connection between the GPS and the Beaglebone, and to read in the data streaming from the GPS. We want to get a fix, and verify that we can read and print the NMEA sentences that contain the various position, altitude and velocity data.
The video takes you step-by-step through the code. The following simple code will get you streaming data from the GPS to your terminal window. In future lessons we will break the data down and show you how to get your position from the raw NMEA sentences streaming in.
If you went through our series of lesson on the Raspberry Pi, you will remember that we found the major limitation of the Pi is that it has no analog input pins. Luckily, the Beaglebone Black as a number of analog input pins, so we can greatly expand the scope of projects we can do. The pinout below shows the pins that are available on the Beaglebone Black for analog input. (If you do not already have your Beaglebone Black, you can pick one up HERE.)
Default Pin Configuration for the Beaglebone Black Rev. C.
You can see the blue shaded pins in the diagram above are for analog input.
A couple of very important points. These pins are designed to read analog voltages between 0 and 1.8 volts. Applying voltages above 1.8 volts can burn out the pin, or even smoke the Beaglebone. Hence, as you set up voltage divider circuits you must ensure they have a rail of 1.8 Volts, to ensure that the analog in pins will never see more than 1.8 Volts. Luckily, the Beaglebone provides a handy 1.8 Volt reference signal on pin 32 (on P9 header). Always use pin 32 as your reference rail when working with analog inputs. Similarly, you should use pin 34 (on P9 header) as your reference ground on your analog input circuits.
To demonstrate how to do analog reads, we will set up a simple voltage divider using a potentiometer. Go ahead and hook up your circuit as follows:
A Simple Voltage Divider Using a Potentiometer
Note we are using P9_32 as the reference voltage on the voltage divider, we are using P9_34 as the reference ground, and we are using P9_33 as the analog sense pin.
With this circuit hooked up we are ready to develop some code. In the attached video we take you through this program step-by-step to show you how you can make analog readings from the potentiometer using python.
Python
1
2
3
4
5
6
7
8
9
importAdafruit_BBIO.ADC asADC
ADC.setup()
fromtimeimportsleep
analogPin="P9_33"
while(1):
potVal=ADC.read(analogPin)
potVolt=potVal*1.8
print"The Potentiometer Voltage is: ",potVolt
sleep(.5)
Note the analog read returns a number between 0 and 1, which is proportional to the applied voltage. Hence to convert to actual voltage, we multiply this read value by 1.8 Volts.
In Lesson 4 and Lesson 5 we showed how to do digital writes to the GPIO pins using Python. (If you have not picked up your Beaglebone Black Rev. C yet, you can get one HERE) With digital writes, we could generate an output of 3.3 volts or 0 volts. For many applications, we would like analog output, or the in between voltages. The Beaglebone Black, as with most microcontrollers, can not produce true analog output. However, for many applications, an analog output can be simulated by creating a fast on/off sequence where the analog value is simmulated by controlling the ratio of on time and off time. This technique is called Pulse Width Modulation, or more simply, PWM. Consider a 3.3 volt signal, which is turning on and off with a frequency of 50 Hz. A 50 Hz signal has a Period of: Period=1/frequency=1/50=.02 seconds, or 20 milliseconds. If during that 20 millisecond period, the signal was “High” for 10 milliseconds, and “Low” for 10 milliseconds, the signal would act like a 1.65 volt analog signal. The output voltage therefor could be considered the rail voltage (3.3 volts) multiplied by the duty cycle (percentage of time the signal is high.
For the Beaglebone Black, only certain pins can be used for PWM signals.
Default Pin Configuration for the Beaglebone Black Rev. C.
In the chart above, the purple pins are suitable for PWM output. You can see there are 7 pins which can produce PWM signals. In this lesson we show you how to control those pins.
In order to control PWM signals, we are going to use Python and the Adafruid_BBIO Library. Recent versions of Beaglebone Black Rev. C are shipped with the library already part of the operating system. If you are getting errors indicating that you do not have the library, update your operating system to the latest Debian image for the Beaglebone Black.
In order to use PWM in Python, you must load the Adafruit Library. If you have the recent versions of Debian Wheezy for the Beaglebone black, the library will already be on your system. If you do not do an update and upgrade on your operating system.
To begin with, you will need to load the library.
Python
1
importAdafruit_BBIO.PWM asPWM
Next up, you will need to start the PWM on the pin you are using. We will use pin “P8_13”. Remember you must use one of the purple colored pins on the chart above. We start the PWM with the following command:
Python
1
PWM.start("P8_13",25,1000)
This command puts a 1000 Hz signal (Period of 1 mSec) on pin P8_13, with a duty cycle of 25%. This should yield a simulated analog voltage of .84 volts.
We can change the duty cycle after this initial setup with the command:
Python
1
PWM.set_duty_cycle("P8_13",90)
This command would change the duty cycle to 90%, which would simulate a voltage of 3.3 * .9 = 2.97 volts.
You can also change the frequency of the signal using the command:
Arduino
1
PWM.set_frequency("P8_13",100)
This would change the frequency to 100 Hz (Period of 10 mSec). Changing the frequency does not really affect the net result of PWM in most applications, although it does matter for many servo applications.
After you are done, you can stop the PWM with the command:
Python
1
PWM.stop("P8_13")
And always remember to clean up after yourself with:
Arduino
1
PWM.cleanup()
Play around with the Python Program below. Connect a DVM to your Beaglebone Black, and measure the DC voltage at the output pin. The DVM should show your anticipated voltages.
Python
1
2
3
4
5
6
7
8
importAdafruit_BBIO.PWM asPWM
myPWM="P8_13"
PWM.start(myPWM,0,1000)
foriinrange(0,5):
DC=input("What Duty Cycle Would You Like (0-100)? ")
PWM.set_duty_cycle(myPWM,DC)
PWM.stop(myPWM)
PWM.cleanup()
Considering that the simulated analog voltage V=3.365 X Duty Cycle, how would modify the program above to ask the user for the Voltage he desires, and then calculate the duty cycle that would give that voltage. Your assignment is to modify the program above where the user inputs desired voltage, and DC is calculated. Use a DVM to check your results
Making The World a Better Place One High Tech Project at a Time. Enjoy!
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.