School Project HELP

Hi guys. I'm new to programming. First of all, I was told to do a thermometer project and I ran over Arduino. I bought myself an Arduino Leonardo + a DHT 11 Sensor. The teacher got so excited because it was his first time seeing this kind of "technology" just because it was not something normal a student would bring.

Anyways, as time went on, he kept asking me to do more and more updates to this thermometer. I added the humidity part, then he wanted me to make my own unit(?) and after that he wanted a greenhouse. But before the greenhouse he wants me to try to open and close a circuit... he wants something that goes on and off IF the humidity of the soil is LOW.

My code is

#include <DHT.h>
#include <DHT_U.h>

int pin_sensor = 2;
int vTemp = 0, vPelee = 0, vHum = 0;
int pin_switch = 3;

DHT dht(pin_sensor, DHT11);


void setup()
   {
       Serial.begin(9600);  
       dht.begin();
      
   }

void loop()
   {
    vTemp = dht.readTemperature();
    vHum  = dht.readHumidity();
    vPelee = dht.readTemperature();

    
    Serial.print("Temperatura: ");
    Serial.print(vTemp);
    Serial.print("C");
    Serial.print(" Humedad: ");
    Serial.print(vHum);
    Serial.print("%");
    Serial.print("  Pelee: ");
    Serial.print((vTemp+8)*1.5);
    
    if(vTemp > 24) {
      Serial.print("            La temperatura esta muy alto! Tiempo de enfriar " );
     }
     if(vTemp < 20) {
      Serial.print("            La temperatura esta muy baja! Ayuda! ");
     }

   
    Serial.println();
    
    delay(3000);

    
     
   }

Can anyone teach me the code for that specific work? I would greatly appreciate new lessons. Thank you!

unikskyseed:
he wants something that goes on and off IF the humidity of the soil is LOW.

The DHT11 measures the temperature of the air.

You have code doing the same for air temperature already - detect too high/too low. That's how you switch "something that goes on and off".

unikskyseed:
Hi guys. I'm new to programming. First of all, I was told to do a thermometer project and I ran over Arduino. I bought myself an Arduino Leonardo + a DHT 11 Sensor. The teacher got so excited because it was his first time seeing this kind of "technology" just because it was not something normal a student would bring.

Hi,
Welcome to the forum.
Well done, and good to hear you have a teacher that is prepared to keep you extending your capabilities.
You now need to show him/her that you can turn an LED ON/OFF for your humidity threshold.
Lookup pinMode and digitalWrite, in the Arduino REFERENCE page.

Tom.. :slight_smile:

You need to STOP now, and break some of those bad habits you are developing.

There is NO need to use delay(). Look at the blink without delay example, and learn how to periodically read the sensors and send data to the serial port without using delay.

You are wasting SRAM. String literals are copied from FLASH memory (where the code runs) to SRAM (where data is stored at run time) when the Arduino starts up, unless you take some action to stop that.

      Serial.print("            La temperatura esta muy alto! Tiempo de enfriar " );

uses 59 bytes of SRAM.

      Serial.print(F("            La temperatura esta muy alto! Tiempo de enfriar " ));

uses ZERO bytes of SRAM.

While neither issue might matter at the moment, your teacher just might ask you to log the data to an SD card, or to add an ethernet shield, and make the Arduino a server, so that clients (like web browsers) can view the temperature and humidity, and change the setpoints when the fan is turned on or off, when the heater is turned on or off, etc. Then, having used blocking functions, or wasted memory, WILL matter.

PaulS:
You need to STOP now, and break some of those bad habits you are developing.

There is NO need to use delay(). Look at the blink without delay example, and learn how to periodically read the sensors and send data to the serial port without using delay.

You are wasting SRAM. String literals are copied from FLASH memory (where the code runs) to SRAM (where data is stored at run time) when the Arduino starts up, unless you take some action to stop that.

      Serial.print("            La temperatura esta muy alto! Tiempo de enfriar " );

uses 59 bytes of SRAM.

      Serial.print(F("            La temperatura esta muy alto! Tiempo de enfriar " ));

uses ZERO bytes of SRAM.

While neither issue might matter at the moment, your teacher just might ask you to log the data to an SD card, or to add an ethernet shield, and make the Arduino a server, so that clients (like web browsers) can view the temperature and humidity, and change the setpoints when the fan is turned on or off, when the heater is turned on or off, etc. Then, having used blocking functions, or wasted memory, WILL matter.

What does the F mean right before the "? Is it like a memory saver or something? I did change it and it significantly reduce the global memory.

What does the F mean right before the "? Is it like a memory saver or something? I did change it and it significantly reduce the global memory.

The basics of Arduino memory and the F() macro are explained here
https://playground.arduino.cc/Learning/Memory

cattledog:
The basics of Arduino memory and the F() macro are explained here
Arduino Playground - HomePage

Thank you!