Compare commits

...

3 Commits

Author SHA1 Message Date
ptrinchini 08e71b96e2 Changed input and output pin 2 weeks ago
ptrinchini 54bee65185 Internal pullup 2 weeks ago
ptrinchini b779613fc0 Fix libraries 2 weeks ago
  1. 17
      .vscode/extensions.json
  2. 7
      platformio.ini
  3. 30
      src/main.cpp

17
.vscode/extensions.json

@ -1,7 +1,10 @@
{ {
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"platformio.platformio-ide" "platformio.platformio-ide"
] ],
} "unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

7
platformio.ini

@ -8,9 +8,10 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[env:nodemcuv2]
platform = espressif8266 [env:esp32dev]
board = nodemcuv2 platform = espressif32
board = esp32dev
framework = arduino framework = arduino
upload_protocol = esptool upload_protocol = esptool
lib_deps = lib_deps =

30
src/main.cpp

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

Loading…
Cancel
Save