描述
商品內容
Arduino UNO R3主控板 1個
LM35溫度感測模組 1個
繼電器模組 1個
USB cable (100cm) 1條
I2C LCD1602 模組(附RJ11轉杜邦線) 1條
RJ11 6P4C 25cm信號線 3條
收納盒 1個
程式範例
/////////////////////////////////
//// 功能: WiFi ESP8266 with S4A Sensor Board v2 Testing
//// 日期: Oct 2016
//// 作者: Dennis
//////////////////////////
#include <SoftwareSerial.h>
#include <Wire.h>
#include <motoLiquidCrystal_I2C.h>
#include “motoESP8266.h”
SoftwareSerial esp8266(3,2); // for S4A Sensor Board v2 or IO Board,
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define AP_SSID “XXXXXXXX” // change this to match your WiFi SSID
#define PASSWORD “XXXXXXXX” // change this to match your WiFi password
ESP8266 wifi(esp8266);
int LED_CONNECT_PIN = 11;
int Relay_Pin = 12; // 繼電器模組 I/O 位置 D12
int analogPin = A3; //LM35接在A3
int readValue = 0;
float temperature = 0;
float temperatureF = 0;
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.print(“Getting IP …”);
// change if necessary to match your modules’ baud rate
esp8266.begin(9600);
Serial.begin(9600);
Serial.println(“begin.”);
wifi.restart();
if (wifi.setOprToStation()) {
Serial.print(“set to STATION mode ok\r\n”);
} else {
Serial.print(“set to STATION mode err\r\n”);
}
wifi.joinAP(AP_SSID, PASSWORD);
delay(8000);
Serial.print(“IP: “);
String ipaddress = wifi.getLocalIP();
Serial.println(ipaddress);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“IP:”);
lcd.setCursor(0,1);
lcd.print(ipaddress);
pinMode(Relay_Pin, OUTPUT);
}
void loop()
{
digitalWrite(Relay_Pin, HIGH);
delay(5000);
digitalWrite(Relay_Pin, LOW);
delay(5000);
readValue = analogRead(analogPin);
//Serial.println(readValue);
temperature = (readValue * 0.0049);
temperature = temperature * 100;
temperatureF = (temperature * 1.8) + 32;
Serial.print(“Temperature: “);
Serial.print(temperature);
Serial.print(“C \t”);
Serial.print(temperatureF);
Serial.println(“F”);
}
接線範例
LCD 模組 A4A5 孔位
WiFi模組 D2D3 孔位
繼電器 D12D13 孔位
LM35溫度 A3A4 孔位