물을 감지하면 LED가 켜지는 구조이고 감지가 잘 됩니다. 첨 해 본 건데, 나중에 문제 생기면 후기 올리겠습니다.
요새는 비접촉식 수위 측정 센서들이 조금씩 나오는 듯 한데, 자신 없으면 접촉식..
아직 확실한 비접촉식 센서는 없는듯 보입니다.
1
2
3
4
5
6
7
8
9
10
11
12
|
boolean SDClass::begin(uint8_t csPin, uint32_t speed) {
/*
Performs the initialisation required by the sdfatlib library.
Return true if initialization succeeds, false otherwise.
*/
return card.init(speed, csPin) &&
volume.init(card) &&
root.openRoot(volume);
}
| cs |
1
2
3
4
|
if (SD.begin(4)) {
Serial.println("SD opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
}
| cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <SPI.h>
#include <SD.h>
//#include <FS.h>
#include <WiFiClient.h>
#define FTP_SERVER_VERSION "FTP-2016-01-14"
#define FTP_CTRL_PORT 21 // Command port on wich server is listening
#define FTP_DATA_PORT_PASV 50009 // Data port in passive mode
#define FTP_TIME_OUT 5 // Disconnect client after 5 minutes of inactivity
#define FTP_CMD_SIZE 255 + 8 // max size of a command
#define FTP_CWD_SIZE 255 + 8 // max size of a directory name
#define FTP_FIL_SIZE 255 // max size of a file name
//#define FTP_BUF_SIZE 1024 //512 // size of file buffer for read/write
#define FTP_BUF_SIZE 2*1460
| cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//
// MLSD - Listing for Machine Processing (see RFC 3659)
//
else if( ! strcmp( command, "MLSD" ))
{
if( ! dataConnect())
client.println( "425 No data connection MLSD");
else
{
client.println( "150 Accepted data connection");
uint16_t nm = 0;
File dir=SD.open(cwdName);
File entry;
dir.rewindDirectory();
char dtStr[ 15 ];
while(1)
{
entry = dir.openNextFile();
if (!entry)
break;
String fn,fs;
fn = entry.name();
fs = String(entry.size());
data.println( "Type=file;Size=" + fs + ";"+"modify=20000101160656;" +" " + fn);
nm ++;
}
client.println( "226-options: -a -l");
client.println( "226 " + String(nm) + " matches total");
}
data.stop();
entry.close();
}
| cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <EEPROM.h>
const int buttonPin = 0; // the number of the pushbutton pin
int buttonState = 0,buttonState_old=0; // variable for reading the pushbutton status
byte value;
void setup() {
// put your setup code here, to run once:
delay(1000);
Serial.begin(115200);
EEPROM.begin(512);
pinMode(buttonPin, INPUT);
value = EEPROM.read(0);
Serial.println("");
Serial.print("EEPROM value = ");
Serial.println(value,HEX);
buttonState_old = buttonState = digitalRead(buttonPin);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState_old = buttonState;
buttonState = digitalRead(buttonPin);
if (buttonState_old != buttonState)
{
if (buttonState == LOW)
{
value = EEPROM.read(0);
value ^= 1;
EEPROM.write(0, value);
EEPROM.commit();
Serial.print("Button Pressed !, EEPROM value = ");
Serial.println(value,HEX);
Serial.println("ESP8266 Software Reset");
ESP.reset();
}
}
}
| cs |
1
2
3
|
const char* ssid = "FISI_Server";
const char* password = "0317358631";
| cs |
1
2
3
4
5
|
// config static IP
IPAddress apIP(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1); // set gateway to match your network
IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network
| cs |
1
2
3
4
5
6
7
8
9
10
|
WiFi.config(apIP, gateway, subnet);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.disconnect();
delay(100);
WiFi.softAPConfig(apIP, gateway, subnet);
WiFi.softAP(ssid, password);
| cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266FtpServer.h>
const char* ssid = "FISI_Server";
const char* password = "0317358631";
// config static IP
IPAddress apIP(192, 168, 4, 1);
IPAddress gateway(192, 168, 4, 1); // set gateway to match your network
IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network
ESP8266WebServer server(80);
FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
void handleRoot() {
server.send(200, "text/plain", "hello from esp8266!");
}
void handleNotFound(){
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
void setup(void){
delay(1000);
Serial.begin(115200);
Serial.println("");
Serial.println(WiFi.SSID());
Serial.println(WiFi.psk());
WiFi.config(apIP, gateway, subnet);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.disconnect();
delay(100);
WiFi.softAPConfig(apIP, gateway, subnet);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
Serial.println("");
Serial.println("");
WiFi.printDiag(Serial);
Serial.println("");
Serial.print("Connected to ");
Serial.println(WiFi.SSID());
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
/////FTP Setup, ensure SPIFFS is started before ftp; /////////
if (SD.begin(4)) {
Serial.println("SD opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
}
Serial.println("FTP server On!");
/*
if (SPIFFS.begin()) {
Serial.println("SPIFFS opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
} */
}
void loop(void){
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
server.handleClient();
}
| cs |