My sketch validates, but i get no response from my arduino after upload

Ok, to start from the beginning…

I’m trying to build an egg incubator, mostly for fun, but also because i soon will need one as i have quails, and to buy a nice quality incubator cost a lot of $$$… and ofc that was a good reason to buy an arduino instead and try to build it my self… :grin:

Underway while experimenting with the different sensors and stuff i bought, I found this that i think gives a great way to make many small scripts come together, and the code looks neat and clean after.

I have basically no C++ programming skills, but i have done some html and php.

But now i have a problem, because my script validates and uploads to my arduino, but nothing happens!

I even tried with other example codes to test the pins, and they work fine, the whole unit seems to work just fine… but after uploading my script, i get nothing…

so now i hope some of you can help, as i’ve stared my self blind on the problem…

Ok, here is the code:

// ----------LIBRARIES--------------

#include "DHT.h"

// --------CONSTANTS (won't change)---------------
#define DHTPIN 2
#define DHTTYPE DHT22

const int fanHumPin =  10;        // the pin numbers for humidity +
const int heaterPin =  11;        // the pin numbers for heater +
const int fanExitPin =  12;       // the pin numbers for hum - and heater -

const int tempMin = 37;   // in celcius
const int tempMax = 38;   // in celcius
const int humMin = 65;   // in %RH
const int humMax = 67;   // in %RH

//------------ VARIABLES (will change)---------------------

byte fanHumState = LOW;           // used to record whether the unit are on or off
byte heaterState = LOW;           //   LOW = off
byte fanExitState = LOW;

float rhDHT = dht.readHumidity();
float tempDHT = dht.readTemperature();


void setup() {
      // set the Led pins as output:
  pinMode(fanHumPin, OUTPUT);
  pinMode(heaterPin, OUTPUT);
  pinMode(fanExitPin, OUTPUT);


void loop() {
  float rhDHT = dht.readHumidity();
  float tempDHT = dht.readTemperature();


//============== humControl ================

void humControl() {
  if(rhDHT < humMin) {
    fanHumState = HIGH;
  if(rhDHT >= humMax) {
    fanHumState = LOW;
//============== heatControl ================
void heatControl() {
  if(tempDHT < tempMin) {
    heaterState = HIGH;
  if(tempDHT >= tempMax) {
    heaterState = LOW;

//============== exitFanControl ================
void exitFanControl() {
  if(rhDHT > humMax || tempDHT > tempMax) {
    fanExitState = HIGH;
  else {
    fanExitState = LOW;

//=============== change relays ===============
void changeRelay() {
  digitalWrite(fanHumPin, fanHumState);
  digitalWrite(heaterPin, heaterState);
  digitalWrite(fanExitPin, fanExitState);
//============ serial.print =============
void serialPrint() {
  Serial.print("Temp: ");
  Serial.print("RH: ");

If you got any idea, please feel free to :stuck_out_tongue_closed_eyes: :grin:

I even tried with other example codes to test the pins, and they work fine, the whole unit seems to work just fine… but after uploading my script, i get nothing…

Really “nothing”?

If you even not get the “starting…” message in the serial monitor, set the baudrate in the serial monitor to the same you use in your program: 9600 baud.

Hi, welcome to the forum.

When you say that you get nothing, we are wondering what nothing is. I hope at least a led on the Arduino board is turning on, that is something :wink:
Which Arduino board are you using ?
What is printed to the serial monitor ?

(while I was typing this, als jurs noticed the nothing)

Hi, thanks!

The baudrate is the same in serial monitor as the script, and i don’t get the “starting…” message.

I use a cheap china uno r3 clone with ATMEGA328P-AU. the board works fine with all other examples i’ve tried.

I guess i don’t get nothing, i do get some leds… :grin:

What i meant was, there is no response in the serial monitor or any relays turning on as they should do.

The “ON” and “L” led is on. See photo of the unit attached

It that a white wire in pin 1 ?
What is that doing there ? Pin 1 is TX.
You better not use pin 0 (RX) and pin 1 (TX), those are used to upload a sketch and for the serial monitor.

What you could do in situations like this, is to test if your board is still okay. Remove all the wires and create a new test sketch. In that sketch, let the system led at pin 13 blink, or write something to the serial monitor. Keep the test sketch as small as possible, and don't include any library.

The baudrate is the same in serial monitor as the script, and i don't get the "starting..." message.

Is the DHT sensor connected to a "pull-up" resistor on the data wire?

What happens if you remove all connected hardware from the board except the DHT sensor and its pull-up resistor? Do you see the "starting..." message then?

the white one is on pin 2, and the greenish on pin 3. The board works fine with other sketches, and i've also tested those pins that are connected to the relayboard(10-11-12) with the blink sketch to turn on and of the relays(just to test if they where working, and they are)

The DHT sensor data is connected directly to the pin 2, and it works just fine with the DHTtest and in other scripts i made to print out the data to an oled display. i have also tried the DHT sensor with the oled to test if the dht was defect, and it works just fine.

Thanks for your reply!

After some testing, i found that skipping the

float rhDHT = dht.readHumidity();
float tempDHT = dht.readTemperature();

and change that with

void humControl() {
  if(dht.readHumidity() < humMin) {
    fanHumState = LOW;
  if(dht.readHumidity() >= humMax) {
    fanHumState = HIGH;

it seems to work just fine…

now my question is why…?

And another question, why does HIGH represent “off” and LOW “on” on my relay board? is it just the way it’s build?

is it just the way it's build?


In the original codr you had 2 different variables declared named rhDHT. One global and one local to loop(). In the himControl() function the global one was being used, not the one that you had just saved the humidity into. The same with tempDHT,