Specification
- Module power 3.3V, regular current consumption at 70ma, peak current at 240mA (300mA must be able to provided)
- +20Dbm power, 100M max transmitting distance on ideal circumstance.
- It is common and correct to see some random error data when module is power up, and end up with "ready" (Turn baud rate to 115200 can see this actual debug data, this is used for firmware updating)
IC Features
- 802.11 b / g / n
- WIFI @ 2.4 GHz, supports WPA / WPA2 security mode
- Ultra-small size module 11.5mm * 11.5mm
- Built-in 10 bit precision ADC
- Built-in TCP / IP protocol stack
- Built-in TR switch, balun, LNA, power amplifier and matching network
- Built-in PLL, voltage regulator and power management components
- 802.11b mode + 19.5dBm output power
- Supports antenna diversity
- Off leakage current is less than 10uA
- Built-in low-power 32-bit CPU: can double as an application processor
- SDIO 2.0, SPI, UART
- STBC, 1x1 MIMO, 2x1 MIMO
- The guard interval A-MPDU, the polymerization of the A-MSDU and 0.4 s of
- Within 2ms of the wake, connect and transfer data packets
- Standby power consumption is less than 1.0mW (DTIM3)
- Operating temperature range -40 ~ 125 ℃
Wiring
ESP8266 >>> Arduino
TX>>> Pin10
RX>>> Pin11
Vcc>>> 3.3 Vcc
GND >>> GND
CH_PD>>> 3.3Vcc
VDO
Library
DHT11 :
AT Command for ESP8266
Code
//ตัวนี้ใช้ได้ดีมาก
#include <SoftwareSerial.h>
#include <stdlib.h>
#include "DHT.h"
DHT dht;
int sensor1State=0;
int sensor2State=0;
//int sensor3State=0;
//int sensor4State=0;
// replace with your channel's thingspeak API key
String apiKey = "LE3COBJ28VTF50KL";
// connect 10 to TX of ESP8266
// connect 11 to RX of ESP8266
SoftwareSerial ser(10, 11); // RX, TX
int i=1;
void setup() {
// DHT
dht.setup(2); // data pin 2
Serial.begin(9600);
ser.begin(9600);
// reset ESP8266
ser.println("AT+RST");
}
// the loop
void loop() {
delay(dht.getMinimumSamplingPeriod());
float humidity = dht.getHumidity(); // ดึงค่าความชื้น
float temperature = dht.getTemperature(); // ดึงค่าอุณหภูมิ
Serial.print(dht.getStatusString());
Serial.print("\t");
Serial.print(humidity, 1);
Serial.print("\t\t");
Serial.print(temperature, 1);
Serial.print("\t\t");
Serial.println(dht.toFahrenheit(temperature), 1);
sensor1State = humidity ;//digitalRead(sensor1);
sensor2State = temperature; //digitalRead(sensor2);
String state1=String(sensor1State);
String state2=String(sensor2State);
// server connect
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\",80";
ser.println(cmd);
Serial.println(cmd);
if(ser.find("Error")){
Serial.println("AT+CIPSTART error");
return;
}
// prepare GET string
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr +="&field1=";
getStr += String(state1);
getStr +="&field2=";
getStr += String(state2);
getStr += "\r\n\r\n";
// send data length
cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
ser.println(cmd);
Serial.println(cmd);
if(ser.find(">")){
ser.print(getStr);
Serial.print(getStr);
}
else{
ser.println("AT+CIPCLOSE");
// alert user
Serial.println("AT+CIPCLOSE");
}
// thingspeak needs 15 sec delay between updates
delay(16000);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น