First of all you need a raspberry pi (next rpi) and raspbian jessie installed on SD card. Raspbian is a kind of OS from the developers of rpi, you can download it for free from official website. After you have installed raspbian, connect your rpi to external monitor via HDMI to see that system boots successfully (this step is not mandatory)
- Connect PI to the power with micro usb port. You can use phone charger or usb of PC.
- Connect PI to your local network with Ethernet cable.
The next step is to find out raspbery's IP address. there are two ways to figure out the IP
If you boot to the command line instead of the desktop, your IP address should be shown in the last few messages before the login prompt.
- Connect rpi to display via hdmi.
- Connect USB keyboard and mouse.
- Using the terminal (boot to the command line or open a Terminal window from the desktop), simply type hostname -I which will reveal your Pi's IP address.
It is possible to find the IP address of your Pi without connecting to a screen using one of the following methods:
In a web browser navigate to your router's IP address e.g. http://192.168.1.1
, which is usually printed on a label on your router;
this will take you to a control panel. Then log in using your credentials, which is usually also printed on the router or sent to you
in the accompanying paperwork. Browse to the list of connected devices or similar (all routers are different), and you should see some
devices you recognise. Some devices are detected as PCs, tablets, phones, printers, etc. so you should recognise some and rule them out
to figure out which is your Raspberry Pi. Also note the connection type; if your Pi is connected with a wire there should be fewer devices
to choose from.
- Open command line.
- Type
arp -a
press enter - You should see a list of all devices in your local network. If rpi is connected it should be here.
The nmap
command (Network Mapper) is a free and open-source tool for network discovery, available for Linux, Mac OS, and Windows.
-
To install on Linux, install the
nmap
package e.g. apt-get install nmap. -
To install on Mac OS or Windows, see the nmap.org download page.
-
To use
nmap
to scan the devices on your network, you need to know the subnet you are connected to. First find your own IP address, in other words the one of the computer you're using to find your Pi's IP address: -
On Linux, type
hostname -I
into a terminal window -
On Mac OS, go to System Preferences then Network and select your active network connection to view the IP address or type
ifconfig
. en0 -> inet should be your IP address. -
On Windows, go to the Control Panel, then under Network and Sharing Center, click View network connections, select your active network connection and click View status of this connection to view the IP address Now you have the IP address of your computer, you will scan the whole subnet for other devices. For example, if your IP address is
192.168.1.5
, other devices will be at addresses like192.168.1.2
,192.168.1.3
,192.168.1.4
, etc. The notation of this subnet range is192.168.1.0/24
(this covers192.168.1.0
to192.168.1.255
).
Now use the nmap
command with the -sn flag (ping scan) on the whole subnet range. This may take a few seconds:
nmap -sn 192.168.1.0/24
Ping scan just pings all the IP addresses to see if they respond. For each device that responds to the ping, the output shows the hostname and IP address like so:
Starting Nmap 6.40 ( http://nmap.org ) at 2014-03-10 12:46 GMT
Nmap scan report for hpprinter (192.168.1.2)
Host is up (0.00044s latency).
Nmap scan report for Gordons-MBP (192.168.1.4)
Host is up (0.0010s latency).
Nmap scan report for ubuntu (192.168.1.5)
Host is up (0.0010s latency).
Nmap scan report for raspberrypi (192.168.1.8)
Host is up (0.0030s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.41 seconds
Here you can see a device with hostname raspberrypi has IP address 192.168.1.8.
Now when you have raspbian installed and you know the correct IP address of your PI we can start development.
First of all open a comand line on your PC or laptop.
enter: ssh pi@<ip-address>
paste rpi's ip instead of <ip-address>
You should see the next picture. Default password is raspberry
. Press enter.
Now you have remote access to raspberry.
- Navigate to appropriate directory on your raspbian system. As example
cd Desktop
. - Clone this repo
git clone https://github.com/yaroslav0507/PWO_Hardware.git
. - Enter project directory
cd PWO_Hardware
.
We need to build bcm2835
driver to use DHT sensor.
bcm2835
is the Broadcom chip used in the Raspberry Pi 2 Model B
The underlying architecture in BCM2836 is identical to BCM2835. The only significant difference is the removal of the ARM1176JZF-S processor and replacement with a quad-core Cortex-A7 cluster.
Execute next commands in console to get and build driver
- wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.49.tar.gz
- tar xvfz bcm2835-1.49.tar.gz;
- cd bcm2835-1.49;
- ./configure;
- make;
- sudo make install
Now when driver is installed, we can install Node dependencies. Get back to the project directory cd ..
.
Type npm install
;
Node Package Manager should install next dependencies automatically
- johnny-five - robotics framework
- node-dht-sensor - humidity and temperature sensor middleware
- express - simple node.js server
- socket-io - WebSockets middleware for instant data transfer to the web client
- dotenv - middleware that allows you to provide environment variables, such as server port or critical humidity value
Congrats. You've install all required dependencies and can process to next step.
Now we can wire up all devices and mount them on raspberry.
In my case I used Turnigy™ TGY-390DMH High Performance DS/MG Servo
5.4kg / 0.11sec / 22.5g
Specification:
- Weight: 22.5 grams / 0.79 oz.
- Dimensions: 29 x 13 x 30 mm / 1.14 x 0.51 x 1.18 inch
- Torque @ 4.8V: 4.6 kg/cm , 64 oz/in
- Torque @ 6.0V: 5.4 kg/cm , 75 oz/in
- Speed @ 4.8V: 0.14sec / 60 deg at no load
- Speed @ 6.0V: 0.11sec / 60 deg at no load
- Connect the pilot wire (it is always orange or yellow) to the 12th pin of GPIO.
- Connect red (power) wire to the second pin of GPIO (5v.)
- Connect brown wire (ground) to the 0v.
I used 3 pin AM2302 sensor. You can use DHT22, the are almost same. Here are technical characteristics.
- Model DHT22
- Power supply 3.3-6V DC
- Output signal digital signal via single-bus
- Sensing element Polymer capacitor
- Operating range humidity 0-100%RH; temperature -40~80Celsius
- Accuracy humidity +-2%RH(Max +-5%RH); temperature <+-0.5Celsius
- Resolution or sensitivity humidity 0.1%RH; temperature 0.1Celsius
- Repeatability humidity +-1%RH; temperature +-0.2Celsius
- Humidity hysteresis +-0.3%RH
- Long-term Stability +-0.5%RH/year
- Sensing period Average: 2s
- Interchangeability fully interchangeable
- Dimensions small size 14185.5mm; big size 22285mm
- Connect ground wire (Brown) to the 0v. pin 25th for example.
- Connect power wire (red) to the 17th pin of GPIO.
- Connect the pilot wire (orange) to the 7th pin of GPIO.
You have to install Wiring Pi to have a posibility of GPIO pins configuration.
Now you can configure pins mode with a command gpio mode <pin> in/out/pwm/clock/up/down/tri
Example: gpio mode 7 in
.
`