Data logging shield

[ [ images & links ] ]

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Gambar 1. learn.adafruit.com

 

adafruit_products_labeled.jpgGambar 2.

 

Place the SD library folder your sketchbook libraries folder. You may need to create the libraries subfolder if its your first library.

 

 

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_Logger_bb.jpgGambar 3.

Adafruit library examples.

Deek-Robot: Data logging shield V1.0

D10 – Chip Select
D11 – SPI MOSI
D12 – SPI MISO
D13 – SPI SCK

“Next is the error() function, which is just a shortcut for us, we use it when something Really Bad happened, like we couldn’t write to the SD card or open it. It prints out the error to the Serial Monitor, turns on the red error LED, and then sits in a while(1); loop forever, also known as a halt

“Now the code starts to talk to the SD card, it tries to initialize the card and find a FAT16/FAT32 partition.

Next it will try to make a logfile. We do a little tricky thing here, we basically want the files to be called something like LOGGERnn.csv where nn is a number. By starting out trying to create LOGGER00.CSV and incrementing every time when the file already exists, until we get to LOGGER99.csv, we basically make a new file every time the Arduino starts up

To create a file, we use some Unix style command flags which you can see in the logfile.open() procedure. FILE_WRITE means to create the file and write data to it.

Assuming we managed to create a file successfully, we print out the name to the Serial port.”

“OK we’re wrapping up here. Now we kick off the RTC by initializing the Wire library and poking the RTC to see if its alive.

Then we print the header. The header is the first line of the file and helps your spreadsheet or math program identify whats coming up next. The data is in CSV (comma separated value) format so the header is too: “millis,time,light,temp” the first item millis is milliseconds since the Arduino started, time is the time and date from the RTC, light is the data from the CdS cell and temp is the temperature read.

You’ll notice that right after each call to logfile.print() we have #if ECHO_TO_SERIAL and a matching Serial.print() call followed by a #if ECHO_TO_SERIAL this is that debugging output we mentioned earlier. The logfile.print() call is what writes data to our file on the SD card, it works pretty much the same as the Serial version. If you set ECHO_TO_SERIAL to be 0 up top, you won’t see the written data printed to the Serial terminal.

Finally, we set the two LED pins to be outputs so we can use them to communicate with the user. There is a commented-out line where we set the analog reference voltage. This code assumes that you will be using the ‘default’ reference which is the VCC voltage for the chip – on a classic Arduino this is 5.0V. You can get better precision sometimes by lowering the reference. However we’re going to keep this simple for now! Later on, you may want to experiment with it.”

Main loop

Now we’re onto the loop, the loop basically does the following over and over:

  1. Wait until its time for the next reading (say once a second – depends on what we defined)
  2. Ask for the current time and date froom the RTC
  3. Log the time and date to the SD card
  4. Read the photocell and temperature sensor
  5. Log those readings to the SD card
  6. Sync data to the card if its time
 

“The first important thing is the delay() call, this is what makes the Arduino wait around until its time to take another reading. If you recall we #defined the delay between readings to be 1000 millseconds (1 second). By having more delay between readings we can use less power and not fill the card as fast. Its basically a tradeoff how often you want to read data but for basic long term logging, taking data every second or so will result in plenty of data!

Then we turn the green LED on, this is useful to tell us that yes we’re reading/writing data now.

Next we call millis() to get the ‘time since arduino turned on’ and log that to the card. It can be handy to have – especially if you end up not using the RTC.

Then the familiar RTC.now() call to get a snapshot of the time. Once we have that, we write a timestamp (seconods since 2000) as well as the date in YY/MM/DD HH:MM:SS time format which can easily be recognized by a spreadsheet. We have both because the nice thing about a timestamp is that its going to montonically increase and the nice thing about printed out date is its human readable.”

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Plotting with a spreadsheet

adafruit_products_dataselect.gifGambar 4.

Gambar 5.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Using Gnuplot

 

 

adafruit_products_gnuplotcmd.gifGambar 6.

adafruit_products_gnuplotted.gifGambar 7.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_adafruitlogshieldsch.pngGambar 8.

Gambar 9.

Gambar 10.

Gambar 11.

Gambar 12.

 

Save

Save

Save

Save

RTC DS1302

[ [ images & links ] ]

Gambar 1. [sumber]

Sebelumnya, kutipan informasi dari dua RTC telah pernah diungkap di situs ini. Pertama DS1307, dan yang kedua adalah DS3231. Di halaman ini akan saya kutip keterangan mengenai RTC DS1302, yang bersama dua RTC terdahulu saya beli di situs online lokal.

 

The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.

Interfacing the DS1302 with a microprocessor is simplified by using synchronous serial communication. Only three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). Data can be transferred to and from the clock/RAM 1 byte at a time or in a burst of up to 31 bytes. The DS1302 is designed to operate on very low power and retain data and clock information on less than 1µW.

The DS1302 is the successor to the DS1202. In addition to the basic timekeeping functions of the DS1202, the DS1302 has the additional features of dual power pins for primary and backup power supplies, programmable trickle charger for VCC1, and seven additional bytes of scratchpad memory.

~maximintegrated.com

 

Gambar 2. domoticx.com/arduino-rtc-tijdklok-ds1302/

Pustaka yang diperlukan untuk mengeksekusi kode bisa diakses di link ini.

Berdasarkan pengalaman saya menguji coba sistem ini dan pengalaman cukup banyak orang lain yang saya pantau di berbagai halaman di Internet, tampaknya sistem RTC DS1302 yang banyak beredar memiliki permasalahan dalam hal operasi. Banyak pengguna yang melaporkan kesalahan pembacaan jika mempergunakan IC ini. Ada beberapa kemungkinan, termasuk kemungkinan IC yang banyak diperjual-belikan yang memang memiliki grade yang lebih rendah.

Secara praktis, sampai ditemukan solusi yang baik untuk IC ini (versi yang banyak dijual), akan lebih baik mempergunakan RTC DS1307 atau DS3231.

RTC DS3231

[ [ images, codes & links ] ]

Keterangan mengenai RTC (Real-Time Clock) sudah pernah disampaikan melalui kutipan di post terdahulu. Di halaman itu yang dibahas adalah komponen RTC DS1307, yang lazim diperdagangkan dalam bentuk papan yang ditandai sebagai Tiny RTC. Kali ini saya coba rangkumkan mengenai DS3231 dari berbagai sumber sebagai awalan untuk memperlajarinya. RTC ini dilaporkan memiliki akurasi yang lebih baik dari RTC DS1307.

Gambar 1.

 

With a backup button cell (e.g. CR2032) on the underside of the module, these DS1307 modules will keep time even when disconnected from the main power source for months and even years on end. However, in our experimental projects (using this RTC with an Arduino for dataloggers amongst other things), we have found these DS1307 modules to vary hugely in their time-keeping accuracy – some gaining/losing a few seconds per day, and others gaining/losing as much as 3-5 minutes per day. While they have proved to be very consistent – i.e. a unit which gains 3 minutes per day will gain 3 minutes per day every day – having to test each unit individually over a few days and then modifying the Arduino project code to cancel out errors is not practical.

Some of the error is caused by ambient temperature changes affecting the accuracy of the timing of the crystal resonator. Some more of the error is also caused by the quality of the crystal itself and its attachment to the PCB in these economical modules.

In extensive testing we have found the time-keeping of these modules to be excellent. The DS3231 chip on the module is marketed as being accurate to 2ppm (parts per million), which means less than one second lost or gained every 5 to 6 days. The units we have tested thus far have all come in at under 1ppm accuracy, so a couple of seconds at most lost or gained per month.

This accuracy is achieved in part by the incorporation of a temperature sensor in the DS3231 which can compensate for changes in ambient temperature. The measurements from this temperature sensor are also accessible to the user (accurate to +/- 3 Celcius) which makes for a handy extra feature. These DS3231 modules also have 32kb of available EEPROM memory which can be utilised by your projects, and many other useful features.

~reuk.co.uk

 

sumber: Benchmarks: Real Time Clocks – Results for Raspberry Pi/Arduino – DS3231 / PCF8563 / MCP79400 / DS1307

 

Gambar 2. [randomnerdtutorials.com]

 

Terdapat beberapa pustaka/library untuk tiap RTC. Dua yang disampaikan dalam “mashup ini adalah pustaka dari Adafruit dan pustaka dari Makuna.

Contoh-contoh kode program sistem Arduino untuk RTC DS3231.

Sistem ini dirancang untuk bekerja dengan menggunakan baterai “khusus”, yaitu baterai yang bisa diisi ulang (rechargeable) seperti LIR2032. Di papan sudah disediakan sistem pengisian ulang untuk baterai tersebut. Karena itu jika kita mempergunakan baterai tipe yang tidak bisa diisi ulang (non-rechargeable) seperti CR2032 maka ada perubahan yang perlu dilakukan. Hal ini untuk mencegah agar baterai primer yang tidak bisa diisi ulang itu tidak berusaha diisi oleh sistem. Caranya adalah dengan melepas/membuang diode seperti pada Gambar 3 berikut.

ds.jpgGambar 3. [sumber: tronixlabs.com]

 

 

Save

RTC DS1307

[ [ images, codes & links ] ]

Gambar 1.

A real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time.

Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.

Real-time clock

What is an RTC?

A real time clock is basically just like a watch – it runs on a battery and keeps time for you even when there is a power outage! Using an RTC, you can keep track of long timelines, even if you reprogram your microcontroller or disconnect it from USB or a power plug.

Most microcontrollers, including the Arduino, have a built-in timekeeper called millis() and there are also timers built into the chip that can keep track of longer time periods like minutes or days. So why would you want to have a separate RTC chip? Well, the biggest reason is that millis() only keeps track of time since the Arduino was last powered – . That means that when the power is turned on, the millisecond timer is set back to 0. The Arduino doesn’t know that it’s ‘Tuesday’ or ‘March 8th’, all it can tell is ‘It’s been 14,000 milliseconds since I was last turned on’.

OK so what if you wanted to set the time on the Arduino? You’d have to program in the date and time and you could have it count from that point on. But if it lost power, you’d have to reset the time. Much like very cheap alarm clocks: every time they lose power they blink 12:00

While this sort of basic timekeeping is OK for some projects, some projects such as data-loggers, clocks, etc will need to have consistent timekeeping that doesn’t reset when the Arduino battery dies or is reprogrammed. Thus, we include a separate RTC! The RTC chip is a specialized chip that just keeps track of time. It can count leap-years and knows how many days are in a month, but it doesn’t take care of Daylight Savings Time (because it changes from place to place).

~DS1307 Real Time Clock Breakout Board Kit

 

What are Real Time Clocks?

Real time clocks (RTC), as the name recommends are clock modules. The DS1307 real time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a low-power clock/calendar with 56 bytes of battery backup SRAM. The clock/calendar provides seconds, minutes, hours, day, date, month and year qualified data. The end date of each month is automatically adjusted, especially for months with less than 31 days.

They are available as integrated circuits (ICs) and supervise timing like a clock and also operate date like a calendar. The main advantage of RTC is that they have an arrangement of battery backup which keeps the clock/calendar running even if there is power failure. An exceptionally little current is required for keeping the RTC animated. We can find these RTCs in many applications like embedded systems and computer mother boards, etc.

~www.elprocus.com/rtc-ds1307/

 

 

Arduino Tiny RTC D1307 Tutorial

 

TinyRTC PinoutsGambar 2. [henrysbench.capnfatz.com]

Arduino TinyRTC Tutorial ConnectionsGambar 3. [henrysbench.capnfatz.com]

Gambar 4. [tronixstuff.com]

Connecting your module to an Arduino

Both modules use the I2C bus, which makes connection very easy. If you’re not sure about the I2C bus and Arduino, check out the I2C tutorials (chapters 20 and 21), or review chapter seventeen of my book “Arduino Workshop“.

Moving on – first you will need to identify which pins on your Arduino or compatible boards are used for the I2C bus – these will be knows as SDA (or data) and SCL (or clock).

~ tronixstuff.com

 

 

Tiny RTC

Gambar 5.

Features

  • 5V DC supply
  • Programmable Square-Wave output signal
  • Automatic Power-Fail detect and switch circuitry
  • Consumes less than 500nA in Battery-Backup Mode with Oscillator Running
  • 56-Byte, Battery-Backed, Nonvolatile (NV)RAM for data storage

Gambar 6.

TinyRTC hardware1.jpgGambar 7.

~www.elecrow.com

 

 

RTC DS-1307 with Arduino

DS 1307 RTC Pinout

Gambar 8.

Block Diagram of DS1307

Gambar 9. [Datasheet]

Gambar 10.

~www.theorycircuit.com

 

Terdapat beberapa pustaka/library untuk tiap RTC. Dua yang disampaikan dalam “mashup ini adalah pustaka dari Adafruit dan pustaka dari Makuna.

Contoh-contoh kode program sistem Arduino untuk RTC DS1307.

adafruit: ds1307.ino