Close
0%
0%

NodeMCU Voice Bin Lid

Just out of Reach

Similar projects worth following

Just .. out .. of .. reach. The solution is of course to waste additional resources bcz what is it to be modernly alive if not burdening others, from the unseen to those cherished. To hell with them all bcz the bin is aesthetically more appealing out of reach.

Notations
1. This project was least about creative thinking and more about episodic novelty practicality .. a form of selling out .. in my mind.
2. The feisty bot is K∞e (pronounced Katey). She/it will co-star in several upcoming engineering episodes bcz she/it does not demand scale.
3. The code presented features both the trash bin lid and a light switch relay.
4. Program voice cmd to call url http://192.168.0.47/trash or go to url and press 'trash' button.

  • 1 × NodeMCU ESP8266 12E
  • 1 × MG995 Servo
  • 1 × Purty Printy Parts
  • 1 × Voice Attack

  • Simple Simon

    Vije Miller07/24/2019 at 18:41 0 comments

  • Code Dumpster Fire (Relay (Light Switch) + Servo (Trash Bin))

    Vije Miller07/24/2019 at 05:32 0 comments

    // NodeMCU -> Lights -> Lid
    
    #include <ESP8266WiFi.h>
    #include <Servo.h>
    
    // Static IP
    IPAddress ip(192, 168, 0, 47);
    IPAddress gateway(192, 168, 0, 1);
    IPAddress dns(192, 168, 0, 1);
    IPAddress subnet(255, 255, 255, 0);
    
    const char* ssid = "ssid";
    const char* pass = "password";
    
    WiFiServer server(80);
    
    // Trash
    Servo trash;
    int pos = 80;
    int up_lid = 145;
    int down_lid = 80;
    int bin_delay = 20;
    
    // Lights
    int relay = D8;
    int state = 0;
    int led = D0;
    
    void setup() {
      Serial.begin(115200);
    
      pinMode(led, OUTPUT);
      pinMode(relay, OUTPUT);
    
      trash.attach(D5);
      trash.write(90);
    
      digitalWrite(led, LOW);
      digitalWrite(relay, LOW);
    
      wifi_connect();
    }
    
    void loop() {
    
      // Check
      WiFiClient client = server.available();
      if (!client) {
        return;
      }
      // Wait
      while (!client.available()) {
        delay(1);
      }
      // Read
      String query = client.readStringUntil('\r');
      client.flush();
    
      if (query.indexOf("/light") != -1) {
        if (state == 0) { // off
          up();
        } else if (state == 1) { // on
          down();
        }
      } else if (query.indexOf("/trash") != -1) {
        trash_open();
      }
      
      // Browsers prefer content to read other wise they loop
      // Voice program attack ip+/light or ip+/trash
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println("");
      client.println("<!DOCTYPE HTML>");
      client.println("<html>");
      client.println("<a href=\"/light\"\"><button>Light</button></a>");
      client.println("<a href=\"/trash\"\"><button>Trash</button></a>");
      client.println("</html>");
    
      delay(1);
      Serial.println("Client disonnected");
    }
    
    // Light Switch On
    void up() {
      digitalWrite(led, HIGH);
      digitalWrite(relay, HIGH);
      state = 1;
    }
    
    // Light Switch Off
    void down() {
      digitalWrite(led, LOW);
      digitalWrite(relay, LOW);
      state = 0;
    }
    
    // Trash Open + Close
    void trash_open() {
      for (pos = down_lid; pos <= up_lid; pos += 1) {
        trash.write(pos);
        delay(bin_delay);
      }
      delay(3000);
      for (pos = up_lid; pos >= down_lid; pos -= 1) {
        trash.write(pos);
        delay(bin_delay);
      }
    }
    
    // Wifi Dating App
    void wifi_connect() {
      Serial.println(ssid);
      WiFi.config(ip, gateway, subnet, dns);
      WiFi.mode(WIFI_STA);
      WiFi.begin(ssid, pass);
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      Serial.println("Connected");
      server.begin();
      Serial.print("http://");
      Serial.print(WiFi.localIP());
      Serial.println("/");
    }

View all 2 project logs

Enjoy this project?

Share

Discussions

Vije Miller wrote 07/25/2019 at 17:42 point

Perhaps not this one - but I have (2) new ones finishing that might fit the bill. Thx for the link to the contest.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates