User:ZUZU/SI 24: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 58: Line 58:


== ESP32 WiFi Access Point with Web Server for LED Control and Sensor Monitoring ==
== ESP32 WiFi Access Point with Web Server for LED Control and Sensor Monitoring ==
Create a WiFi Access Point (AP) using an ESP32 microcontroller. It sets up a web server on this AP to control an LED and display sensor readings (humidity and temperature) via a web interface.
[https://randomnerdtutorials.com/esp32-dht11-dht22-temperature-humidity-sensor-arduino-ide/ sensor collections]
Create a WiFi Access Point (AP) using an ESP32 microcontroller. It sets up a web server on this AP to control an LED and display sensor readings (humidity and temperature) via a web interface.<br>
 
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
/*
  WiFiAccessPoint.ino creates a WiFi access point and provides a web server on it.
  Steps:
  1. Connect to the access point "yourAp"
  2. Point your web browser to http://192.168.4.1/H to turn the LED on or http://192.168.4.1/L to turn it off
    OR
    Run raw TCP "GET /H" and "GET /L" on PuTTY terminal with 192.168.4.1 as IP address and 80 as port
  Created for arduino-esp32 on 04 July, 2018
  by Elochukwu Ifediora (fedy0)
*/
#include <DHT.h>
#include <DHT.h>
#include <WiFi.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>


#define DHTPIN 21
#define DHTPIN 21
#define LED_BUILTIN 23  // Set the GPIO pin where you connected your test LED or comment this line out if your dev board has a built-in LED
#define LED_BUILTIN 23  // GPIO pin for the LED (change as needed)
   
 
#define DHTTYPE DHT22   
#define DHTTYPE DHT22   
DHT dht(DHTPIN, DHTTYPE);
DHT dht(DHTPIN, DHTTYPE);


float hum;  //Stores humidity value
float humidity;  // Variable to store humidity value
float temp;
float temperature; // Variable to store temperature value
 
// Set these to your desired credentials.
const char *ssid = "jungle";
const char *password = "myPassword";


WiFiServer server(80);
const char *ssid = "jungle"; // WiFi AP SSID
const char *password = "myPassword";  // WiFi AP password


WiFiServer server(80);  // Create a server object that listens on port 80


void setup() {
void setup() {
   pinMode(LED_BUILTIN, OUTPUT);
   pinMode(LED_BUILTIN, OUTPUT); // Set LED pin as output
 
 
   Serial.begin(115200);
   Serial.begin(115200); // Initialize serial communication
   Serial.println();
   Serial.println();
   Serial.println("Configuring access point...");
   Serial.println("Configuring access point...");
   dht.begin();
 
 
   dht.begin(); // Initialize DHT sensor
   // You can remove the password parameter if you want the AP to be open.
    
   // a valid password must have more than 7 characters
   // Start WiFi access point
   if (!WiFi.softAP(ssid, password)) {
   if (!WiFi.softAP(ssid, password)) {
     log_e("Soft AP creation failed.");
     Serial.println("Soft AP creation failed.");
     while(1);
     while(1); // Infinite loop if AP creation fails
   }
   }
   IPAddress myIP = WiFi.softAPIP();
 
   IPAddress myIP = WiFi.softAPIP(); // Get IP address of the AP
   Serial.print("AP IP address: ");
   Serial.print("AP IP address: ");
   Serial.println(myIP);
   Serial.println(myIP);
   server.begin();
 
 
   server.begin(); // Start the server
   Serial.println("Server started");
   Serial.println("Server started");
}
}


void loop() {
void loop() {
   WiFiClient client = server.available();   // listen for incoming clients
   WiFiClient client = server.available(); // Check for incoming client connections
  int sensorValue = analogRead(34);
    
    
 
   if (client) { // If a client is connected
   if (client) {                             // if you get a client,
     Serial.println("New Client."); // Print message to serial monitor
     Serial.println("New Client.");           // print a message out the serial port
   
     String currentLine = "";               // make a String to hold incoming data from the client
     String currentLine = ""; // String to hold incoming data from the client
     while (client.connected()) {           // loop while the client's connected
   
       if (client.available()) {             // if there's bytes to read from the client,
     while (client.connected()) { // Loop while client is connected
         char c = client.read();             // read a byte, then
       if (client.available()) { // If data is available from client
         Serial.write(c);                   // print it out the serial monitor
         char c = client.read(); // Read a byte from client
         if (c == '\n') {                   // if the byte is a newline character
         Serial.write(c); // Print byte to serial monitor
 
       
          // if the current line is blank, you got two newline characters in a row.
         if (c == '\n') { // If end of line is reached
          // that's the end of the client HTTP request, so send a response:
           if (currentLine.length() == 0) { // If current line is blank, end of HTTP request
           if (currentLine.length() == 0) {
             client.println("HTTP/1.1 200 OK"); // Send HTTP response headers
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
             client.println("HTTP/1.1 200 OK");
             client.println("Content-type:text/html");
             client.println("Content-type:text/html");
             client.println();
             client.println();
 
           
             hum = dht.readHumidity();   
             humidity = dht.readHumidity();  // Read humidity value from sensor
             temp = dht.readTemperature();  
             temperature = dht.readTemperature(); // Read temperature value from sensor
 
           
             // the content of the HTTP response follows the header:
             // Send HTML response with sensor data and LED control links
             client.print("<meta http-equiv='refresh' content='0.1'>");
             client.print("<meta http-equiv='refresh' content='0.1'>");
             client.print("<style>body{background-color:purple;}</style><br>");
             client.print("<style>body{background-color:purple;}</style><br>");
              
              
             int radius = map(hum, 30, 90, 0, 200);
             int radius = map(humidity, 30, 90, 0, 200);
             client.print("<style>.object{width:400px;height:400px;}</style><br>");
             client.print("<style>.object{width:400px;height:400px;}</style><br>");
             client.print("<style>.object{border-radius:"+ String(radius)+"px;background-color:white; }</style><br>");
             client.print("<style>.object{border-radius:"+ String(radius)+"px;background-color:white; }</style><br>");
 
           
             client.print("<h1>eviltwin" + String(sensorValue) + "</h1><br>");
             client.print("<h1>eviltwin" + String(temperature) + "</h1><br>");
             client.print("<div class='object'></div><br>");
             client.print("<div class='object'></div><br>");
             client.print("Click <a href=\"/H\">here</a> to turn ON the LED.<br>");
             client.print("Click <a href=\"/H\">here</a> to turn ON the LED.<br>");
             client.print("Click <a href=\"/L\">here</a> to turn OFF the LED.<br>");
             client.print("Click <a href=\"/L\">here</a> to turn OFF the LED.<br>");
            client.print("<p>Humidity: " + String(hum) + " %</p>");
            client.print("<p>Temperature: " + String(temp) + " °C</p>");
              
              
 
            client.print("<p>Humidity: " + String(humidity) + " %</p>");
             // The HTTP response ends with another blank line:
             client.print("<p>Temperature: " + String(temperature) + " °C</p>");
             client.println();
           
            // break out of the while loop:
             client.println(); // End of HTTP response
             break;
             break; // Exit the loop
           } else {   // if you got a newline, then clear currentLine:
           } else {
             currentLine = "";
             currentLine = ""; // Clear current line
           }
           }
         } else if (c != '\r') {  // if you got anything else but a carriage return character,
         } else if (c != '\r') {  // If not end of line or carriage return
           currentLine += c;     // add it to the end of the currentLine
           currentLine += c; // Add character to current line
         }
         }
 
       
         // Check to see if the client request was "GET /H" or "GET /L":
         // Check for specific client requests to control LED
         if (currentLine.endsWith("GET /H")) {
         if (currentLine.endsWith("GET /H")) {
           digitalWrite(LED_BUILTIN, HIGH);               // GET /H turns the LED on
           digitalWrite(LED_BUILTIN, HIGH); // Turn LED ON
         }
         }
         if (currentLine.endsWith("GET /L")) {
         if (currentLine.endsWith("GET /L")) {
           digitalWrite(LED_BUILTIN, LOW);               // GET /L turns the LED off
           digitalWrite(LED_BUILTIN, LOW); // Turn LED OFF
         }
         }
       }
       }
     }
     }
     // close the connection:
   
     // Close client connection
     client.stop();
     client.stop();
     Serial.println("Client Disconnected.");
     Serial.println("Client Disconnected.");
   }
   }
}
}


</syntaxhighlight>
</syntaxhighlight>

Revision as of 00:00, 9 May 2024


4/8

Start

Explore the possibilities of loitering and launching in or around Rotterdam

Why Loiter?

Why Loiter?: Women and Risk on Mumbai Streets by Shilpa Phadke points out that "loitering" is viewed negatively in Indian society, and women are expected to have a legitimate reason for being out in public. Otherwise, they may be considered not conforming to societal expectations of being a "respectable woman." This perspective reflects a common narrative of victim blaming prevalent in patriarchal societies, where women are advised to move from one sheltered space to another , and any deviation from this norm is seen as a moral deficiency by default.

Women have the right to freely navigate urban spaces without fear or judgment. Shilpa Phadke proposes a social initiative that encourages women's "loitering" to occupy urban public spaces, advocating for the creation of a more inclusive and equitable urban environment where women can move about freely without the fear of being labeled or subjected to shame.

Loitering around Blaak

Day1 blaak.jpg

The weather was lovely and we took a nice walk around Blaak, sharing memories of our individual hometowns.

4/9

Microcontroller

Beginning of Microcontroller

Circuit Brief
delect right board eg. Wemos Lolin32

  • Install ESP32 Board Package
  • Tools > Board > Wemos Lolin32
  • Tools > Upload Speed

4/10


Information Overload

INFORMATION OVERLOAD by Claire Bishop The article discusses the development of research-based installation art in contemporary art and the problems it faces.The author points out that a large number of research-based installation artworks have emerged in recent years that lack clear definitions and critical analyses. The article analyses three stages in the development of research-based art:"Many of these pieces convey a sense of being immersed-even lost-in data." Contemporary viewers face pressures from visually saturated contexts and attentional economies when processing information. And contemporary audiences are under pressure to process information through visual saturation and an economy of attention.

Blasé attitude or the Flâneur

The Metropolitan: Blasé attitude or the Flâneur describes the phenomenon of individuals experiencing a sense of Blasé in metropolitan life I've been trying to find a description about my own feelings about city life, and this term accurately describes my personal emotions

4/15

Making list

Pad for lists
list Sketching, observing the city as a spectator, joining the observation from a subjective point of view

  • People sitting in shopping center rest area during workday from 11:11am
  • where /how /why people laughing in public space
  • List of shop signs
  • Things dangerous in the park
  • The sound that occurs when people enter a space
  • Things between curtains and windows

4/23

ESP32 WiFi Access Point with Web Server for LED Control and Sensor Monitoring

sensor collections Create a WiFi Access Point (AP) using an ESP32 microcontroller. It sets up a web server on this AP to control an LED and display sensor readings (humidity and temperature) via a web interface.

#include <DHT.h>
#include <WiFi.h>

#define DHTPIN 21
#define LED_BUILTIN 23   // GPIO pin for the LED (change as needed)

#define DHTTYPE DHT22   
DHT dht(DHTPIN, DHTTYPE);

float humidity;  // Variable to store humidity value
float temperature;  // Variable to store temperature value

const char *ssid = "jungle";  // WiFi AP SSID
const char *password = "myPassword";  // WiFi AP password

WiFiServer server(80);  // Create a server object that listens on port 80

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);  // Set LED pin as output
  
  Serial.begin(115200);  // Initialize serial communication
  Serial.println();
  Serial.println("Configuring access point...");
  
  dht.begin();  // Initialize DHT sensor
  
  // Start WiFi access point
  if (!WiFi.softAP(ssid, password)) {
    Serial.println("Soft AP creation failed.");
    while(1);  // Infinite loop if AP creation fails
  }
  
  IPAddress myIP = WiFi.softAPIP();  // Get IP address of the AP
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  
  server.begin();  // Start the server
  Serial.println("Server started");
}

void loop() {
  WiFiClient client = server.available();  // Check for incoming client connections
  
  if (client) {  // If a client is connected
    Serial.println("New Client.");  // Print message to serial monitor
    
    String currentLine = "";  // String to hold incoming data from the client
    
    while (client.connected()) {  // Loop while client is connected
      if (client.available()) {  // If data is available from client
        char c = client.read();  // Read a byte from client
        Serial.write(c);  // Print byte to serial monitor
        
        if (c == '\n') {  // If end of line is reached
          if (currentLine.length() == 0) {  // If current line is blank, end of HTTP request
            client.println("HTTP/1.1 200 OK");  // Send HTTP response headers
            client.println("Content-type:text/html");
            client.println();
            
            humidity = dht.readHumidity();  // Read humidity value from sensor
            temperature = dht.readTemperature();  // Read temperature value from sensor
            
            // Send HTML response with sensor data and LED control links
            client.print("<meta http-equiv='refresh' content='0.1'>");
            client.print("<style>body{background-color:purple;}</style><br>");
            
            int radius = map(humidity, 30, 90, 0, 200);
            client.print("<style>.object{width:400px;height:400px;}</style><br>");
            client.print("<style>.object{border-radius:"+ String(radius)+"px;background-color:white; }</style><br>");
            
            client.print("<h1>eviltwin" + String(temperature) + "</h1><br>");
            client.print("<div class='object'></div><br>");
            client.print("Click <a href=\"/H\">here</a> to turn ON the LED.<br>");
            client.print("Click <a href=\"/L\">here</a> to turn OFF the LED.<br>");
            
            client.print("<p>Humidity: " + String(humidity) + " %</p>");
            client.print("<p>Temperature: " + String(temperature) + " °C</p>");
            
            client.println();  // End of HTTP response
            break;  // Exit the loop
          } else {
            currentLine = "";  // Clear current line
          }
        } else if (c != '\r') {  // If not end of line or carriage return
          currentLine += c;  // Add character to current line
        }
        
        // Check for specific client requests to control LED
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(LED_BUILTIN, HIGH);  // Turn LED ON
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(LED_BUILTIN, LOW);  // Turn LED OFF
        }
      }
    }
    
    // Close client connection
    client.stop();
    Serial.println("Client Disconnected.");
  }
}