I'm a beginner to coding. Internet and Google only took me so far.....
I'm trying to build A nextion-arduino nano thermostat.
It took me ages to find the right libraries and code to make the nano and nextion communicate.
I managed to create the code, the DHT11 is reading the temp and displays it over the Nextion.
I managed to make the setting buttons temperature up and down working( on the Nextion touch screen) . However after im putting the IF statements ( if temp is higher than set temp then is HOT) the buttons are not working anymore and the thermostat is not working.
Can anyone give me a suggestion before I suffer a mental breakdown :).
You are not using digitalWrite() correctly either:
digitalWrite(OUTPUT, 4);
The correct syntax is digitalWrite( pinNumber, state );
so you code should be
digitalWrite(4, HIGH); // or LOW
I would also recommend defining pins 2 to 5 rather than using the numbers. Give them meaningful names. (I'm not sure what that would be. maybe they have LEDs tied to them?)
const int coldPin = 2;
const int hotPin = 3;
const int dryPin = 4;
const int moistPin = 5;
and then use those names throughout your code rather than hardcoded numbers
I'll make the suggested settings. Basically when it will be cold, the pin is going to be connected to a relay to turn the heating on. Or if hot, to turn the vent on.
Basically when it will be cold, the pin is going to be connected to a relay to turn the heating on. Or if hot, to turn the vent on.
I'd need to see a schematic. Turning the relay on to turn a heater on makes sense. Turning the relay off, to turn a vent on, does not. First, you will have either the heater or the vent on all the time, since a relay is not a tri-state device. Second, a vent is not usually a powered device. It is open or closed, not on or off.