Hey Guys
I need some help Ive managed to get my Arduino Mega hooked up to a D1 robot LCD with 2 temp sensors and a relay i am using the temp sensors to regulate the temp of my ball-python setup and basically need both temps to regulate the temp of two different places
So they must get an average but at the moment im getting the sum of both temps so instead of 28 degrees im getting 62 degrees
How would i fix this
Haha sorry its a Type of snake and you get different species of them
Perhaps letting 'us' look at your well formatted code, posted in code tags would be a big help in getting to the root of the issue?
nepellew:
Haha sorry its a Type of snake and you get different species of them
That's still not very informative - this is programming Forum, not a reptile forum.
Are you trying to create a controlled environment in which snakes will live?
...R
So they must get an average but at the moment im getting the sum of both temps so instead of 28 degrees im getting 62 degrees
nepellew:
So they must get an average but at the moment im getting the sum of both temps so instead of 28 degrees im getting 62 degrees
How would i fix this
To get an average, you add the values and divide by the number of values. Did you forget to divide?
Hi John
Haha must have forgot to divide just trying to figure out where to divide because when i change to the / symbol it freezes
Hi there guys ok im not too clued up on where to divide
[for (int i = COUNT_DHT - 1; i >= 0; i--) {
float temperature = dhts[i].readTemperature();
float humidity = dhts[i].readHumidity();]
Hi,
We need to see your complete code.
Just half of a for loop is not enough.
Thanks.. Tom.. 
Hey Tom
I tried to upload code but think it exceeds the about of characters in the form
i have uploaded it as an attachment .
Thanks for the quick reply
Kevin_example.ino (14.3 KB)
Hi,
Thanks for the code.
Did you write it in stages, getting each stage working before starting the next.
You should have some code that JUST reads the two temperature inputs and averages them, nothing else.
If not, you would be best to write some code that just does that and get your average temperature working first.
Thanks.. Tom.. 
Hey tom had a mate overseas helping me do it so he just sent me the code and its hard to edit it once its written haha is there no way to assist with current already written code
There is a LOT of code in that Timer1_COMPA_vect ISR.
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 15624 * 2; // 31284
TCCR1B |= (1 << WGM12) | (1 << CS12) | (1 << CS10);
TIMSK1 |= (1 << OCIE1A);
It would help if there were some comments to say how often the interrupt was set for. Looks like CTC mode with TOP in OCR1A and prescale set to 1024. 31284 * 1024 is almost 32 million counts per cycle so about every 2 seconds?
It would be MUCH safer to use the millis() timer to execute that code every two seconds.
You only have one Temperature/Humidity sensor so after adding up all 1 samples you divide by 1 to get the average. If you are getting the wrong answer, perhaps the DHT library doesn't work with interrupts disabled (like they are inside an ISR).
In case you were still looking for the divide:
average_temperature = accumulated_temperature / COUNT_DHT;
average_humidity = accumulated_humidity / COUNT_DHT;
Thanks a ton will give it a try
Hi,
Do you have a circuit diagram?
Tom... 