/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Temperature Bluetooth - Source Code compiled for: Arduino Nano ESP32 - Source Code created on: 2024-10-02 23:16:55 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Initialize internal Bluetooth device as master, */ /* receive BLE data, and show it on a 16x2 LCD using */ /* LiquidCrystal library for Arduino. */ /****** SYSTEM REQUIREMENT 2 *****/ /* read temperature and send it via bluetooth. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include // https://github.com/arduino-libraries/LiquidCrystal #include // https://github.com/matmunk/DS18B20 #include // https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git #include // https://github.com/olikraus/U8g2_for_Adafruit_GFX #include // https://github.com/adafruit/DHT-sensor-library #include "BluetoothController.h" // Include the header for the LCD controller /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(); void sendTemperatureViaBluetooth(float temperature); /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // The instances are already defined in BluetoothController.h, so we do not redefine them here. void setup(void) { Serial.begin(9600); // Initialize serial communication pinMode(temperatureSensor_DHT22_DOUT_PIN, INPUT_PULLUP); initializeLCD(); // Initialize the LCD display setupDS18B20(); // Setup DS18B20 sensor dht.begin(); // Initialize the DHT sensor display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // Initialize the OLED display display.display(); // Clear the display delay(2000); display.clearDisplay(); } void loop(void) { updateOutputs(); // Refresh output data checkTemperature(); // Check temperature from DS18B20 } void updateOutputs() { // Example of updating LCD display lcd.setCursor(0, 0); lcd.print("Temp: "); float temperature = dht.readTemperature(); // Read temperature from DHT sensor lcd.print(temperature); lcd.print(" C"); // Send temperature via Bluetooth sendTemperatureViaBluetooth(temperature); } void sendTemperatureViaBluetooth(float temperature) { // Send the temperature data over Bluetooth Serial.print("Temperature: "); Serial.println(temperature); } /* END CODE */