sleep mode after getting some value

Hello,

I am programming temperature sensor (exactly it is DHT11) and I want to turn my arduino into sleep mode after geting the same value like previously. Long story short, I do not want to have two identical messages. I have already wtritten some testing code, but it does not work. My problem is not, that i do not know, how to turn arduino to sleep, but that I have no idea, how to work with data, which DHT11 sent to serial monitor.

Thant you so much for your answers.

Start by posting your code. People can help point out what may be wrong. Without the code, who knows?

For posting instructions, see "How to use this forum" at the top of every topic page.

Iridium1944:
My problem is not, that i do not know, how to turn arduino to sleep, but that I have no idea, how to work with data, which DHT11 sent to serial monitor.
Thant you so much for your answers.

Put how to turn arduino to sleep into a Google search for some clues.

The definative guide is perhaps here;

https://www.gammon.com.au/forum/?id=11497

Please note exactly how to put your 'Arduino' to sleep does depend on which 'Arduino' you are using, so dont forget to mention which 'Arduino' you have when posting.

I do not know if you understand me… I do not have problem with turning arduino uno into sleep mode. I only need your advice. How I mentioned before, I do not want to have two identical messages and my plan is to achieve this by turning arduino into sleep mode after getting the same value, like previously.

BUT I do not know, how can you tell arduino to ascertain values from last message and compare the with new ones (and if are they identical → sleep).

By the way code will not help you. I know, I have written, that I had created some code, but this code does not relate with my question.

if (x == y) sleep();

If x and y are zero-terminated character arrays (C-strings), use strcmp() to compare them for equality.

OP probably has an example code that just prints the numbers out to serial and doesn’t realize that he could store them in variable instead.

If OP would take the advice given and post his code we might know and we might be able to help. As long as OP is ignoring the advice given all we can do is wait until he realizes that he needs to listen.

Iridium1944:
By the way code will not help you. I know, I have written, that I had created some code, but this code does not relate with my question.

So the changing the code you have written will not solve the the problem you are having ?

As far as I'm concerned, Irridium1994's problem is solved.

#include "DHT.h"
#include "LowPower.h"
#define pinDHT 5

#define typDHT11 DHT11 // DHT 11

DHT mojeDHT(pinDHT, typDHT11);

void setup() {

Serial.begin(9600);

mojeDHT.begin();
}

void loop() {

float tep = mojeDHT.readTemperature();
float vlh = mojeDHT.readHumidity();

// Only testing (the final code will not include this).

while (tep == 31.00) {

LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);}

if (isnan(tep) || isnan(vlh)) {
Serial.println("Chyba při čtení z DHT senzoru!");
}
else {

Serial.print("Teplota: ");
Serial.print(tep);
Serial.print(" stupnu Celsia, ");
Serial.print("vlhkost: ");
Serial.print(vlh);
Serial.println(" %");
}

delay (500);
}

jremington:
For posting instructions, see "How to use this forum" at the top of every topic page.

Please do as you have been asked. Ignoring our responses isn't going to get you any help any faster.

float tep = mojeDHT.readTemperature();
  float vlh = mojeDHT.readHumidity();

You just need a second set of variables to hold the old values. You can set them at the end of loop to equal these and on the next pass of loop you can compare the new readings to those.

Delta_G:
Please do as you have been asked. Ignoring our responses isn't going to get you any help any faster.

float tep = mojeDHT.readTemperature();

float vlh = mojeDHT.readHumidity();




You just need a second set of variables to hold the old values. You can set them at the end of loop to equal these and on the next pass of loop you can compare the new readings to those.

Yeah, thank you.