diff --git a/ESP32/Artez_Reactor/Artez_Reactor.ino b/ESP32/Artez_Reactor/Artez_Reactor.ino new file mode 100644 index 0000000..0b4087d --- /dev/null +++ b/ESP32/Artez_Reactor/Artez_Reactor.ino @@ -0,0 +1,189 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include "fontdef.h" +//#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` +#include "SSD1306Wire.h" +#include "OLEDDisplayUi.h" +#include + +Servo myservo; // create servo object to control a servo +int servoPin = 23; + + +// Initialize the OLED display using Wire library +SSD1306Wire display(0x3c, 21, 22); + +#define DHTPIN 25 // Digital pin connected to the DHT sensor +#define DHTTYPE DHT11 // DHT 11 +//#define DHTTYPE DHT22 // DHT 22 (AM2302) +//#define DHTTYPE DHT21 // DHT 21 (AM2301) +DHT_Unified dht(DHTPIN, DHTTYPE); + +uint32_t delayMS; + +int count1 = 0; +long int deltask1 = 30 * 60 * 1000 / portTICK_PERIOD_MS; // 30 min + +//long int deltask1 = 1 * 60 * 1000 / portTICK_PERIOD_MS; // 30 min + + +int transPin = 14; +int ledPin = 22; + +//////////////////////// +void task1(void * parameters) { + for(;;){ + servoDance(); + vTaskDelay(deltask1); + } +} + + +///////////////////////// +void servoDance(){ + +for(int n=1; n<=10; n++){ + myservo.write(90); + delay(500); + myservo.write(180); + delay(500); +} + + myservo.write(90); + +} + + +//////////////////////// +void setup() { + + Serial.begin(115200); + + myservo.setPeriodHertz(10); + myservo.attach(servoPin); + +// pinMode(transPin, OUTPUT); +// pinMode(ledPin, OUTPUT); +// +// digitalWrite(ledPin,HIGH); + + helloHuman(); // init OLED display + initTempSensor(); // init temperature sensor + + + xTaskCreate( + task1, // function name + "Task1", // task name + 1000, // stack size + NULL, // task parameters + 1, // priority (low = more priority) + NULL // task handle + ); + +} + + + +void ShowTemperature(){ + // SENSOR AND DISPLAY + display.clear(); + + // Delay between measurements. + delay(delayMS); + // Get temperature event and print its value. + sensors_event_t event; + dht.temperature().getEvent(&event); + if (isnan(event.temperature)) { + Serial.println(F("Error reading temperature!")); + } + else { + display.setFont(Monospaced_bold_16); + display.drawString(0, 10, "Temp:"); + display.drawString(50, 10, String(int(event.temperature)) + " c" ); + + Serial.print(F("Temperature: ")); + Serial.print(event.temperature); + Serial.println(F("°C")); + } + // Get humidity event and print its value. + dht.humidity().getEvent(&event); + if (isnan(event.relative_humidity)) { + Serial.println(F("Error reading humidity!")); + } + else { + display.setFont(Monospaced_bold_16); + display.drawString(0, 50, "Hum:"); + display.drawString(50, 50, String(int(event.relative_humidity)) + " %"); + + Serial.print(F("Humidity: ")); + Serial.print(event.relative_humidity); + Serial.println(F("%")); + } + + display.display(); +} + + +//////////////////////////// +void initTempSensor(){ + // Initialize DHT device. + dht.begin(); + Serial.println(F("DHTxx Unified Sensor Example")); + // Print temperature sensor details. + sensor_t sensor; + dht.temperature().getSensor(&sensor); + Serial.println(F("------------------------------------")); + Serial.println(F("Temperature Sensor")); + Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); + Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); + Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); + Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("°C")); + Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("°C")); + Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("°C")); + Serial.println(F("------------------------------------")); + // Print humidity sensor details. + dht.humidity().getSensor(&sensor); + Serial.println(F("Humidity Sensor")); + Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); + Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); + Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); + Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("%")); + Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("%")); + Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("%")); + Serial.println(F("------------------------------------")); + // Set delay between sensor readings based on sensor details. + delayMS = sensor.min_delay / 1000; + +} +//////////////////////// +void helloHuman(){ + // Initialising the OLED display + display.init(); + display.flipScreenVertically(); + display.setTextAlignment(TEXT_ALIGN_LEFT); + display.clear(); + + display.setFont(Monospaced_bold_16); + display.drawString(0, 0, "Hello Human!"); + display.setFont(Monospaced_plain_12); + display.drawString(20, 30, "How are you"); + display.drawString(40, 50, "today?"); + + display.display(); + + delay(3000); + +} + +//////////////////////// +void loop() { + ShowTemperature(); + delay(1000); +} diff --git a/ESP32/D1-ESP32-SIMPLESERVO/D1-ESP32-SIMPLESERVO.ino b/ESP32/D1-ESP32-SIMPLESERVO/D1-ESP32-SIMPLESERVO.ino index 4bf5356..2569e85 100644 --- a/ESP32/D1-ESP32-SIMPLESERVO/D1-ESP32-SIMPLESERVO.ino +++ b/ESP32/D1-ESP32-SIMPLESERVO/D1-ESP32-SIMPLESERVO.ino @@ -6,13 +6,13 @@ Servo myservo; // create servo object to control a servo int servoPin = 23; void setup() { - myservo.setPeriodHertz(50); + myservo.setPeriodHertz(10); myservo.attach(servoPin); } void loop() { - myservo.write(0); - delay(2000); + myservo.write(90); + delay(500); myservo.write(180); - delay(2000); + delay(500); } diff --git a/TeZ-BioReactor_web.pdf b/TeZ-BioReactor_web.pdf index 2ad9ef2..0b33fd2 100644 Binary files a/TeZ-BioReactor_web.pdf and b/TeZ-BioReactor_web.pdf differ