|
|
|
@ -1,13 +1,15 @@ |
|
|
|
#include <Arduino.h> |
|
|
|
#include <ESP8266WiFi.h> |
|
|
|
#include <ESP8266WebServer.h> |
|
|
|
|
|
|
|
#include <WiFi.h> |
|
|
|
#include <WebServer.h> |
|
|
|
|
|
|
|
#include <PubSubClient.h> |
|
|
|
|
|
|
|
#define WLAN_SSID "TP-LINK-RPT0" |
|
|
|
#define WLAN_PASS "6JM54UG4EY" |
|
|
|
#define WLAN_SSID "TP-LINK-OUT" |
|
|
|
#define WLAN_PASS "6JM54UG4EX" |
|
|
|
|
|
|
|
#define MQTT_CLID "ValveControl" |
|
|
|
#define MQTT_HOST "192.168.1.133" |
|
|
|
#define MQTT_HOST "192.168.1.146" |
|
|
|
#define MQTT_PORT 1883 |
|
|
|
#define MQTT_USER "admin" |
|
|
|
#define MQTT_PASS "22pa0799" |
|
|
|
@ -26,14 +28,14 @@ String SendHTML(uint8_t ValveOpen); |
|
|
|
|
|
|
|
bool ValveOpen = false; |
|
|
|
|
|
|
|
int ButtonOpen = 14; |
|
|
|
int ButtonClose = 12; |
|
|
|
int ButtonOpen = 16; |
|
|
|
int ButtonClose = 19; |
|
|
|
|
|
|
|
int MotorPin1 = 0; |
|
|
|
int MotorPin2 = 2; |
|
|
|
int duration = 10000; |
|
|
|
int MotorPin1 = 25; // estende il braccio
|
|
|
|
int MotorPin2 = 26; // ritrae il braccio
|
|
|
|
int duration = 60000; |
|
|
|
|
|
|
|
ESP8266WebServer server(80); |
|
|
|
WebServer server(80); |
|
|
|
|
|
|
|
WiFiClient espClient; |
|
|
|
PubSubClient client(espClient); |
|
|
|
@ -49,7 +51,7 @@ void setup_wifi() { |
|
|
|
} |
|
|
|
Serial.println(); |
|
|
|
Serial.println("WiFi connected"); |
|
|
|
Serial.println("IP address: "); |
|
|
|
Serial.print("IP address: "); |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
} |
|
|
|
|
|
|
|
@ -109,8 +111,8 @@ void setup() { |
|
|
|
delay(100); |
|
|
|
} |
|
|
|
|
|
|
|
pinMode(ButtonOpen, INPUT); |
|
|
|
pinMode(ButtonClose, INPUT); |
|
|
|
pinMode(ButtonOpen, INPUT_PULLUP); |
|
|
|
pinMode(ButtonClose, INPUT_PULLUP); |
|
|
|
|
|
|
|
pinMode(MotorPin1, OUTPUT); |
|
|
|
pinMode(MotorPin2, OUTPUT); |
|
|
|
|