How to Use Linkit 7697 to Establish Intelligent Temperature Monitoring Platform

After the rise of the Internet of Things, MediaTek Labs has focused on four key technical areas of the Internet of Things: wearable devices, smart homes, smart positioning and M2M. And MediaTek continues to innovate a variety of system-on-chip (SoCs) to improve processing power in order to apply to more complex situations in the Internet of Things.Especially in the application of smart home technology, security, power, customization and convenience of different development chips, to solve multi-oriented issues, but also it provides a secure Wi-Fi communication capabilities, and the establishment of security mechanisms to connect with the Internet and a variety of peripheral connections of the cloud platform in series.\

The previous generation of Linkit Smart 7688 / DUO both the server and the client's powerful features and easy to use development environment,it is a highly accepted version of a development board now. However, many Maker require small, fast, and poorly functioning, purely client-side development boards, when building networking devices. Finally, MediaTek Labs re-launched Linkit 7697 this development board, so that Maker can quickly develop a meet the needs of the Internet of things device.

In the intelligent home networking technology, home temperature monitoring isn't only the most basic,but also the most critical core technology, because people-centered smart home, is committed to creating a comfortable environment,and comfort often depends on the temperature of the feelings,So this article uses Linkit 7697 development board to establish the Internet temperature and humidity monitoring station, so that all members of the family through the Internet to get fast, correct temperature and humidity information.

Connect the Linkit 7697 development board to the Internet

We're going to teach you how to get MAC information.

First of all, the Linkit 7697 development board driver installed (refer to [Tutorial] LinkIt 7697 three development environment, easy to use! ), we have to open the Linkit 7697 development board development tools: Arduino IDE integrated development software, and write a program (as shown in the table below), so you can through the LinkIt 7697 development board module, MAC data.

As shown in the following figure, the reader can see this experiment - to obtain the MAC data test program results screen.

Connect to the wireless base station via WiFi module

By integrating these programs, we can easily access MAC data, and next we'll teach readers how to connect to a Access Point.Open Arduino IDE integrated development software, and write test programs that connect wireless base stations (as shown in the following table), so we can connect to the Access Point through the LinkIt 7697 development board.

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:

status = WiFi.begin(ssid, pass);

// status = WiFi.begin(ssid);

// wait 10 seconds for connection:

delay(2000);

}

Serial.print(“\n Success to connect AP:”) ;

Serial.print(ssid) ;

Serial.print(“\n”) ;

}

void printWifiData() {

// print your WiFi shield’s IP address:

IPAddress ip = WiFi.localIP();

Serial.print(“IP Address: “);

Serial.println(ip);

Serial.println(ip);

// print your MAC address:

byte mac[6];

WiFi.macAddress(mac);

Serial.print(“MAC address: “);

Serial.print(mac[5], HEX);

Serial.print(“:”);

Serial.print(mac[4], HEX);

Serial.print(“:”);

Serial.print(mac[3], HEX);

Serial.print(“:”);

Serial.print(mac[2], HEX);

Serial.print(“:”);

Serial.print(mac[1], HEX);

Serial.print(“:”);

Serial.println(mac[0], HEX);

}

void printCurrentNet() {

// print the SSID of the network you’re attached to:

Serial.print(“SSID: “);

Serial.println(WiFi.SSID());

// print the MAC address of the router you’re attached to:

byte bssid[6];

WiFi.BSSID(bssid);

Serial.print(“BSSID: “);

Serial.print(bssid[5], HEX);

Serial.print(“:”);

Serial.print(bssid[4], HEX);

Serial.print(“:”);

Serial.print(bssid[3], HEX);

Serial.print(“:”);

Serial.print(bssid[2], HEX);

Serial.print(“:”);

Serial.print(bssid[1], HEX);

Serial.print(“:”);

Serial.println(bssid[0], HEX);

// print the received signal strength:

long rssi = WiFi.RSSI();

Serial.print(“signal strength (RSSI):”);

Serial.println(rssi);

// print the encryption type:

byte encryption = WiFi.encryptionType();

Serial.print(“Encryption Type:”);

Serial.println(encryption, HEX);

Serial.println();

}

void ShowMac()

{

Serial.print(“MAC:”);

Serial.print(MacAddress);

Serial.print(“\n”);

}

String GetWifiMac()

{

String tt ;

String t1,t2,t3,t4,t5,t6 ;

WiFi.status(); //this method must be used for get MAC

WiFi.macAddress(mac);

Serial.print(“Mac:”);

Serial.print(mac[0],HEX) ;

Serial.print(“/”);

Serial.print(mac[1],HEX) ;

Serial.print(“/”);

Serial.print(mac[2],HEX) ;

Serial.print(“/”);

Serial.print(mac[3],HEX) ;

Serial.print(“/”);

Serial.print(mac[4],HEX) ;

Serial.print(“/”);

Serial.print(mac[5],HEX) ;

Serial.print(“~”);

t1 = print2HEX((int)mac[0]);

t2 = print2HEX((int)mac[1]);

t3 = print2HEX((int)mac[2]);

t4 = print2HEX((int)mac[3]);

t5 = print2HEX((int)mac[4]);

t6 = print2HEX((int)mac[5]);

tt = (t1+t2+t3+t4+t5+t6) ;

Serial.print(tt);

Serial.print(“\n”);

return tt ;

}

void ShowInternetStatus()

{

if (WiFi.status())

{

Meip = WiFi.localIP();

Serial.print(“Get IP is:”);

Serial.print(Meip);

Serial.print(“\n”);

}

else

{

Serial.print(“DisConnected:”);

Serial.print(“\n”);

}

}

// MISC Function

String print2HEX(int number) {

String ttt ;

if (number >= 0 && number < 16)

{

ttt = String(“0”) + String(number,HEX);

}

else

{

ttt = String(number,HEX);

}

return ttt ;

}

As shown in the following figure, the reader can see test program results screen of the connection to the wireless base station , you can successfully connected to the wireless base station (Access Point), and through the DHCP server to obtain the network address, and can display the gateway, Mask and other information. Connect the wireless base station test program results screen.

Assembly temperature and humidity module circuit

As shown in the following figure,we need to use the experimental hardware has the following figure (left) LinkIt 7697 development board, the following figure (middle) MicroUSB download line, the following figure (right) Microphone module on this step .

As the Linkit 7697 development board using ARM Cortex-M4 MCUmicroprocessor, in order to be able to Arduino IDE development environmentcompatible, I refer to the original LinkIt 7697 development board officialwebsite, as shown below, we understand that P0 ~ P13 corresponds to Arduinodevelopment board digital pin: D0 ~ D13, so we can pick up the DHT22temperature and humidity module, the data output pin received P8 (D8), completethe circuit.

The reader can refer to the temperature, humidity, circuit diagram and pin list as shown below.

Temperature and humidity module circuit diagram

Temperature and humidity module foot table

For the reading of temperature and humidity modules, please refer to the author of the article"Arduino program (temperature and humidity module): Arduino Programming (Temperature & Humidity Modules)"(Cao Yongzhong, Xu Zhicheng, & Cai Yingde, 2016a, 2016b, 2016c, 2016d) , There are detailed instructions for how to read the temperature and humidity module method and reference program, here is no longer detailed.

Install the temperature and humidity module library

As the DHT22 temperature and humidity module common to the library, can not be applied to the LinkIt 7697 development board, so I refer to the original official website of the LinkIt 7697 Starter Kit, download"Temperature and Humidity Sensor Pro"related library, Click here to download. As for the installation of the library method, you can refer to the author of the article"wisdom family: how to install various types of sensor library"(Cao Yongzhong, 2016b; Cao Yongzhong et al., 2016a, 2016c), complete DHT22 temperature and humidity Group of library installation.

Temperature and humidity module basic test

We open the Arduino IDE integration development software, as shown below, open the Temperature and Humidity Sensor Pro function examples.

As shown in the following table dht22 test example program, we first modify: #define DHTPIN D8, the data output pin connected to P8 (D8), then #define DHTTYPE DHT22, set the DHT22 temperature and humidity modules used in this article, DHT11 / DHT21 will be marked with the program, we first test DHTtester program, you can correctly read the DHT22 temperature and humidity module.

// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

void setup()

{

Serial.begin(9600);

Serial.println(“DHTxx test!”);

dht.begin();

}

void loop()

{

// Reading temperature or humidity takes about 250 milliseconds!

// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)

float h = dht.readHumidity();

float t = dht.readTemperature();

// check if returns are valid, if they are NaN (not a number) then something went wrong!

if (isnan(t) || isnan(h))

{

Serial.println(“Failed to read from DHT”);

}

else

{

Serial.print(“Humidity: “);

Serial.print(h);

Serial.print(” %\t”);

Serial.print(“Temperature: “);

Serial.print(t);

Serial.println(” *C”);

}

}

As shown below, the reader can see the experiment-dht22 test example program results screen, you can successfully read the temperature and humidity module temperature and humidity information.

Summary

Thisarticle is"how to use LinkIt 7697 to establish intelligent temperature monitoringplatform"on the article, mainly to inform the reader, in the developmentof things, how to use Linkit 7697 development board to build things networkingtemperature and humidity sensing device.In the next chapter, we will show howto use such a development device, the establishment of an Internet temperatureand humidity monitoring site, so that all members of the family through theInternet to get fast, correct temperature and humidity information.

Follow-up,we will continue to develop a variety of Internet devices and platform teachingarticles. We hope to work with you to create better and more promisingtechnologies for Internet related product development.