diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b6c5a13 Binary files /dev/null and b/.DS_Store differ diff --git a/Body.stl b/Body.stl deleted file mode 100644 index 1132c2a..0000000 Binary files a/Body.stl and /dev/null differ diff --git a/Deckel.stl b/Deckel.stl deleted file mode 100644 index 5b087d9..0000000 Binary files a/Deckel.stl and /dev/null differ diff --git a/platformio.ini b/platformio.ini index d026671..8f5ca81 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,3 +12,6 @@ platform = espressif8266 board = esp12e framework = arduino + +upload_port = esp_wz_duft.local ;192.168.1.134 +upload_flags = --auth=druffmann77 diff --git a/screenshot_04.png b/screenshot_04.png deleted file mode 100644 index a5f67e7..0000000 Binary files a/screenshot_04.png and /dev/null differ diff --git a/screenshot_05.png b/screenshot_05.png deleted file mode 100644 index 9a2dfba..0000000 Binary files a/screenshot_05.png and /dev/null differ diff --git a/screenshot_06.png b/screenshot_06.png deleted file mode 100644 index 41873cd..0000000 Binary files a/screenshot_06.png and /dev/null differ diff --git a/src/Duftsprueher.ino b/src/Duftsprueher.ino index 50a32fb..6ead453 100644 --- a/src/Duftsprueher.ino +++ b/src/Duftsprueher.ino @@ -2,7 +2,8 @@ #include #include //ESP library from http://github.com/esp8266/Arduino #include // MQTT library from http://github.com/Imroy/pubsubclient -#include "Servo.h" +#include +#include extern "C" { #include "user_interface.h" @@ -11,45 +12,25 @@ extern "C" { String esp_id = "duft"; const char *ssid = "iApfel"; // cannot be longer than 32 characters! -const char *password = "***PASSWORD***"; // +const char *password = "druffmann77"; // const char* mqtt_server = "192.168.1.5"; +const char* ota_password = "druffmann77"; #define SERV1 12 // Pin connected to the Servomotor Servo s1; // Strings zusammen bauen -String esp = "esp_wz" + esp_id; +String esp = "esp_wz_" + esp_id; char *esp_name = &esp[0u]; -//String air_topic = "esp" + String(esp_id) + "/room"; -//const char* mqtt_air_topic = &air_topic[0u]; -const char* mqtt_air_topic = "airfresh"; +String print_topic = "airfresh"; +const char* mqtt_print_topic = &print_topic[0u]; WiFiClient espClient; PubSubClient client(espClient); -void setup() { - // start the serial connection - Serial.begin(115200); - - setup_wifi(); - - Serial.print("Connecting to MQTT"); - client.setServer(mqtt_server, 1883); - Serial.print("Connected to MQTT"); - client.setCallback(callback); - client.publish("airfrash","hello world"); - client.subscribe("airfresh"); - - // move servomotor to neutral position - s1.attach(SERV1); - delay(400); - s1.write(90); - delay(400); - s1.detach(); -} - void setup_wifi() { + delay(10); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); //wifi_set_phy_mode(PHY_MODE_11G); @@ -66,8 +47,8 @@ void setup_wifi() { // animate LEDs while waiting for connection while (WiFi.status() != WL_CONNECTED) { + delay(500); Serial.print("."); - delay(50); } Serial.println(""); @@ -76,30 +57,41 @@ void setup_wifi() { Serial.println(WiFi.localIP()); } -void loop() { - // Check WLan - if (WiFi.status() != WL_CONNECTED) { - reconnect(); - } +void setup() { + // start the serial connection + Serial.begin(115200); - // Check mqtt messages - if (!client.connected()) { - reconnect(); - } - client.loop(); + setup_wifi(); + + client.setServer(mqtt_server, 1883); + client.setCallback(callback); + + ArduinoOTA.setPassword(ota_password); + ArduinoOTA.setHostname(esp_name); + ArduinoOTA.onStart([]() { + String type; + if (ArduinoOTA.getCommand() == U_FLASH) + type = "sketch"; + else // U_SPIFFS + type = "filesystem"; + }); + ArduinoOTA.begin(); + + // move servomotor to neutral position + s1.attach(SERV1); + s1.write(90); + delay(3000); + s1.detach(); } -// this function is called whenever a message -// is received from Adafruit IO. it was attached to -// the feed in the setup() function above. void callback(char* topic, byte* payload, unsigned int length) { // Zähler int i = 0; // Hilfsvariablen für die Convertierung der Nachricht in ein String char message_buff[100]; - Serial.println("Message arrived: topic: " + String(topic)); - Serial.println("Length: " + String(length,DEC)); + //Serial.println("Message arrived: topic: " + String(topic)); + //Serial.println("Length: " + String(length,DEC)); // Kopieren der Nachricht und erstellen eines Bytes mit abschließender \0 for(i=0; i