DIY!

Textile printing IIb

My particulate matter sensor for the FabLab Bremen

Adaptation of the microcontroller holder to the dust and water jet-protected Wiska 607 junction box.

Housing for particulate matter sensor

3D printing ( https://www.thingiverse.com/thing:2423413 ) – nice – but the electronics will probably not survive the fall in Bremen in this design…

LightSensor&Switch2WWW with XMLHttpRequest



The backgroundColor property is dynamically controlled with the ESP8266 via a light sensor and/or a switch.

 

LIGHTSENSORundSCHALTER.ino

/*
——————————————————————————
Author: BNC
Platforms: ESP8266
Board: Generic ESP8266 MODULE
Language: C++/Arduino

Thank you:
——————————————————————————
https://github.com/acrobotic/Ai_Tips_ESP8266/tree/master/webserver_html_js
——————————————————————————
https://circuits4you.com/2018/11/20/web-server-on-esp32-how-to-update-and-display-sensor-values/
———————————————————————————
*/

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

int schalter = 5;

ESP8266WebServer server;

char* ssid = „*******“;
char* password = „*******“;

char MAIN_page[] PROGMEM = R“=====(
<!DOCTYPE html>
<html>
<body>
<div id=“demo“>
<h1>Licht an Licht aus – TEST</h1>
</div>

<div>
Sensor Status: <span style=“color: blue;“ id=“ADCValue“>0</span><br>
</div>
<script>

setInterval(function() {
getData();
}, 100); //update rate

function getData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(„ADCValue“).innerHTML = this.responseText;

document.body.style.backgroundColor = ‚rgb(‚ + this.responseText + ‚,‘ + this.responseText + ‚,‘ + this.responseText + ‚)‘;
document.getElementById(„ADCValue“).innerHTML = this.responseText;
}
};
xhttp.open(„GET“, „readADC“, true);
xhttp.send();
}
</script>
<br>
</body>
</html>
)=====“;

void setup()
{
WiFi.begin(ssid,password);
Serial.begin(115200);

// Programmierung Schalter
pinMode(schalter, INPUT);

while(WiFi.status()!=WL_CONNECTED)
{
Serial.print(„.“);
delay(500);
}
Serial.println(„“);
Serial.print(„IP Address: „);
Serial.println(WiFi.localIP());

server.on(„/“,[](){server.send_P(200,“text/html“, MAIN_page);});
server.on(„/readADC“, handleADC);
server.begin();
}

void loop()
{
server.handleClient();
}

void handleADC() {
int a = analogRead(A0);
if (digitalRead(schalter) == HIGH){
a = 0;
} else {
a = a/4;
digitalRead(schalter) == LOW;
}
Serial.print(a);
Serial.print(‚\n‘);
String adcValue = String(a);
server.send(200, „text/plane“, adcValue);
}