ESP8266 網路控制器

IMG_20181009_165026.jpg這是一個用ESP8266開發的網路控制器
即使人不在家也可以靠手機去開關家裡的冷氣
這個算是我這幾次研究的集大成
在這個專案中有遇到一些問題
像是網站有時候會掛掉
我們後來在!client.available()之中加了一個計數器
若計數器滿了即會重置
有點類似watchdog

#ifndef UNIT_TEST
#include
#endif
#include
#include
#include
const char* ssid = "SSID";
const char* password = "PW";
const char* host = ""; //it will tell you the IP once it starts up
//just write it here afterwards and upload
#define IR_LED 4
IRsend irsend(IR_LED);
uint16_t irSignal[439] = {3500, 1750, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 10320, 3500, 1750, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435};
uint16_t irSignalcl[439] = {3500, 1750, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 10320, 3500, 1750, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 1300, 435, 1300, 435, 435, 435, 435, 435, 1300, 435};
WiFiServer server(301); //just pick any port number you like
uint16_t temp = 26;
uint16_t wind = 10;
String onoff;
int ccon = 0;
void setup() {
Serial.begin(115200);
irsend.begin();
delay(10);
Serial.println(WiFi.localIP());
// prepare GPIO2
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print("."); }
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
while (!client.available()) {
delay(1);
ccon = ccon + 1;
if (ccon > 100) {
break;
}
}
ccon = 0;
// Read the first line of the request
String req = client.readStringUntil('\r');
client.flush();
// Match the request
if (req.indexOf("") != -10) { //checks if you're on the main page
if (req.indexOf("/16") != -1) {
temp = 16 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/17") != -1) {
temp = 17 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/18") != -1) {
temp = 18 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/19") != -1) {
temp = 19 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/20") != -1) {
temp = 20 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/21") != -1) {
temp = 21 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/22") != -1) {
temp = 22;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/23") != -1) {
temp = 23 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/24") != -1) {
temp = 24 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/25") != -1) {
temp = 25 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/26") != -1) {
temp = 26 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/27") != -1) {
temp = 27 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/28") != -1) {
temp = 28 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/29") != -1) {
temp = 29 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/30") != -1) {
temp = 30 ;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/w1") != -1) {
wind = 1;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/w2") != -1) {
wind = 2;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/w3") != -1) {
wind = 3;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/w4") != -1) {
wind = 4;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/w5") != -1) {
wind = 5;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/wa") != -1) {
wind = 8;
irchange(temp, wind);
iremit();
}
if (req.indexOf("/off") != -1) {
irsend.sendRaw(irSignalcl, sizeof(irSignalcl) / sizeof(irSignalcl[0]), 38);
onoff = "off";
}
else {
onoff = "on";
}
}

else {
Serial.println("invalid request");
client.stop();
return;
}
// Prepare the response
String s = "HTTP/1.1 200 OK\r\n";
s += "Content-Type: text/html\r\n\r\n";
s += "\r\n\r\n";
s += ("Temperature : ");
s += temp;
s += "
";
s += ("Wind : ");
s += wind;
s += "
";
s += ("Status:");
s += onoff;
s += "
";
s += "";
s += "";
s += "";
s += "";
s += "
";
s += "";
s += "";
s += "";
s += "";
s += "
";
s += "";
s += "";
s += "";
s += "";
s += "
";
s += "";
s += "";
s += "";
s += "";
s += "
";
s += "
";
s += "\n";
client.flush();
// Send the response to the client
client.print(s);
delay(1);
}
void irchange(int temp, int wind) {
int tempa [4] = {0, 1, 0, 1};
int winda [4] = {0, 1, 0, 1};
int scorea [7] = {0, 0, 0, 0, 0, 0, 0};
int score = temp + 8 * wind - 12;
int tempb = temp - 16;
int windc = wind + 2;
for (int i = 6; i >= 0; i--) {
if (score >= pow(2, i )) {
scorea[i] = 1;
score = score - pow(2, i );
}
else {
scorea[i] = 0;
}
}
for (int i = 3; i >= 0; i--) {
if (tempb >= pow(2, i )) {
tempa[i] = 1;
tempb = tempb - pow(2, i );
}
else {
tempa[i] = 0;
}
}
for (int i = 3; i >= 0; i--) {
if (windc >= pow(2, i )) {
winda[i] = 1;
windc = windc - pow(2, i );
}
else {
winda[i] = 0;
}
}
Serial.println();
Serial.print("score: ");
for (int i = 0; i < 7; i++) {
Serial.print(scorea[i]);
Serial.print(",");
}
Serial.println();
Serial.print("temp: ");
for (int i = 0; i <= 3; i++) {
Serial.print("i=");
Serial.print(i);
Serial.print(" ");
Serial.print(tempa[i]);
Serial.print(",");
}
Serial.println();
Serial.print("wind: ");
for (int i = 0; i <= 3; i++) {
Serial.print(winda[i]);
Serial.print(",");
}
Serial.println();
if (tempa[0] == 0) {
irSignal[233] = 435;
} else {
irSignal[233] = 1300;
}
if (tempa[1] == 0) {
irSignal[235] = 435;
} else {
irSignal[235] = 1300;
}
if (tempa[2] == 0) {
irSignal[237] = 435;
} else {
irSignal[237] = 1300;
}
if (tempa[3] == 0) {
irSignal[239] = 435;
} else {
irSignal[239] = 1300;
}
if (winda[0] == 0) {
irSignal[271] = 435;
} else {
irSignal[271] = 1300;
}
if (winda[1] == 0) {
irSignal[273] = 435;
} else {
irSignal[273] = 1300;
}
if (winda[2] == 0) {
irSignal[275] = 435;
} else {
irSignal[275] = 1300;
}
if (winda[3] == 0) {
irSignal[277] = 435;
} else {
irSignal[277] = 1300;
}
if (scorea[0] == 0) {
irSignal[425] = 435;
} else {
irSignal[425] = 1300;
}
if (scorea[1] == 0) {
irSignal[427] = 435;
} else {
irSignal[427] = 1300;
}
if (scorea[2] == 0) {
irSignal[429] = 435;
} else {
irSignal[429] = 1300;
}
if (scorea[3] == 0) {
irSignal[431] = 435;
} else {
irSignal[431] = 1300;
}
if (scorea[4] == 0) {
irSignal[433] = 435;
} else {
irSignal[433] = 1300;
}
if (scorea[5] == 0) {
irSignal[435] = 435;
} else {
irSignal[435] = 1300;
}
if (scorea[6] == 0) {
irSignal[437] = 435;
} else {
irSignal[437] = 1300;
}
for (int i = 0; i < 439; i++) {
Serial.print(irSignal[i]);
Serial.print(",");
}
}
void iremit() {
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), 38);
}

廣告

ESP8266 Rainsun 天線加強

ESP8266的Rainsun陶瓷天線非常的脆弱,焊接的地方容易翹起,最後將脫落斷裂。因此在使用前我會建議加強Rainsun天線與開發版的連接。

簡單的將陶瓷天線的兩端加上銲錫,就天可以防止天線掉落,得不償失。
img_20181009_161321.jpg
右邊的為加強過天線的
左邊是原本的ESP8266

杜邦線的壓法

杜邦線壓鉗的設計原本是讓你可以一次就壓出漂亮的線材

壓的地方有圓形和m字型的

IMG_20181011_233530.jpg

不過一次壓好非常的困難,因為沒有辦法只用杜邦壓鉗去固定杜邦接頭

這樣需要三隻手才能壓杜邦線

但其實只要分兩次壓

就可以壓出漂亮的杜邦線了

IMG_20181011_233657.jpg

先壓前半段m字的部分

IMG_20181011_233740.jpg

再壓後半段圓形的部分即完成

img_20181011_233756.jpg

這樣就壓好漂亮的杜邦線了

IR發射

ir 發射主要是利用下面的 sample code

* IRremote: IRsendRawDemo – demonstrates sending IR codes with sendRaw
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*
* IRsendRawDemo – added by AnalysIR (via http://www.AnalysIR.com), 24 August 2015
*
* This example shows how to send a RAW signal using the IRremote library.
* The example signal is actually a 32 bit NEC signal.
* Remote Control button: LGTV Power On/Off.
* Hex Value: 0x20DF10EF, 32 bits
*
* It is more efficient to use the sendNEC function to send NEC signals.
* Use of sendRaw here, serves only as an example of using the function.

#include
IRsend irsend;
void setup()
{
}
void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol
unsigned int irSignal[] = {1405,255,1445,241,589,1144,1407,256,1432,265,587,1133,552,1143,551,1144,549,1141,552,1144,551,1143,1405,7067,1404,253,1440,255,583,1143,1415,241,1463,224,596,1144,551,1143,551,1144,551,1143,551,1144,551,1141,1132,7340,1421,220,1451,269,575,1144,1413,241,1460,224,600,1141,549,1144,551,1144,551,1143,552,1144,548,1143,552,7920,1412,241,1461,223,608,1135,1423,223,1471,223,601,1141,551,1143,551,1143,552,1141,551,1143,557,1139,549
}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

主要困難的地方是如何處理紅外線訊號

分清楚 space 和 pulse

Arduino YUN IR接收完整版

IMG_20181009_165002.jpg
這是Arduino YUN IR 接收器的完整版

#include
#include
#include
#include
HttpClient acwifi;
#define LEDPIN 13
#define maxLen 500
volatile unsigned int irBuffer[maxLen];
volatile unsigned int x = 0;
volatile int temp[4];
volatile int wind[4];
volatile int tempfin = 99;
volatile int windfin = 9;
volatile int onoff = 0;
void setup() {
Bridge.begin();
Console.begin();
Console.println("Press the button on the remote now - once only");
delay(50);
attachInterrupt(digitalPinToInterrupt(2), rxIR_Interrupt_Handler, CHANGE);
}
void loop() {
delay(500);
if (x) {
digitalWrite(LEDPIN, HIGH);
Console.println();
if (1000 < (irBuffer[234] - irBuffer[233])) {
temp[0] = 1;
}
else {
temp[0] = 0;
}
if (1000 < (irBuffer[236] - irBuffer[235])) {
temp[1] = 1;
}
else {
temp[1] = 0;
}
if (1000 < (irBuffer[238] - irBuffer[237])) {
temp[2] = 1;
}
else {
temp[2] = 0;
}
if (1000 < (irBuffer[240] - irBuffer[239])) {
temp[3] = 1;
}
else {
temp[3] = 0;
}
Console.print("TEMP ");
tempfin = 16 + 1 * temp[0] + 2 * temp[1] + 4 * temp[2] + 8 * temp[3];
Console.print(tempfin);
Console.println();
if (1000 < (irBuffer[272] - irBuffer[271]) ) {
wind[0] = 1;
}
else {
wind[0] = 0;
}
if (1000 < (irBuffer[274] - irBuffer[273])) {
wind[1] = 1;
}
else {
wind[1] = 0;
}
if (1000 < (irBuffer[276] - irBuffer[275])) {
wind[2] = 1;
}
else {
wind[2] = 0;
}
if (1000 < (irBuffer[278] - irBuffer[277])) {
wind[3] = 1;
}
else {
wind[3] = 0;
}
Console.print("WIND ");
if ((1 * wind[0] + 2 * wind[1] + 4 * wind[2] + 8 * wind[3]) == 10)
{
windfin = 8;
}
else {
windfin = -2 + 1 * wind[0] + 2 * wind[1] + 4 * wind[2] + 8 * wind[3];
}
Console.print(windfin);
Console.println();
Console.print("STATUS ");
if (1000 maxLen) return;
irBuffer[x++] = micros();
}
void sendata(int tp, int wd, int of) {
acwifi.get("http://IP/AirConditioner/senacs.php?&pass=PW&temp=" + String(tp) + "&windspeed=" + String(wd) + "&status=" + String(of));
Console.println("Data Sent");
return;
}

二氧化碳偵測器


這是我最近做的二氧化碳偵測器

他有一個RGB螢幕可以顯示目前二氧化碳的濃度

如果二氧化碳的濃度越高

他的顏色就會越接近紅色

如果二氧化碳濃度越低

他的顏色會越趨近於綠色

 
#include
#include
#include
rgb_lcd lcd;
int colorR = 155;
int colorG = 0;
int colorB = 0;
SoftwareSerial s_serial(2, 3); // RX, TX
#define sensor s_serial
const unsigned char cmd_get_sensor[] =
{
0xff, 0x01, 0x86, 0x00, 0x00,
0x00, 0x00, 0x00, 0x79
};
unsigned char dataRevice[9];
int temperature;
int CO2PPM;
void setup()
{
sensor.begin(9600);
Serial.begin(115200);
Serial.println("get a 'g', begin to read from sensor!");
Serial.println("********************************************************");
Serial.println();
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
lcd.print("CO2");
}
void loop()
{
if (dataRecieve())
{
lcd.setCursor(0, 1);
if (CO2PPM < 1000) {
lcd.setCursor(0, 1);
lcd.print("0");
lcd.setCursor(1, 1);
}
lcd.print(CO2PPM);
lcd.setRGB(colorR, colorG, colorB);
}
delay(1000);
}
bool dataRecieve(void)
{
byte data[9];
int i = 0;
for (i = 0; i < sizeof(cmd_get_sensor); i++)
{
sensor.write(cmd_get_sensor[i]);
}
delay(10);
if (sensor.available())
{
while (sensor.available())
{
for (int i = 0; i < 9; i++)
{
data[i] = sensor.read();
}
}
}

for (int j = 0; j < 9; j++)
{
Serial.print(data[j]);
Serial.print(" ");
}
Serial.println("");
if ((i != 9) || (1 + (0xFF ^ (byte)(data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7]))) != data[8])
{
return false;
}
CO2PPM = (int)data[2] * 256 + (int)data[3];
temperature = (int)data[4] - 40;
colorR = (CO2PPM / 8);
colorG = 255 - (CO2PPM / 8);
return true;
}

冷氣辨識UNO最終版


#define LEDPIN 13
#define maxLen 600
volatile unsigned int irBuffer[maxLen];
volatile unsigned int x = 0;
volatile int temp[4];
volatile int wind[4];
volatile int prestatus;
void setup() {
Serial.begin(115200);
attachInterrupt(0, rxIR_Interrupt_Handler, CHANGE);
}
void loop() {
Serial.println(F("Press the button on the remote now-once only"));
delay(5000);
if (x) {
digitalWrite(LEDPIN, HIGH);
Serial.println();
Serial.print(F("Raw: ("));
Serial.print((x - 1));
Serial.print(F(") "));
detachInterrupt(0);
for (int i = 1; i < x; i++) {
if (!(i & 0x1)) Serial.print(F("-"));
Serial.print(irBuffer[i] - irBuffer[i - 1]);
Serial.print(F(","));
}
Serial.println();
if (1000 < (irBuffer[234] - irBuffer[233])) {
temp[0] = 1;
}
else {
temp[0] = 0;
}
if (1000 < (irBuffer[236] - irBuffer[235])) {
temp[1] = 1;
}
else {
temp[1] = 0;
}
if (1000 < (irBuffer[238] - irBuffer[237])) {
temp[2] = 1;
}
else {
temp[2] = 0;
}
if (1000 < (irBuffer[240] - irBuffer[239])) {
temp[3] = 1;
}
else {
temp[3] = 0;
}
Serial.print(F("TEMP "));
Serial.print(16 + 1 * temp[0] + 2 * temp[1] + 4 * temp[2] + 8 * temp[3]);
Serial.println();

if (1000 < (irBuffer[272] – irBuffer[271])) {
wind[0] = 1;
}
else {
wind[0] = 0;
}
if (1000 < (irBuffer[274] – irBuffer[273])) {
wind[1] = 1;
}
else {
wind[1] = 0;
}
if (1000 < (irBuffer[276] – irBuffer[275])) {
wind[2] = 1;
}
else {
wind[2] = 0;
}
if (1000 < (irBuffer[278] – irBuffer[277])) {
wind[3] = 1;
}
else {
wind[3] = 0;
}
Serial.print(F(“WIND “));
if ((1 * wind[0] + 2 * wind[1] + 4 * wind[2] + 8 * wind[3]) == 10)
{
Serial.print(“Auto");
}
else {
Serial.print(-2 + 1 * wind[0] + 2 * wind[1] + 4 * wind[2] + 8 * wind[3]);
}
Serial.println();
if (1000 maxLen) return;
irBuffer[x++] = micros();
}