Show Posts
Pages: [1] 2 3 ... 29
1  Using Arduino / Sensors / Re: What is 0.00 temperature on DS18B20? on: January 04, 2014, 07:50:52 am
Thanks so much robtillaart and el_supremo,

Yesterday night i was looking for CRC errors, following the @el_supremo comment, to learn about them, and i was exploring also the DallasTemperature library to see if it could something there what could help me.

On one hand i find something like these sentences:
Code:
sensors.isValid()
and sensors.reset()

However, the first one was related to a something old version of the library, and it doesn´t appear at present version. I saw the isConnected, but i assumed that when it returned FALSE the resulting temperature is -127   But i see that this is not true, thanls to the explanations of @robtillaart. Thanks so much!

On the other hand, if i do: sensors.reset(), Does it means that it reset all the sensors in the bus? and does it also reset the sensors resolution?

Thanks for thing how to solve this by changing the library. I am sure it will help a lot of people!

On the other hand, you are right, there are other type of sensors what i will use in the future since they are more accurate (0.1ºC or so, such as thermocouple and thermistors). However, for this first prototype, i was looking for something quick to install and to program, because i am worry about the general idea of the device (sensors, power supply, how to install the temperature busses in the field,...). for the next one i will consider real accurate sensors, and also a barebones board to reduce the consume, etc. In any case, the 0.5ºC is no bad at all. In fact, i already have installed in the field about 500 maxim temperature sensors with this resolution, and are quite enough for me purposes.

No, i am sorry. At this stage i didn´t have time to prepare the project webpage, although i have a blog where i write the adventures of your fieldtrips in antarctica. I will send you the link by a PM. In any case, thanks so much for you help to made this project run... We are studing the evolution of the frozen soils in the edge of the antarctic continent (where they are really sensible to small temperature increases), in order to have an "alarm-like" system of global warming and antarctic ice melting... So, your contributions help me to reduce the costs of the monitoring devices, what means more monitoring stations with similar economical costs... So... THANKS!
2  Using Arduino / Sensors / Re: What is 0.00 temperature on DS18B20? on: January 03, 2014, 05:35:16 pm
Thanks robtillaart one more time for you good comments,

Yes, i considered this option but the device will be working in Antarctica, and during some months during the summer the temperatures could reach 0.0ºC (at least for some bus, meanwhile not the others). For that reason, i think that try to detect that the sensors do not reply to the temperature request could be more realistic... at least for my scenario.

My idea is, if i am able to detect this condition, to do a soft reset by this code from this forum:
Code:
// Restart the program from beginning
void softReset() {
  asm volatile ("  jmp 0"); 
}

Thanks!!
3  Using Arduino / Sensors / What is 0.00 temperature on DS18B20? on: January 03, 2014, 02:08:13 pm
Hi all,

I have a project in which i have 4 1-wire busses with multiple ds18b20 temperature sensors connected that i read once per hour. Here is the complete code: http://forum.arduino.cc/index.php?topic=207166.0

You can see there that in the setup section i call for the sensors, read the number of devices in each bus, etc... Later, in the loop section, i request for temperatures in each bus in order to save them into an SD card.

I recenty discovered a rare behaviour. One 1-wire bus returned 0.00 values for all the sensors connected to it. I don´t understand what it means (of course, it is not 0ºC, because the other buses returned temperatures in agree with the environmental temperature, of about 11ºC), because if the device is not recognized or there is an error when reading the sensor, it should return -127.00 or 85.00 values.

When i tryed the "testing" example from DallasTemperature library, it required different tests, before to have them ready again.   
Now, the device is working well again with my original code, but i am scary about if it happend again, because the device will be stand alone and it will only checked ones per year...

Is any way to detect this kind of behaviour? For example, something like
Code:
if (! sensors.requestTemperatures()){
(i know this not works because i tryed).
Something to detect if the the sensors does not reply to that call for temperatures...

Thanks!!
4  Using Arduino / Programming Questions / Re: Comments & advices about my code on: December 29, 2013, 02:30:20 pm
You are right. I mean a switch to cut the led circuit. In this way, although the code try to turn on the led by a digital pin, the circuit is cut and the led remains off to save power.
Then, when the user want to check the devide (once per year in the better case), it should turn on the switch and then use the test button to check if it works ok and, in case, the higher type of error detected during device working
5  Using Arduino / Programming Questions / Re: Comments & advices about my code on: December 29, 2013, 12:54:42 pm
Thanks PaulS for your comments.

You are right about some comments and names of pins, variables and functions... i used the examples and codes to test each sensor and procedure, and when  putting all together i forgot to made the necessary modifications. Thanks for call my attention about it. Be sure i will modify it!

About the RTC.now(),
i must use it, because without it, the next calculation of the sleetime does not work. So, this code read the time from the RTC, and then i use the minutes and seconds to made the calculation. Without it, it simply does not work.

Cheers,

6  Using Arduino / Programming Questions / Third part of the code on: December 28, 2013, 01:13:16 pm
Code:
//  MAIN DEVICE PROGRAM
void loop(){
  detachInterrupt(0);                            // Disable test button
  DateTime now = RTC.now();                      // Check the present time
  if ((now.minute() == 0) && (abortSleep == false)){      // Measure if it is the time o'clok and the test button was not pressed
    Measurements();
    delay(100);
  }
  if (abortSleep == true){                       // Shows device status if button was pressed
    Checking();
    delay(100);
  }
  RTC.now();                                     // Check the present time to calculate sleeping time (in ms)                             
  sleepTime = (3600000UL - (((now.minute()*60UL) + now.second())*1000UL));
  delay(100);
  abortSleep = false;
  attachInterrupt(0, Awake, CHANGE);             //Activate again the test button on the board
  delay(100);
  sleep.pwrDownMode();                           // Set the sleep mode to maximum power save
  sleep.sleepDelay(sleepTime, abortSleep);       // Start to sleep during the calculated period, until waked up
}


//  PROCEDURES
// Sensors reading
void Measurements(){
  DateTime now = RTC.now();
  digitalWrite(Power, HIGH);                     // Turn on the sensor's power
  digitalWrite(TestLed, HIGH);                   // Turn on the led marking "Measurements in progress"
  delay(1000);
  n = n + 1;                                     // Update measurement counter
  datafile = SD.open(filename1, FILE_WRITE);     // Open the file to store the data
  if (datafile){
    datafile.print(n);                           // Save measurement number (counter)
    datafile.print(";");
    datafile.print(now.day(), DEC);              // Save date and time
    datafile.print("/");
    datafile.print(now.month(), DEC);
    datafile.print("/");
    datafile.print(now.year(), DEC);
    datafile.print(";");
    datafile.print(now.hour(), DEC);
    datafile.print(":");
    datafile.print(now.minute(), DEC);
    datafile.print(":");
    datafile.print(now.second(), DEC);
    datafile.print(";");
    datafile.print(readVcc());                   // Read and save battery voltage
    datafile.print(";");
    datafile.print(readTemp());                  // Read and save inner temperature
    datafile.print(";");
    datafile.print(analogRead(Battery));         // Read and save battery reading                   
    datafile.print(";");
    datafile.print(analogRead(SolarCell));       // Read and save solar cell reading                     
    datafile.print(";");
    sensors1.requestTemperatures();              // Read Air temperature sensor
    temp = sensors1.getTempC(airsensors[0]);
    datafile.print(temp);                        // Save Air temperature data
    datafile.print(";");
    if ((temp == -127)||(temp == 85)){           // Check for errors
      e = 6;
    }
    sensors2.requestTemperatures();              // Read Snow temperature sensors
    for (uint8_t i=0; i<14; i++){     
      temp = sensors2.getTempC(snowsensors[i]);
      datafile.print(temp);                      // Save Snow temperature data
      datafile.print(";");
      if ((temp == -127)||(temp == 85)){         // Check for errors
        e = 7;
      }
    }
    sensors3.requestTemperatures();              // Read Surface temperature sensors
    temp = sensors3.getTempC(surfacesensors[0]);
    datafile.print(temp);                        // Save Surface temperature data
    datafile.print(";");
    if ((temp == -127)||(temp == 85)){           // Check for errors
      e = 8;
    }
    sensors4.requestTemperatures();              // Read Ground temperature sensors
    for (uint8_t i = 0; i<10; i++){     
      temp = sensors4.getTempC(groundsensors[i]);
      datafile.print(temp);                      // Save Ground temperature data
      datafile.print(";");
      if ((temp == -127)||(temp == 85)){         // Check for errors
        e = 9;
      }
    }
    flux1 = analogRead(ThermalFlux1);            // Read Geothermal flux sensor 1
    datafile.print(flux1);                       // Save geothermal flux 1 (1023 levels)                   
    datafile.print(";");
    flux2 = analogRead(ThermalFlux2);            // Read Geothermal flux sensor 2
    datafile.print(flux2);                       // Save geothermal flux 2 (1023 levels)
    datafile.print(";");                       
    flux2 = (((flux2*5000)/2013)*FluxRes);       // Convert values
    datafile.print(flux2);                       // Save geothermal flux 2 (mW/cm^2)
    datafile.println(";");
    delay(100);
    datafile.close();                            // Close data file
  }
  else {                                         // Call error procedure if not able to save the data
    e = 5;
    error();
    return;
  }
  digitalWrite(Power, LOW);                      // Turn off the sensor's power
  digitalWrite(TestLed, LOW);                    // Turn off the led marking "Measurements in progress"
}


//Inner voltmeter
long readVcc() {
  long result;
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);  // Read 1.1V reference against AVcc
  delay(2);                                      // Wait for Vref to settle
  ADCSRA |= _BV(ADSC);                           // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result;                    // Back-calculate AVcc in mV
  return result;
}

//Inner temperature
long readTemp() {
  long result;
  ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3);   // Read temperature sensor against 1.1V reference
  delay(2);                                      // Wait for Vref to settle
  ADCSRA |= _BV(ADSC);                           // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = (result - 125) * 1075;                // Back-calculate temp in ºCx1000
  return result;
}

//  Stops the sleep process
void Awake(){
  abortSleep = true;
}

//  Shows the device status by a blinking led
void Checking(){
  for (byte i=0; i<3; i++){                      // Blink the led 3 times
    digitalWrite(TestLed, HIGH);   
    delay(500);
    digitalWrite(TestLed, LOW);
    delay(500);
  }
  for (byte i=0; i < e; i++){
    digitalWrite(TestLed, HIGH);                 // Red LED indicates higher error type
    delay(200);
    digitalWrite(TestLed, LOW);
    delay(200);
  }
  delay(500);
}

// Error control
void error() {
  for (byte i=0; i = e; i++){                   // Red LED indicates error
    digitalWrite(TestLed, HIGH);
    delay(200);
    digitalWrite(TestLed, LOW);
    delay(200);
  }
  delay(1000);
  while(1);                                     // Freeze the program because of the error
}
7  Using Arduino / Programming Questions / Second part of the code on: December 28, 2013, 01:12:37 pm
Code:
//  DEVICE INITIALIZATION
void setup(){
  pinMode(Power, OUTPUT);                        // Configure the power pin
  pinMode(TestLed, OUTPUT);                      // Configurate the working led
  pinMode(10, OUTPUT);                           // Configure SD card
  Wire.begin();                                  // Starts I2C communications
  //Serial.begin(9600);                          // Starts Serial comminications
  digitalWrite(TestLed, HIGH);                   // Turn off the test led
  RTC.begin();                                   // Start the RTC
  delay(50);  
  if (! RTC.isrunning()) {                       // Check if RTC is running
    e = 1;
    error();
    return;
  }
  if (! SD.begin(chipSelect)) {                   // Check if SD memory card is running
    e = 2;
    error();
    return;
  }
  if (! SD.exists(filename1)) {                  // Check and/or create the logdata file on SD Card
    datafile = SD.open(filename1, FILE_WRITE);   // Create the datafile if it doesn't exist
    datafile.close();
    if (! SD.exists(filename1)) {                // Check if datafile was created
      e = 3;
      error();
      return;
    }
    eeRead(0,config);                            // Read the header information from the EEPROM memory
    delay(30);
    datafile = SD.open(filename1, FILE_WRITE);   // Open the datafile and save the header on it
    if (datafile){
      //Datafile.println(config.header);
      //datafile.print("No;Date;Time;Bat(V);Sol(V);InV(V);InT(C);Air1(C);Sn1(C);Sn2(C);Sn3(C);Sn4(C);Sn5(C);Sn6(C);Sn7(C);Sn8(C);Sn9(C);Sn10(C);Sn11(C);Sn12(C);Sn13(C);Sn14(C);");
      //datafile.println("Surf1(C);Gr1(C);Gr2(C);Gr3(C);Gr4(C);Gr5(C);Gr6(C);Gr7(C);Gr8(C);Gr9(C);Gr19(C);GF1(-);GF2(-);GF2(mW/m2)");
      delay(30);
      datafile.close();
    }
    else {
      e = 4;
      error();
      return;
    }    
  }
  
  // Sensors initilization, configuration  and test
  digitalWrite(Power, HIGH);                     // Turn on the sensors
  delay(1000);
  sensors1.begin();                              // Initialize air temperature sensor bus
  sensors2.begin();                              // Initialize snow temperature sensor bus
  sensors3.begin();                              // Initialize surface temperature sensor bus
  sensors4.begin();                              // Initialize ground temperature sensor bus
  sn[0] = sensors1.getDeviceCount();             // Establish the number of sensors on air temperature bus
  sn[1] = sensors2.getDeviceCount();             // Establish the number of sensors on snow temperature bus
  sn[2] = sensors3.getDeviceCount();             // Establish the number of sensors on surface temperature bus
  sn[3] = sensors4.getDeviceCount();             // Establish the number of sensors on ground temperature bus
  for (byte i=0; i<4; i++){                      // Check if the number of sensors is correct in each bus
    if (! sn[i] == sensorsnumber[i]){
      e = 5;
      error();
      return;
    }
  }
  sensors1.setResolution(airsensors[0], Precision);    // Set the resolution of air temperature sensors
  for (byte i=0; i < 14; i++){                         // Set the resolution of snow temperature sensors
   sensors2.setResolution(snowsensors[i], Precision);
  }
  sensors3.setResolution(airsensors[0], Precision);    // Set the resolution of surface temperature sensors
  for (byte i=0; i < 10; i++){                         // Set the resolution of ground temperature sensors
    sensors4.setResolution(airsensors[i], Precision);
  }
  Measurements();                                // Take an initial measurement from sensors
  digitalWrite(Power, LOW);                      // Turn off the sensors
  
  digitalWrite(TestLed, LOW);                    // Turn off the test led
  abortSleep = false;                            //
  attachInterrupt(0, Awake, CHANGE);             // Activate the test button on the board
}
8  Using Arduino / Programming Questions / First part of the code on: December 28, 2013, 01:11:27 pm
Code:
//  DEVICE CONFIGURATION
//  Libraries definition
#include <Wire.h>                                // Library for I2C communications protocol
#include <RTClib.h>                              // Library for DS1307 RTC management
#include <eepromi2c.h>                           // Library for 24LC256 EEPROM management
#include <OneWire.h>                             // Library for 1-Wire communications protocol
#include <DallasTemperature.h>                   // Library for DS18B20 temperature sensor
#include <SD.h>                                  // Library for SD card management
#include <Sleep_n0m1.h>                          // Library for sleep and power save

//  Analogue pins definition
const int Battery = 0;                           // Battery voltage - Analog pin 0
const int SolarCell = 1;                         // Solar cell voltage - Analog pin 1
const int ThermalFlux1 = 3;                      // Geothermal Flux device - Analog pin 2
const int ThermalFlux2 = 2;                      // Geothermal Flux sensor - Analog pin 3

//  Digital pins definition
//const int TestButton = 2;                      // PermArduino working test button - Digital pin 2
const int TestLed = 9;                           // PermArduino working led - Digital pin 9
const int chipSelect = 10;                       // SD Card configuration - Digital pin 10
const int Power = 8;                             // Activation pin to power sensors - Digital pin 8
const int AirTemp = 4;                           // Air temperature sensor - Digital pin 4
const int SnowTemp = 5;                          // Snow temperature sensors chain - Digital pin 5
const int SurfaceTemp = 6;                       // Surface temperature sensor - Digital pin 6
const int GroundTemp = 7;                        // Ground temperature sensors chain- Digital pin 7

//  Variables definition
boolean abortSleep;                              // Cancel sleep cycle
unsigned int n = 0;                              // Measurements counter
volatile byte e = 0;                                      // Error type
byte sn[4];                                      // Sensors in each bus
unsigned int batt;                               // Store battery voltage
unsigned int solar;                              // Store solar cell voltage
float temp;                                      // Store temperature data
int flux1;                                       // Store geothermal flux (device) data
float flux2;                                     // Store geothermal flux (sensor) data

//  Constants definition
const float FluxRes = 41.8;                      // Resolution of Geothermal Flux 2 sensor (W·cm^-2/mV)

//  EEPROM data configuration
struct config {
  String header;
} config;

//  Log files
File datafile;                                   // File to store the adquired data
char filename1[] = "Data.csv";                   // Name of the file to store the data

//  Libraries configuration
RTC_DS1307 RTC;                                  // Configure library to read the Real Time Clock                      
Sleep sleep;                                     // Configure the library to sleep the Arduino board
unsigned long sleepTime;                         // Define the sleep time (in ms)
OneWire oneWire1(AirTemp);                       // Configure library to read air temperature sensors
DallasTemperature sensors1(&oneWire1);
OneWire oneWire2(SnowTemp);                      // Configure library to read snow temperature sensors
DallasTemperature sensors2(&oneWire2);
OneWire oneWire3(SurfaceTemp);                   // Configure library to read surface temperature sensors
DallasTemperature sensors3(&oneWire3);
OneWire oneWire4(GroundTemp);                    // Configure library to read ground temperature sensors
DallasTemperature sensors4(&oneWire4);
const byte sensorsnumber[4] = {1,14,1,10};       // Number of sensors in each bus
const byte Precision = 12;                       // DS18B20 precision configuration to 12 bits (0.0625ºC)

//  Sensors identification
uint8_t airsensors[1][8] = {                     // Air temperature sensors
  {0x28,0x96,0x38,0x20,0x05,0x00,0x00,0xE2}      // Sensor at 160 cm heigth
};
uint8_t snowsensors[14][8] = {                   // Snow temperature sensors
  {0x28,0x72,0x87,0x05,0x05,0x00,0x00,0xC6},     // Sensor at 2.5 cm height
  {0x28,0x72,0x8E,0x04,0x05,0x00,0x00,0xBA},     // Sensor at 5 cm height
  {0x28,0x22,0xF8,0x05,0x05,0x00,0x00,0xEA},     // Sensor at 10 cm height
  {0x28,0xB4,0xAE,0x04,0x05,0x00,0x00,0x6F},     // Sensor at 20 cm height
  {0x28,0xCB,0x84,0x04,0x05,0x00,0x00,0x96},     // Sensor at 30 cm height
  {0x28,0x79,0x10,0x06,0x05,0x00,0x00,0x50},     // Sensor at 40 cm height
  {0x28,0x52,0x30,0x05,0x05,0x00,0x00,0x6E},     // Sensor at 50 cm height
  {0x28,0xF8,0x77,0x05,0x05,0x00,0x00,0x45},     // Sensor at 60 cm height
  {0x28,0x60,0x41,0x06,0x05,0x00,0x00,0xC5},     // Sensor at 70 cm height
  {0x28,0xD2,0x8F,0x04,0x05,0x00,0x00,0x2B},     // Sensor at 80 cm height
  {0x28,0x04,0xA4,0x05,0x05,0x00,0x00,0x5A},     // Sensor at 100 cm height
  {0x28,0x51,0xF7,0x05,0x05,0x00,0x00,0x44},     // Sensor at 120 cm height
  {0x28,0x7E,0x2E,0x05,0x05,0x00,0x00,0x7B},     // Sensor at 140 cm height
  {0x28,0x42,0xEF,0x04,0x05,0x00,0x00,0x8B}      // Sensor at 160 cm height
};
uint8_t surfacesensors[1][8] = {                 // Surface temperatue sensors
  {0x28,0x4A,0x86,0x20,0x05,0x00,0x00,0xB6}      // Sensor at 1 cm depth  
};
uint8_t groundsensors[10][8]={                   // Ground temperature sensors
  {0x28,0x1C,0xC4,0x04,0x05,0x00,0x00,0x3E},     // Sensor at 2.5 cm depth
  {0x28,0xD4,0x2B,0x05,0x05,0x00,0x00,0x3A},     // Sensor at 5 cm depth
  {0x28,0x7E,0xFD,0x05,0x05,0x00,0x00,0x6B},     // Sensor at 10 cm depth
  {0x28,0xA5,0x57,0x04,0x05,0x00,0x00,0x56},     // Sensor at 20 cm depth
  {0x28,0xAF,0x1C,0x06,0x05,0x00,0x00,0x07},     // Sensor at 30 cm depth
  {0x28,0x7D,0x1E,0x05,0x05,0x00,0x00,0xA6},     // Sensor at 40 cm depth
  {0x28,0x6D,0xA6,0x04,0x05,0x00,0x00,0x03},     // Sensor at 50 cm depth
  {0x28,0x1E,0x86,0x05,0x05,0x00,0x00,0xB5},     // Sensor at 60 cm depth
  {0x28,0x3F,0x36,0x05,0x05,0x00,0x00,0x7B},     // Sensor at 70 cm depth
  {0x28,0xB4,0xFB,0x05,0x05,0x00,0x00,0xA7}      // Sensor at 80 cm depth
};
9  Using Arduino / Programming Questions / Comments & advices about my code on: December 28, 2013, 01:08:47 pm
Hi all,

I am working on a project to multiple temperatures by the use of DS18B20 sensors (not in parasitic way). The idea is to measure air temperature, snow temperature (at different heights -14-), surface temperature and ground temperature (at different depths -10-), each one in a different bus. I also have other 2 sensors connected to analog pins, as well as the battery and a solar cell by voltaje dividers. The device is powered by a solar cell and a Energy shield (by seedstudio) connected to an arduino duemilanove board.

I use an ds1307 to send the arduino to sleep and allow to measure once per hour, and save the data into an SD card. I also added and 4n35 optocoupler to power the sensors only when measuring (so save power), and a led to show that the device is measuring, as well as to see if there is an error during the setup, freezing the program. If the setup is ok, and the program runs perfect, the user could check whenever he want if an error ocurred latter, for example by fault of one of the sensors or SD Card corruption. For that reason i added a push button connected to digital pin 2 to test if by the use of interrupts (digital pin 2). To save power i added a switch to disconnect the led when not needed, because the device will be only checked once per year (in the better case).

Additionally i added an 24LC256 eeprom to save the error in case of a complete dissaster or the battery drain. I still didn´t  coded this part of the program.

I will post the code. Could you take a look? I would like to know your opinion and how to improve it, if able.
BTW, i observed a rare behaviour when pushing the button, because the checking code seems to repeat. I mean, when i push the button, the led should blink 3 times to say everything is ok. However, it occurs twice... Is not bad, because the user have two opportunities to count the led blinks to know the error, but i didn´t write the code in this way. So, just only i would like to know why.

Thanks so much, and thanks from now for any comment or idea.
Cheers!
10  Using Arduino / Programming Questions / Re: Problems on delay calculation on: December 12, 2013, 05:17:04 pm
MY BAD. YOU ARE COMPLETELY RIGHT! SORRY.

I made a mixture between the present time and the remaining time. So, you are completely right!

Thanks so much for your piece of code. It works PERFECT!
Code:
DateTime now = RTC.now();                                          
sleepTime = (3600000UL - (((now.minute()*60UL) + now.second())*1000UL));

Thanks!
11  Using Arduino / Programming Questions / Re: Problems on delay calculation on: December 12, 2013, 03:42:22 pm
Hi Pete,

You are my hero! Thanks so much for your explanation and code. I didn´t know that about the arithmetic!

However, i still think that it is necesary to substract the seconds to reach the time o'clok... THis is how i see it:
If time is, for example: 21:30:40, it means that the next time to measure is at 22:00:00, the, it means 29 minutes and 20 seconds, it is: 29 minutes X 60 seconds =  1740 seconds + 20 seconds = 1760 seconds, right?
By the equation i presented above, it reads the minutes (30), and the seconds (40), then: 30 minutes x 60 seconds = 1800 - 40 seconds = 1760. Am i right?

In order to test the code you propose to correct my wrong code i made this short version to read each minute:
Code:
sleepTime = (60000UL - ((now.second())*1000UL));
and this is the result:
Quote
22:8
52000
23:5
55000
24:4
56000
25:5
55000
26:4
56000
27:4
56000
28:5
55000
29:4
56000

and, when i try with the whole period (1 hour), using your code but substracting the seconds, it return correct values:
Quote
40:11
1211000
43:1
1021000

Note: Numbers are minutes and seconds, and below the, the miliseconds to reach the next minute (above) or o'clock time (below).
12  Using Arduino / Programming Questions / [SOLVED] Problems on delay calculation on: December 12, 2013, 02:56:29 pm
I use the Sleep_n0m1 library to sleep the arduino duemilanove board for a long time (about one hour) to read different temperature sensors at each hour o'clock.
This is the library:
https://github.com/n0m1/Sleep_n0m1

This is the pieceof  code what send the arduino board to sleep :
Code:
 sleep.pwrDownMode();                                               // Set the sleep mode to maximum power save
  sleep.sleepDelay(sleepTime, abortSleep);             // Start to sleep during the calculated period, until waked up

I am using a ds1307 rtc to read the time, and then i calculate for how long should sleep the board by this simple equation included in the code:
Code:
 DateTime now = RTC.now();                                          // Calculate sleeping time until next measurement
  sleepTime = (3600000-(((now.minute()*60)-now.second())*1000));    // Mileseconds to reach the next hour o'clok
 Serial.println(sleepTime);
what goes inmediatly before to call the sleep procedure.

The problem is what when i run the program, the sleep time printed on the serial port was 3608192 but it should be not more than 900000 miliseconds to the next time o'clock!

So, what am i doing wrong?

I tested by using smaller frequency (1 minute), and i observed that the first 2 measurements does not fitt, but at the third one it returns correct values...
Any idea of this rare behaviour?
Thanks!

13  Using Arduino / Project Guidance / Re: Wake and sleep on: December 10, 2013, 04:40:42 pm
You could also try this library:
https://github.com/n0m1/Sleep_n0m1
14  Using Arduino / Sensors / Re: [SOLVED] Reading DS18B20 in the correct sequence on: December 09, 2013, 02:32:07 pm
One small step:

By changing the definition in the loop the sequence error seems to be solved:
Code:

for (uint8_t i=0; i<4; i++){ 
    if ((bus[i].getDeviceCount())<(sensorsnumber[i])){
      Serial.print("error on bus ");
      Serial.println(i);
    }
  }

Now i still have error on getting device count (0) in each bus, but the infinite error call is solved.

After studing the code, i think that the problem is located how the array of buses is defined:
Code:
DallasTemperature bus[4] = {sensors1, sensors2, sensors3, sensors4};

I don´t know how to define in other way what could be correct... i tryied this:
Code:
DallasTemperature bus[4] = {sensors1(&oneWire1), sensors2(&oneWire2), sensors3(&oneWire3), sensors4(&oneWire4};

But it is not recognized by arduino IDE:
Quote
no match for call to '(DallasTemperature) (OneWire*)'

So, still working on this.
15  Using Arduino / Storage / Re: Write char on eeprom by this library on: December 08, 2013, 04:41:53 pm
I really do not have idea... i never used eeprom devices before... so, i do not know well how they works... I was only looking for an easy and light way to store data in it... But i don´t know how the code works...

I will take a look to the library you use to see how could i work with it.
Thanks again for your comments and tips!
Cheers
Pages: [1] 2 3 ... 29