I am new to arduino but am trying to learn as i go. I am having issues with an else if statement I kind of hacked together to try to get a couple relays to turn on based off the temperature. At the moment I am able to get the relay to turn on when the temperature gets over the max number and will then shut off when it gets to a good area. I cant seem to get the other relay to turn on if the temperature drops below the min though? I have tested all my hardware to make sure everything is working and it all points me back to my code right now. Any help would be greatly appreciated.
Sorry I am also new to using these forums for help so I pasted the code below but also tried to attach a pic, not sure if the attachment worked?
honeys:
could anyone tell me the code which can convert frequency into hertz. my max req is from 1 to 30Hz. i have tried with pulsein() function but it bug the whole code
Please start a new thread instead of hijacking one that has absolutely nothing to do with your question.
At the moment I am able to get the relay to turn on when the temperature gets over the max number and will then shut off when it gets to a good area. I cant seem to get the other relay to turn on if the temperature drops below the min though?
I would suggest that you use a Serial print statement to verify that event.temperature is returning the value you think it is, and are testing for.
Explain more about the relays you are using.
What is the pulsed output all about. Are the relays active HIGH or LOW? delayMS is a value used in the sensor reading, why are you using it here for a pulse delay?
I'm a bit surprised that any of the delays are working, you declared sensor in Setup(), but never gave it any value, so delayMS ends up with a value of 0.
You need the following in Setup() to populate sensor with data:
@cattledog i did mentioned earlier i kind of hacked this together from other code and am trying to learn as i go. maybe that is my issue? i am really new at this and just like messing with technology and things.
i did have serial print with this code and it showed me the temperature and humidity going up and down properly when i was debugging. i removed it and it actually helped part of my code work better (ie. both relays would then shut off when the temperature was in the middle).
they relays i have are "HONG WEI 10A 250VAC 10A 30VDC; 10A 125VAC 10A 28VDC". cheap ones off amazon.. which i believe i have set up as active HIGH?
the pulse with the relay was just me trying to make sure it was going through parts of my code as again i am new to arduino and the coding for it.
i am used to excel vba editor where you get to walk through and see where your code goes wrong. is there anything like that for arduino by chance?
@david_2018 i actually did have that in my code when i started hacking, i will add that back but i was still having the issue with that info there.
they relays i have are "HONG WEI 10A 250VAC 10A 30VDC; 10A 125VAC 10A 28VDC". cheap ones off amazon.. which i believe i have set up as active HIGH?
Most of these photo isolated relays are active LOW. Are you confusing NO and NC with what the input signal needs to be to activate them?
In any case, the pulse code is not correct. Figure out what turns the relay on and off. Is there an indicator light for status?
Getting the relays to work properly with the temperature limits will be very straighforward, once you figure out how the relays actually work, and you make sure they are both wired the same.
@david_2018 i attached a jpeg of how i wired everything up to the arduino. i tried both switching the wires and switching the pinOut in the code and both relays seem to work fine.
Proietti:
I really dont understand your delays...nowhere do you state how long the delay should be.
For some reason, he is using the delays defined in the DHT library for the minimum delay between samples. For a DHT11, that is 1000000uS, giving a 1000mS delay in the code. Probably just a carryover from the example code from the library, where delayMS is used to delay between samples from the sensor.