Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: SOC_and_SOH_estimation
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-22 18:53:28
- - Source Code generated by: ANTU
- ********* Pleasedontcode.com **********/
- /********* User code review feedback **********
- #### Feedback 1 ####
- - worst code
- ********* User code review feedback **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <DHT.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* soc and soh estimation of battery */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t DHT_PIN = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DHT dht(DHT_PIN, DHT22);
- void setup(void)
- {
- // Initialize serial communication
- Serial.begin(9600);
- Serial.println(F("DHTxx test!"));
- // Initialize DHT sensor
- pinMode(DHT_PIN, INPUT_PULLUP);
- dht.begin();
- }
- void loop(void)
- {
- // Delay for 2 seconds
- delay(2000);
- // Read temperature and humidity from DHT sensor
- float humidity = dht.readHumidity();
- float temperature = dht.readTemperature();
- float temperatureF = dht.readTemperature(true);
- // Check if any reading is invalid
- if (isnan(humidity) || isnan(temperature) || isnan(temperatureF))
- {
- Serial.println(F("Failed to read from DHT sensor!"));
- return;
- }
- // Compute heat index
- float heatIndexC = dht.computeHeatIndex(temperature, humidity);
- float heatIndexF = dht.computeHeatIndex(temperatureF, humidity, false);
- // Print sensor data to serial monitor
- Serial.print(F("Humidity: "));
- Serial.print(humidity);
- Serial.print(F("% Temperature: "));
- Serial.print(temperature);
- Serial.print(F("°C "));
- Serial.print(temperatureF);
- Serial.print(F("°F Heat index: "));
- Serial.print(heatIndexC);
- Serial.print(F("°C "));
- Serial.print(heatIndexF);
- Serial.println(F("°F"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement