Monthly Archives: September 2013

Seg 5: wifi association and authentication

  1. Radio hosts connect to AP
  • Listening beacon frame sent by AP
    • AP send periodically beacon frame
    • Including the SSID and MAC of AP
  • Scanning 14 channels, and select an AP to associate by 802.11 association protocol
    • After association, means that radio hosts join the sub networks of the chosen AP
    • By possibly utilizing DHCP, radio host rents IP address from AP
    • Generally speaking, radio hosts choose an AP having the strongest signal beacon frame to associate.
  1. Scanning methods
  • Passive scanning, shown in Figure 1-7.
    • AP(s) periodically send beacon frame , the host scans 14 channels to find the all the possible beacon frames from APs at the location;
    • The host sends the request frame to the selected AP ②;
    • AP send the response frame to the host ③;


Figure 1-7 Passive scanning

  • Initiative scanning, shown in Figure 1-8.
    • The radio host broadcasts the request frame to AP ①;
    • APs send probe response ②;
    • The radio host sends the association request frame to the chosen AP ③;
    • The chosen AP sends the association response frame .


Figure 1-8 Imitative scanning

  1. Authentication
  • When Associated, the radio host may need to authenticate itself by authentication/identification mechanism;
  • By MAC address to authenticate
  • By user name/password to authenticate
  1. CSMA/CA and CSMA/CD
  • Base station should be full duplex for the ability of collision detection, which requires it have the ability to receive and send at the same time. However, the received signal strength is far less than the sent signal strength for WLAN adapter, which would consume too much energy to realize the collision detection. Therefore, most of wireless devices are generally half duplex.
  • Not all WLAN devices can detect the collision because of hidden terminals and attenuation, etc.
  • During the sending frame, if collision is detected, then base station don’t give up the sending frame, but finish sending the whole frame. Thus, if collision happens, in this time, the channels would be wasted.
  • Because the high bit error rate (BER), the sender would firstly transmit a frame to the receiver. After received it, the receiver would transmit a confirm frame to the sender in the SIFS period; then, after the sender receive this confirm frame, it would transmit the next data frame to receiver. If the sender don’t receive the confirm frame, it would retransmit the frame for several times.

Seg 4: wifi architectures

As for 2.4GHz, there are 14 channels. Each has 22MHz bandwidth, which is shown in Figure 1-3. Evidently, only channel 1,6,11 are the channels which are not intertwined each other.



Figure 1-3 wireless channel

  1. Wi-Fi architecture


    Figure 1-4 Infra networks

    Wi-Fi has two main modes: Infra and Adhoc networks

    1. Infra networks
      1. Minimum element: BSS (Basic Service Set), shown in Figure 1-4.
  • One or more radio hosts;
  • AP: Access Point, i.e., BS (Base Station)
  • Radio hosts communicate with the outside by AP
  • Inter-connection among APs by the inter-connection with Hub/Switch /Router
  1. SSID (Service Set Identification)
  • Manager assigns a SSID less than 32 bytes for an AP;
  • A BSS can exist lonely. It can also be connected to another BSS by the connection with DS (Distribution System) for the constitution of ESS.
  1. ESS (Extension Service Set)

ESS is composed of several APs and DS. All of the APs share an ESSID, and an ESS can include several BSS, as shown in Figure 1-5.


Figure 1-5 ESS

  1. DS (Distribution System)
  • Distribution System, which is used to the logical connection BSS, and provide the roam distribution system for the wireless APs.
  • When DS is used, then all of the BSSes seem like a BSS in a BSS.
  • DS is usually denoted by Ethernet, point-to-point link or other wireless networks.
  1. Adhoc networks
  • No AP center control
  • Generally no connection to the outside networks


Figure 1-6 Adhoc networks

Seg 3: wifi features and frequency band

  1. Features of Wifi
  • Constitution of network is flexible. It can be infrastructure mode, or a self-organizing mode;
  • Mature technology and rich application;
  • Low price devices;
  • Low power, small recover range;
  • Woring at the frequency 2.4GHz, which is the same as IMS (Industrial/Medical/Scientific). Thus, it may be relatively easy to be interfered. Moreover, Microwave ovens, and cordless phone are also working at IMS frequency.
  1. Wireless frequency band

ISM frequency band is reserved for the Industrial/ Scientific / Medical use, which is specialized by FCC. Nowadays, most countries all over the world open this frequency band by following this standard. But the ISM frequency is not unified in these countries. We cannot be allowed to use these frequency bands, i.e., 900MHz, 2.4GHz, 5.7GHz; but the transmitted power must be lower the specialized power (generally lower 1W) and the utilized frequency cannot interfere with other frequencies. At present, most of the wireless products are working at 2.4GHz. And the 802.11 protocol families are shown in Table 1-1.

Table 1-1 Wireless Frequency

802.11b

802.11a

802.11g

802.11n

Release time

Sept. 1999

Sept. 1999

June. 2003

Jan. 2004

frequency

2.4Ghz

5Ghz

2.4Ghz

2.4Ghz5Ghz(2.4Ghz or/and 5Ghz

modulation

CCK/DSSS

OFDM

CCK/OFDM

MIMO OFDM

range

About 100m

About 50m

<100m

Several Km

Max rate

11Mbps

54Mbps

54Mbps

600Mbps

compatible

11g

Not with 11b/g

11b

11b/a/g

 

Seg 2: Wifi history

  • In 1996, Lucent in America firstly launched to set up Wireless Ethernet Compatibility Alliance (WECA), which aimed at the wireless local area networks (WLAN).
  • In 1999, WECA was renamed as Wi-Fi alliance, which would design an approval standard again. In this case, the alliance presented a series of wireless networks technology 802.11 in wireless communication, such as 802.11b, 802.11a, 802.11g, 802.11n, and so on.
  • Wi-Fi alliance committed itself to generate the 802.11 products and to solve the compatible problems. Note that, 802.11 is not denoted the wireless network. It is just one of the wireless networks.
  • Wireless Local Area Network can be abbreviated as WLAN. By this wireless communication technology, all the computer devices, pda, mobile phone and other many connectable devices, could communicate with each other by the wireless networks. Furthermore, if we use the wireless communication networks, all of the devices can be connected each other with no cable. It is would be much more mobile and flexible. Fortunately, wifi is the kind of wireless networks technology.


    Figure 1-2 wireless communication networks

  • Difference between Wifi, bluetooth, and ZigBee: bluetooth (BLE) is one of the WPAN (Wireless Personal Area Networks) technology, while wifi belongs to WLAN (Wireless Local Area Networks) technology. The two technologies can provide the different wireless networks services. Moreover, there exists an entitative difference for the realization of the two technologies.
  • The effects of WIFI radiation on human body: general speaking, the transmission power is much weaker than that of the mobile phone. For example, the transmitted power is about 60~70mW, while for mobile phone, the power is 200mW or so. What is more, wireless cannot directly touch the people tissue, but mobile phone must. So, the power to body is less than 1mW, and thus can be ignored.

Seg 1: What is wifi

  1. Problem presentation: know Wi-Fi

In the basic part of Arduino, we have known Arduino to some extent. From this part, we will come to learn the knowledge on the combination of Arduino and wireless communication, which can promote us interact with Arduino. In the first chapter, we will simply get at the relevant concepts and basic knowledge about Wi-Fi (which is also written as wifi) to prepare the future work.

  1. What is wifi

WIFI is the abbreviation of Wireless Fidelity, which is a technology working in the vicinity of the frequency 2.4/5GHz. Its velocity is relative high, and the distance is relative long. Moreover, it is compatible with the existing 802.11 DSSS devices. DSSS (Direct Sequence Spread Spectrum) is a wireless sequence transformation way with high security and anti-interference. DSSS can extend the signal spectrum at send end by utilizing the high velocity spread sequence. Naturally, at the receive end, by using the decoding with the same spread spectrum code sequence, the extended signal can restore to the original signal. This is the principle of direct sequence spread spectrum (DSSS). Wifi can be read as [waifai]. The wireless router shown in Figure 1-1 is already used the wireless communication technology, i.e., wifi.


Figure 1-1 Wi-Fi wireless router

Seg 5: Schematic diagram and experiment of LM35

  1. Schematic circuit

By the connection diagram shown in Figure 8-2, this experimental schematics is easily draw in Figure 8-3. Note that, we should design the circuit by the pin connection of temperature sensor.


Figure 8-3 Schematic circuit


8-4 Circuit diagram

  1. Code

Run Program 8.

01 // Program 8: use sensor to measure your environmental temperature
02 
03 void setup() {
04  
05   Serial.begin(9600);         //set the baud for serial communication
06 }
07  
08 void loop() {
09  
10   int n = analogRead(A0);    //read the voltage from A0
11  
12   float vol = n * (5.0 / 1023.0*100);   //computation of temperature
13  
14   Serial.println(vol);                   //output temperature
15   delay(2000);                           //wait for 2s for display
16 }

Open the serial monitor on the Arduino software platform, we can see the Celsius temperature sensed by the temperature sensor LM35. Note that, the baud of monitor should be the same as the above code, which can be seen in Figure 8-5.


Figure 8-5 the temperature value on the Arduino monitor

From Figure 8-5, we know that the environmental temperature is about 24.44 in this experiment.

  1. Key points and summaries
  2. We should know the features about the temperature sensor. For example, in such experiment, the temperature of LM35 is linearly proportional to the voltage. By this relationship, we can get the formula about the temperature and voltage.
  3. We should the connection about the sensor logs. As for LM35 in this experiment, let the full-face having characters facing us. Then the left is connected to 5V port on the Arduino board, the right leg is a GND port, which should connect to the GND port on Arduino board, and the middle leg should connect to the analog port on the Arduino board, which can output the concrete value about temperature.
  4. The output temperature value can be seen on the serial monitor. But, the baud for the monitor should be unanimous with the baud set in the experimental code.

Seg 4: Experimental principle of LM35

  1. Experiment and code
    1. Experimental principle

The principle of such experiment is very simple. The voltage data is sensed by the temperature sensor LM35, which would be sent to the analog port (A0 is used in this experiment) on the Arduino board. Then the Celsius (Centigrade) temperature can be output by the linear relationship between the voltage and temperature. For example, in this experiment, we know the linear relationship for the temperature LM35 by one Celsius temperature/10mV. Thus, we can get the voltage value n from the analog port A0 connected LM35 on the Arduino board. Not that, the data n is discrete and located on the range of 0~1024. So, we should change the discrete data n into a continuous voltage to get the Celsius temperature. In fact, the computation is simple. We know that, as for the analog ports A0~A5, the value range is 0~1024, and 1024 is corresponding to 5V. Therefore, if we know the value in A0 port, then we can obtain the discrete voltage value within 0~1024; i.e., the value is n. Then, we can compute the Celsius temperature. Assume that the continue voltage in port A0 on Arduino board is denoted by U. Then, we have the following compute formula by the principle A0 and the linear relationship between Celsius temperature and the continuous voltage.

,

where vol is the Celsius temperature we should compute, n can be achieved from analog port A0 on the Arduino. Therefore, we can compute the continuous voltage in A0 by equation (1). Then, we substitute the U into equation (2), the Celsius temperature can thus be obtained. In addition, the value of vol (i.e., Celsius temperature) could display on the serial monitor on the Arduino software platform.


Seg 3: Diagram of LM35

model

package

Temperature range

Deposit temperature

LM35CZ

TO-92

-40~+110

-60~+150

LM35CAZ

TO-92

-40~+110

-60~+150

LM35DZ

TO-92

0~+100

-60~+150

LM35H

TO-46

-55~+150

-60~+180

LM35AH

TO-46

-55~+150

-60~+180

LM35CH

TO-46

-40~+110

-60~+180

LM25CAH

TO-46

-40~+110

-60~+180

LM35DH

TO-46

0~+100

-60~+180

LM35DM

SO-8

0~+100

-65~+150

  1. Parameters and shapes (top view)



  1. Mental package (b) molded package



(c) plastic package (d) plastic package

Figure 8-1 Top view of temperature sensor

Limited parameters

Power voltage

Output voltage

Output current

+35V~0.2V

+6V~1.0

100mA

  1. Temperature sensor physical shape and connection


    Figure 8-2 Physical shape for temperature sensor

    Before connected to the circuit, we should know the connection to the pins on the Arduino board for the temperature sensor LM35, seen in Figure 8-2. Firstly, let the full-face (having characters) facing us. Then, the left log is Vcc and should be connected to the 5V port on the Arduino board; the right log is GND, which can be connected to the GND on the Arduino, and the middle one is output voltage, which is connected to the analog port on the Arduino board, A0 is chosen in such experiment.

Seg 2: Features of temperature sensor LM35

  1. Be familiar with temperature sensor

According to the output signal modes, it can be divided into 3 types: digital temperatures, logic output temperature, and analog temperature. In such experiment, the LM35 series sensors is a precise integrated circuit temperature sensor on the development of LM135. Its output voltage is proportional to the centigrade temperature linearly.

Thus the LM35 make interfacing to readout or control circuitry especially easy. The device is used with single power supplies, or with plus and minus supplies. As the LM35 draws only 60 μA from the supply, it has very low self-heating of less than 0.1°C in still air. The LM35 is rated to operate over a −55°C to +150°C temperature range, while the LM35C is rated for a −40°C to +110°C range (−10° with improved accuracy). The LM35 series is available packaged in hermetic TO transistor packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface-mount small outline package and a plastic TO-220 package.

Features

Calibrated Directly in Celsius (Centigrade) temperature sensors, with an output voltage linearly

Linear + 10 mV/°C Scale Factor proportional to the Centigrade temperature. Thus the

0.5°C Ensured Accuracy (at +25°C) LM35 has an advantage over linear temperature

Rated for Full −55°C to +150°C Range sensors calibrated in ° Kelvin, as the user is not

Suitable for Remote Applications required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The

Low Cost Due to Wafer-Level Trimming LM35 does not require any external calibration or

Operates from 4 to 30 V trimming to provide typical accuracies of ±¼°C at

Less than 60-μA Current Drain room temperature and ±¾°C over a full −55°C to

+150°C temperature range. Low cost is assured by

Low Self-Heating, 0.08°C in Still Air trimming and calibration at the wafer level. The low

Nonlinearity Only ±¼°C Typical output impedance, linear output, and precise inherent

Low Impedance Output, 0.1 W for 1 mA Load calibration of the LM35 make interfacing to readout or control

Seg 1: how to use Arduino and temperature sensor to measure your environment temperature

8.1 Problem description: how to use Arduino and temperature sensor to measure your environment temperature

Temperature is closely associated with our lives, especially our journeys. In such experiment, we would use temperature sensor on the basis of Arduino board. In the later experiments, we would submit these sensed temperature data to the web server and then process. Then, we can look for many cities’ temperature. In fact, there are many similar sensors, like smoke sensor. The photoresistor is also a sensor in the 7th experiment.

8.2 Hardware and software

The required hardware is relative simple. we can replace the photoresistor by temperature on the 7th experiment, as shown in Table 8-1.

Table 8-1: The required materials

Number

Name Quality Function Note

1

Arduino software 1 suit Provide ide New ver 1.05

2

Arduino UNO board 1 Control board Many

3

USB data line 1 Connect board distribution

4

Dupont line 2 Connect elements

5

Temperature sensor 1 Measure temperature

7

Bread board Connection