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.
// this program is written by BruceTsao for MTK Link 7697
#include
#include
IPAddress Meip ,Megateway ,Mesubnet ;
String MacAddress ;
byte mac[6];
int status = WL_IDLE_STATUS; // the Wifi radio’s status
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
MacAddress = GetWifiMac() ;
ShowMac() ;
}
void loop() {
}
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 ;
}
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 this experiment - to obtain the MAC data test program results screen.
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.
(The code can be downloadedhere.)
Connect the wireless base station test program (ConnectWithWPA)
#include <LWiFi.h>
#include <String.h>
IPAddress Meip ,Megateway ,Mesubnet ;
String MacAddress ;
byte mac[6];
int status = WL_IDLE_STATUS; // the Wifi radio’s status
char ssid[] = “IOT”; // your network SSID (name)
char pass[] = “iot12345”; // your network password
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
MacAddress = GetWifiMac() ; // get MacAddress
ShowMac() ; //Show Mac Address
initializeWiFi(); // connect Wifi Access Point
ShowInternetStatus(); // Show Internet information from Wifi Setup
}
void loop() {
}
void initializeWiFi() {
while (status != WL_CONNECTED) {
Serial.print(“Attempting to connect to SSID: “);
Serial.println(ssid);
// 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.
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 .
Left) LINKIT 7697 development board; (medium) MicroUSBdownload line; (right) temperature and humidity module
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.
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.
(The code can be downloadedhere.)
Dht22 test example program (DHTtester)
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include “DHT.h”
#define DHTPIN 8 // what pin we’re connected to
// Uncomment whatever type you’re using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// 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.
Author:Cao jianguo
Articlesource:https://makerpro.cc/2017/07/make-a-smart-temperature-monitor-platform-by-linkit7697-part-one/