DHT11 EEPROM

Hello!

I programmed a sketch that should save the temperature and the humidity in the eeprom
But I just get ovf and 0.
Here is he code:

#include <dht_nonblocking.h>
#include <EEPROM.h>
#define DHT_SENSOR_TYPE DHT_TYPE_11
//#define DHT_SENSOR_TYPE DHT_TYPE_21
//#define DHT_SENSOR_TYPE DHT_TYPE_22

static const int DHT_SENSOR_PIN = 2;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );

void setup( )
{
Serial.begin( 9600);
}
int addr = 0;
void loop( )
{
float temperature;
float humidity;

dht_sensor.measure(&temperature, &humidity);
Serial.print( "T = " );
Serial.print( temperature, 1 );
Serial.print( " deg. C, H = " );
Serial.print( humidity, 1 );
Serial.println( “%” );
EEPROM.write(addr, humidity);
EEPROM.write(addr + 1, temperature);
addr = addr + 2 ;

delay(1000);
if(addr > 999) while(1);
}

Can you help me?

float temperature;
  float humidity;

EEPROM.write(addr, humidity);
  EEPROM.write(addr + 1, temperature);

A variable of the float data type occupies 4 bytes.

The EEPROM functions put() and get() may be useful.

1. To write/store a single byte data in an EEPROM location, we use the following code:

EEPROM.write(addr, dataByte);

2. To store multiple data bytes (in this example: 2 bytes) in one GO, we may use the following code:

int x = 0x1234;
EEPROM.put(addr, x);  //lower byte goes into lower location

3. The following diagram (Fig-1) explains the storage mechanism of two floating point numbers/variables in memory; where each float variable/number occupies 4-byte locations. Lower byte of the data item gets stored into lower memory location.
![/code

... see next post


![floatArray.png|320x227](upload://wz2pPn219cBFxBHXKq4wFS5ihis.png)
Figure-1:

**4.** In view of Fig-1, the following codes (posted by you) are not storing the float type (4 bytes) humidity and temperature at the correct locations of the EEPROM. Do they?

float temperature;
float humidity;

EEPROM.write(addr, humidity);
EEPROM.write(addr + 1, temperature);


**5.** The correct codes are:

float temperature;
float humidity;

EEPROM.write(addr, humidity);  //one mistake -- write should be replaced by ?
==>

EEPROM.write(addr, temperature); // two mistakes -- one as above and the other is: addr should be .....
==>


![floatArray.png|320x227](upload://wz2pPn219cBFxBHXKq4wFS5ihis.png)