Unsere Erfolge

EcoSensors System

Etikettiergerät
#include <FastLED.h>
#define LED_PIN 21 //By default, the WS2812B LED is connected to GPIO21 of the ESP32-S3
#define NUM_LEDS 1 //We only have one LED
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); //Declare and initialize the LED
}
void loop() {
leds[0] = CRGB::Red; //Set the LED to red
FastLED.show();
delay(50);
leds[0] = CRGB::Green; //set the LED to green
FastLED.show();
delay(50);
leds[0] = CRGB::Blue; //set the LED to blue
FastLED.show();
delay(50);
}
#include <FastLED.h>
#define LED_PIN 21 //By default, the WS2812B LED is connected to GPIO21 of the ESP32-S3
#define NUM_LEDS 1 //We only have one LED
CRGB leds[NUM_LEDS];
const int photo_diode = 4; //Define the pin to which the photodiode is connected
int inputVal = 10;
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); //Declare and initialize the LED
}
void loop() {
inputVal = analogRead(photo_diode); //Reading value
Serial.println(inputVal);
if (inputVal > 600) {
leds[0] = CRGB::Red; //Set the LED to red if the photodiode detects something
} else {
leds[0] = CRGB::Green; //set the LED to green
}
FastLED.show();
delay(100);
}
const int photo_diode = 4; //Define the pin to which the photodiode is connected
int inputVal = 10;
const int relay = 6; //Define the pin to which the relay is connected
void setup() {
Serial.begin(115200);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW); //The relay is normally opened
}
void loop() {
inputVal = analogRead(photo_diode); //Reading value
Serial.println(inputVal);
if (inputVal > 600){ //If the photodiode detects something...
digitalWrite(relay, HIGH); //...switch on the relay
} else{
digitalWrite(relay, LOW); //Switch off the relay
}
}

HTA – Hybrid-Traktionssystem
// Libraries
#include <WiFi.h> //including library for Wifi
#include <WebServer.h> //including library for WebServer Design
#include <FastLED.h> //including library for LED
#include "HX711.h"
// Global Variables
//LED
#define LED_PIN 21
#define NUM_LEDS 1
CRGB leds[NUM_LEDS];
//Loadcell
uint8_t dataPin = 4;
uint8_t clockPin = 5;
HX711 myScale;
//Wifi
const char *ssid = "Syde Technology";
const char *password = "nVvffsb#95B!";
WebServer server(80);
//WiFi.config(IPAddress(192,168,1,100), gateway, subnet);
String serialData = "Waiting for data..."; // Stores received Serial data
String ipAddress = "Not connected"; // Stores ESP32's IP Address
String webWeight = "Waiting for weight...";
bool startMeasurement = false;
//Functions
void handleSerialData() {
server.send(200, "text/plain", serialData);
}
void handleWeightData() {
server.send(200, "text/plain", webWeight);
}
void handleZero() {
zero();
server.send(200, "text/plain", "SetZero");
}
void handleEnter() {
enter();
server.send(200, "text/plain", "SetEnter");
}
void handleStart() {
startMeasurement = true;
leds[0] = CRGB::Blue;
FastLED.show();
server.send(200, "text/plain", "Measuring Weight...");
}
//Calibration
void zero() {
myScale.tare();
}
void enter(){
float calibrationFactor = myScale.get_units(10)/1000; //Enter 1000 gramms
myScale.set_scale(calibrationFactor); //Set calibration factor (adjust as necessary)
}
float start() {
return myScale.get_units(10); //Read weight from the scale
}
void handleRoot() {
server.send(200, "text/html", R"rawliteral(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SYDE HTA Loadcell Response</title>
<style>
body { font-family: Arial, sans-serif; background-color: #f4f4f9; text-align: center; }
.container { max-width: 600px; margin: auto; background: white; padding: 20px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); border-radius: 10px; }
button { background-color: #02aff3; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
button:hover { background-color: #6e6e6e; }
</style>
</head>
<body>
<div class="container">
<h1>HTA Loadcell Communication Check</h1>
<p>1. Click on "Zero" before adding weight</p>
<p>2. Click "Enter" with 1000g beeing on the loadcell</p>
<p>(Change in the code if you have a different known Weight)</p>
<p>3. Click on "Start" to begin measurement.</p>
<button onclick="Zero()">Zero</button>
<button onclick="Enter()">Enter</button>
<button onclick="Start()">Start</button>
<h2 id="status">Status: Waiting...</h2>
<h2 id="weight">Weight: Waiting...</h2>
</div>
<script>
function Zero() {
fetch('/zero')
.then(response => response.text())
.then(data => document.getElementById("status").innerText = data);
}
function Enter() {
fetch('/enter')
.then(response => response.text())
.then(data => document.getElementById("status").innerText = data);
}
function Start() {
fetch('/start')
.then(response => response.text())
.then(data => document.getElementById("status").innerText = data);
fetchWeightContinuously();
}
function fetchWeightContinuously() {
setInterval(() => {
fetch('/weight')
.then(response => response.text())
.then(data => document.getElementById("weight").innerText = "Weight: " + data + "g");
}, 100);
}
</script>
</body>
</html>
)rawliteral");
}
void setup() {
Serial.begin(115200);
delay(6000); //Added delay after Serial.begin
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); //Declare and initialize the LED
FastLED.show();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
ipAddress = WiFi.localIP().toString();
Serial.println("Connected. IP: " + ipAddress);
leds[0] = CRGB::Green;
FastLED.show();
myScale.begin(dataPin, clockPin);
server.on("/", handleRoot);
server.on("/serial", handleSerialData);
server.on("/weight", handleWeightData);
server.on("/zero", handleZero);
server.on("/enter", handleEnter);
server.on("/start", handleStart);
server.begin();
}
void loop() {
server.handleClient();
if (Serial.available()) {
serialData = Serial.readString();
}
if (startMeasurement) {
int weight = start();
Serial.println("Measured Weight: " + String(weight));
serialData = "Measured Weight: " + String(weight);
webWeight = String(weight);
}
}
