Show Posts
Pages: 1 [2] 3 4 ... 19
16  Using Arduino / Programming Questions / Date/Time for RTC as seconds since 1/1/2000 on: December 10, 2013, 12:45:26 pm
Hi,

I have been using the nice DS3231 RTC along with this library https://gist.github.com/jeje/2021145

I would like to be able to set the alarm interupt with the number of seconds since 1/1/2000, ie the starting date for this RTC as reported by this function: 
Code:
Serial.print(now.get(),DEC);

The Alarm is currently set by this function which uses hours, minutes and seconds:
Code:
RTC.enableInterrupts(18,4,16)
; //ie 18:04:16

Is there a clever coder out there who may guide me on how to write a function that uses Seconds since 1/1/2000 to set the alarm?  This would very simply allow me to query the current time with
Code:
now.get
and then add a number of seconds and set the alarm - the nice thing about this would be that all the roller-overs of minutes and hours would be taken care of :-)

The
Code:
RTC.enableInterrupts(18,4,0);
code from the library that I would like to change to
Code:
RTC.enableInterrupts(440003968);


Code:
//Enable HH/MM/SS interrupt on /INTA pin. All interrupts works like single-shot counter
void DS3231::enableInterrupts(uint8_t hh24, uint8_t mm, uint8_t ss)
{
unsigned char ctReg=0;
ctReg |= 0b00011101;
writeRegister(DS3231_CONTROL_REG, ctReg); //CONTROL Register Address
 
writeRegister(DS3231_AL1SEC_REG, 0b00000000 | bin2bcd(ss) ); //Clr AM1
writeRegister(DS3231_AL1MIN_REG, 0b00000000 | bin2bcd(mm)); //Clr AM2
writeRegister(DS3231_AL1HOUR_REG, (0b00000000 | (bin2bcd(hh24) & 0b10111111))); //Clr AM3
writeRegister(DS3231_AL1WDAY_REG, 0b10000000 ); //set AM4
}

17  Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: December 02, 2013, 04:46:35 pm
Thanks DC42, much appreciated.

Thanks for pointing out my way too small variable - I really didn't spot that one   smiley-red

Yip, that datasheet needs correcting doesn't it - well spotted, I will email them.  I have my CSB and PS tied as you describe but I'm still not getting good responses - I do get something back which is a start I guess.

I will keep plugging away and post back some code here when I get this working - cheers.
18  Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: November 28, 2013, 05:53:18 pm
Yip, this new MCU looks great, Arduino could do with a nice low-power option for battery powered applications - I will keep watching with interest.  I have used Tindie from the UK before so count me in for a nice 841 low power board :-)
19  Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: November 28, 2013, 02:35:38 pm
Still chipping away at this :-)

I'm now wondering if this is something to do with Arduino WIRE using 7 bits and this device using 8 bits - could this be the issue, can I still use this sensor with the Arduino WIRE library and if so how ?

This is what the byte structure looks like:


Cheers
20  Development / Other Hardware Development / Re: New ATTiny Part (ATTiny841) on: November 28, 2013, 09:10:11 am
Hi, will this new MCU be supported by the Arduino IDE?  Thanks.
21  Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: November 23, 2013, 07:52:01 am
Getting a bit closer - this code makes much more sense and delivers a result but it is the same result each time round the loop regardless of temperature?

Code:
#include <Wire.h>
#define TSYS01Address 0x77
#define TSYS01Reset 0x1E
#define TSYS01StartReg 0x48
#define TSYS01TempReg 0x00
long tempReading = 0;
float finalTempC = 0.0000;
byte MSB;
byte OSB;
byte LSB;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  TSYS01INIT();
}

void loop() {
  delay(100);
  TSYS01GetTemp();
  finalTempC = (tempReading/128.0);
  Serial.print("Temperature: ");
  Serial.print(finalTempC);
  Serial.print((char)176); // Degree symbol.
  Serial.println('C');
  Serial.print("MSB: ");
  Serial.println(MSB);
  Serial.print("OSB: ");
  Serial.println(OSB);
  Serial.print("LSB: ");
  Serial.println(LSB);
  Serial.println("-------------------------");
  Serial.println(" ");
  delay(5000);
}

void TSYS01INIT() {
  Wire.beginTransmission(TSYS01Address);
  Wire.write(0x1E);
  Wire.endTransmission();
}

void TSYS01GetTemp()
{
  Wire.beginTransmission(TSYS01Address);
  Wire.write(TSYS01StartReg);
  Wire.endTransmission();
  delay(100);

  Wire.beginTransmission(TSYS01Address);
  Wire.write(TSYS01TempReg);
  Wire.endTransmission();
 
  Wire.requestFrom(TSYS01Address,3);
  MSB = Wire.read();
  OSB = Wire.read();
  LSB = Wire.read();

  tempReading = ((MSB << 16) | (OSB << 8) | LSB);
}
22  Using Arduino / Sensors / Re: TSYS01 - function to read temperature...... on: November 22, 2013, 03:40:53 pm
..... I'm attempting to get this going with the little knowledge I have...... so far my code looks like this clearly there are some big mistakes on my part  smiley-red  At this stage I just hoping to start the conversion and then read the ADC result - once I can get a result I can work on converting this to a temperature.

Code:
#include <Wire.h>
#define address 0x77
int temperature;
const int data_bytes = 7;
byte result_buffer [data_bytes];


void setup()
{
  Serial.begin(9600);
  Wire.begin();
  Serial.println("TSYS01 Test");
}

void loop()
{   
    Serial.println("");
    ReadTSYS01();
    Serial.println("----------------");
    delay(1000);
}

int ReadTSYS01()
{
  Serial.println("Read TSYS01");
  Wire.beginTransmission(address);
  Wire.write(0x48);
  Wire.endTransmission();
 
  Wire.beginTransmission(address);
  Wire.write(0x00);
  Wire.endTransmission();
  Wire.requestFrom(address, data_bytes);

  while (!Wire.available ());
  for (int i = 0; i < data_bytes; ++i)
  {result_buffer [i] = Wire.read();}
 
  for (int i=0;i<7;i++)
  {
   byte d = result_buffer [i];
   if (i==1) temperature = d;
   if (i==2) temperature = (temperature << 8) | d;
  }
 
  Serial.print("Result: ");
  Serial.println(temperature);
 
}
23  Using Arduino / Sensors / TSYS01 - function to read temperature...... on: November 22, 2013, 02:34:03 pm
Hi all,

I have finally managed to solder my TSYS01 high accuracy temperature sensor to a PCB and now I am looking to write a function to read the 24bit temperature value via I2C but the example looks pretty daunting to my eyes.... wondering if anyone can point me in the right direction on how to do this in Arduino speak?  http://meas-spec.com/downloads/TSYS01_Application_Note.pdf

Any pointers very much appreciated.
24  Topics / Science and Measurement / SODAQ - a nice Arduino Low Power Wireless Data Logging Project on: November 18, 2013, 10:06:27 am
Hi,

First up I will place my cards on the table: I'm not involved with the project.... but I am a backer :-)

Just thought this might be of interest to quite a few people who, like me, use Arduino to collect and send sensor data - nice project which looks like it will have legs :-)

http://www.kickstarter.com/projects/386717175/sodaq-a-lego-like-plug-in-rapid-prototyping-board

Enjoy.
25  Using Arduino / General Electronics / Re: 2N7000 as power swtich ? on: October 10, 2013, 06:07:26 am
Thanks again Nick, I will do some reading and learn a little more about MOSFET MATH so I can fully understand :-)  Cheers.
26  Using Arduino / General Electronics / Re: 2N7000 as power swtich ? on: October 10, 2013, 04:09:34 am
... forgot to ask if I need to change the power switching circuit in any way if my system is 3V3?
27  Using Arduino / General Electronics / Re: 2N7000 as power swtich ? on: October 10, 2013, 04:07:06 am
Hej Nick, that's pretty impressive and very encouraging.  Do you know how long the AAs last for in the field?  I'm looking forward to getting my tests going again to see if I can shave a mere 393uA of my baseline :-)
28  Using Arduino / General Electronics / Re: 2N7000 as power swtich ? on: October 09, 2013, 04:23:33 pm
Hi Nick,

Thats just what I was looking for, thank you.
May I ask how you deal with restarting the SD card in code each time you use it as powering off presumably means reinitialising?
Was the 6-7 uA in powerdown a measured value?  very impressive - I'm currently running at 400uA !!!  I need to get this lower :-)
29  Using Arduino / General Electronics / Re: 2N7000 as power swtich ? on: October 09, 2013, 12:28:46 pm
Thanks Mike,

Is there any advantage of going for a P channel FET over say the circuit below (which may also be wrong?) in terms of keeping this a really low power switch?  Maybe the question should be more like: what is the best way to switch periferals on and off with low power consumption as the main aim?
30  Using Arduino / General Electronics / 2N7000 as power swtich ? on: October 09, 2013, 10:45:47 am
Hi, I am looking to switch an SD card on and off to allow maximum power saving in SLEEP mode and wonder if using a 2N7000 Mosfet to switch the SD 3V3 supply via arduino pin D2 is the best bet?

My circuit looks like this which may be wrong, any pointers appreciated.


Pages: 1 [2] 3 4 ... 19