I have a Honeywell differential pressure sensor HSCDDRD005PD3A3. I have programmed this sensor (without using HSC library) and am able to read data from it.
If you aren't married to the idea of an SD card or shield, then using CoolTerm (free, with option to donate) for your Serial Monitor has an option of adding timestamps as well as capture to textfile.
I have used it in projects with very satisfactory results.
There is a working example here which includes SD file management.
I am not able to open this link. Can you please post it again?
If you aren't married to the idea of an SD card or shield, then using CoolTerm (free, with option to donate) for your Serial Monitor has an option of adding timestamps as well as capture to textfile.
I specifically want to transfer the data on to a SD card.
I have connected the A4 (SDA) and A5 (SCL) pins of the arduino to the pressure sensor and from the pressure sensor, I have connected these pins to DS3231.
Is there any other way to connect?
Note that Weeman makes a good point. You only need SD for backup or when operating remote form a PC.
Also, I have connected the A4 (SDA) and A5 (SCL) pins of the arduino to the pressure sensor and from the pressure sensor, I have connected these pins to DS3231.
Is there any other way to connect?
No. Both devices are I2C, and are meant to share the pins but, while you have defined the sensor, you do not appear to have defined the RTC. It should look something like
#define DS3231_ADDRESS 0x68
I assume the code compiles, so it may be in the library but, if you are having problems with time, maybe that is why.
Perhaps you are too eager to make it work. If it doesn't work, print more data to the serial monitor. Test each part seperately (you have already done that), and make seperate sections in the sketch.
For example a section that prints the time, before the sensor is used. And print the time after the sensor is used.
To be sure that the I2C data is valid, check the return value of Wire.endTransmission() and Wire.requestFrom().
With everything connected, does the i2c_scanner see both the RTC and the sensor ?
Your sketch might get three times as big. But you have to know what is going on.
When you say: "But I dont get any values when I upload this code", then we have not enough information.
There is nothing on the serial monitor ? You could start by printing something from the setup() :
Serial.begin(9600);
Serial.println("Sketch has started");
This line is not needed:
while(Wire.available() == 0);
You can remove it, it doesn't do anything useful, it can only do harm.
Get the serial monitor working. The I2C and the RTC time and sensor data is for later.
Make a new sketch that does only do Serial.begin and print a message. Does it work ? Is the baudrate set to 9600 in the serial monitor ?
Add the Wire.begin, and try to add more.
I don't know the RTClib from Adafruit. Did you install it as a library ?
Try the "ds3231" example. It is in the menu of the Arduino IDE, when the library is correctly installed.
I tried printing Serial.println("Sketch has started");
The serial monitor does not show anything . It is a blank.
That bit of code is about the best advice you will ever get. If the code compiles and screen is blank at that point, my guess is that you have power problem and there is no point in looking at the rest of the code, which may well be kosher anyway.
If you are running on battery, now is the time to change to wall wart. You might also check the wiring and particularly the power to your peripherals.
The time should be set into the DS3231 chip just once. I don't know why it doesn't keep the time.
The way this is going, that is how to develop software. Make small steps; don't assume it will work; test everything; don't rush ahead.
1 ) The serial monitor is working.
2 ) And you are now testing the DS3231.
The Adafruit RTClib "ds3231" example check for "rtc.lostPower()" and only sets the compile time when the power was lost. Do you do that as well ?
Is the battery in the DS3231 module okay ?
Perhaps there are simple test sketches for the DS3231.
dpoornima:
I put this in the loop and it shows values as below.
I reset the time using
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)))
It starts running the time from the adjusted time.
How do I get the current date and time after I unplug and plug it in again? It shows the previously set date and time.
Is the only way to get the current time is using the above line of code and adjusting it every time I upload the code?
I believe you may have at least one of two problems.
Power (again)
Is your ds3231 running on an LIR2032 battery? Is the battery OK? I don't believe the DS3231 module gives the battery problems its predecessor did.
Software
I suspect you are using the wrong clock software. The software I use is from http://bildr.org/2011/03/ds1307-arduino/
Note that there are two separate programmes - clock reader, and clock setter -which simplifies things, and would be what you would expect. I imagine most are rather like this.
The Adafruit RTClib "ds3231" example check for "rtc.lostPower()" and only sets the compile time when the power was lost. Do you do that as well ?
Is the battery in the DS3231 module okay ?
It does not print "The sketch has started"
It also does not print the sentence, "RTC lost power,set the time" even though I unplug it and plug it again.
but the serial monitor starts showing the pressure values along with the time when it stopped before unplugging it.
What might be the problem?
Is your ds3231 running on an LIR2032 battery? Is the battery OK? I don't believe the DS3231 module gives the battery problems its predecessor did.
Does the DS3231 set automatically to the current time after it is unplugged and plugged back in again?
After I unplug it and plug it again, the timer starts from the moment where it was before unplugging it.
Is there any way to get it read the current time ?
I think you have a problem with the Arduino, the computer, the power... and maybe a lot more.
Perhaps you are using a mix of two Arduino versions, or something is wrong with the computer, or the Arduino board is a fake and doesn't work very well.
You can not go on like this.
Use another computer, the newest Arduino IDE, another Arduino board, and start all over again. Do you know someone who can help ? I mean not online, but someone who can check the computer and wiring, and maybe can bring his own working Arduino board.
When I run the code, it prints "Sketch has started".
When I remove the battery and unplug the RTC and plug it again, It should be printing "rtc lost power, adjust the time" but it does not print anything like that.
It show the time when I first set up ans starts running.
Did you buy the DS3231 module from Adafruit ?
There are modules on Ebay that have a diode to charge the battery. With 5V, the battery gets bad very quick.
I found my DS3231 module, it was not in a project and it was still running. After a year, only 7 seconds too slow :o
The battery was 2.84V.
The RTClib from Adafruit (installed via the Library Manager) works.
I used the "ds3231" example from the RTClib. I disconnected the Arduino, removed the battery from the DS3231 module, waited one minute, put battery back, connected everything, and I got the message that the time was lost, and it was set correctly.
It is easy to miss that message. Because, when the serial monitor is opened after uploading, the time might have been set already, since the Arduino starts running after uploading.
I use Arduino IDE 1.6.8.
Did you unpower the Arduino as well ? Which module do you have ? Do you use the Arduino IDE 1.6.8 ? Did you use the Library Manager to install the library ? Can you measure the battery voltage ? What is the voltage of the Arduino 5V pin (perhaps you have a bad usb cable) ?
I unpowered everything,replaced the battery, checked the wiring, installed everything all over again ,installed the library using library manager and then checked. It now works fine.
Thank you.
I
I am getting an error saying "SDcard-1:7: error: expected unqualified-id before numeric constant
SDcard-1.ino:14:1: note: in expansion of macro 'HSCDDRD005PD3A3_I2C' "