Data Logging sketch for Mega

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

But I had to wire the Mega's SCL & SDA to pins 5 & 4 of the logger and LCD shield to make them work, so is it not really compatible?
It is compatible if you plug it directly into the Mega. If the shield in between does not pass the SDA and SCL, you need to add jumpers.
but the interrupt on pin 3 does not work - it did with the UNO.
Not sure why that would be. The Mega does support interrupt 1 on Pin3: http://arduino.cc/en/Reference/AttachInterrupt

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

Thank you.
I copied these lines from somewhere when I first started using interrupts on the Uno. I saw recently on some code for a Mega that PCintPort:: was not used as a prefix. What does PCintPort do please? I can't find an explanation of :: either - what does that do please?

Code: Select all

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>

Code: Select all

 PCintPort::attachInterrupt(PIN, burpcount,RISING);

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

PCintPort is the pin change interrupt class. The :: notation is from C++ syntax. It is the "scope resolution operator"
http://www.programmingsimplified.com/cp ... n-operator

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

The attach interrupt link you gave me 2 replies ago has example code in which the "PCintPort::" is not present. It seems that it is therefore unnecessary?
I wonder if the presence of this prefix in my code is why the Mega doesn't see the interrupt. (I cannot easily try the mega in the project at the moment to find out.)

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

The AttachInterrupt is for an external "hardware" interrupt, not a pin-change interrupt. PCINtPort is from the Pin-Change interrupt library.
http://www.geertlangereis.nl/Electronic ... ge_en.html

User avatar
wilbs719
 
Posts: 11
Joined: Sat Dec 31, 2016 2:52 pm

Re: Data Logging sketch for Mega

Post by wilbs719 »

I have an Arduino Uno R3 with a datalogger shield (new style, V2) and am getting an intermittent CHK fragmented file in Excel 2010 - Windows 7 - when I plug my SD card into my laptop. Do I have a goofy SD card or is there something I am doing wrong? Are there any good tutorials beyond the Adafruit documentation? I am using the light/temp example provided in the Adafruit documentation with a few extra variables for extra logging datas. Sometimes it works great and the error can occur in between sequential logging sessions, such re-loading code while adjusting serial monitor messages. Help!

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

the error can occur in between sequential logging sessions, such re-loading code while adjusting serial monitor messages.
If you start an upload while it is writing to a file the interrupted file write can result in a corrupted file.

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

Is this code still avaiable please? It does not appear as advertised.
The file is AdafruitMega20120329.zip located here http://code.google.com/p/beta-lib/downloads/list.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

Yes it is there. That link was posted more than 5 years ago, so it is now on page 2: https://code.google.com/archive/p/beta- ... ads?page=2

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

Thanks Bill. Sorry!
I have down loaded it and unzipped it, but thanks to my ignorance I can't find the sketch! Tips please.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

There are 3 library folders in that zip file. Inside each library folder is an 'examples' folder. All the example sketches are in the examples folders.

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

Thanks again Bill. I have got the sketch that I want - but it requires library files that I do not have installed. I see .h and .cpp files for those libraries but how and where do I add them? I suppose in Documents\Arduino\Libraries rather than in "program Files" but presumably I should not just copy .h and .cpp files into the libraries folder? Sorry again!

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Data Logging sketch for Mega

Post by adafruit_support_bill »

You need to copy the whole library folder as described in this guide:
http://learn.adafruit.com/adafruit-all- ... nstall-use

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Data Logging sketch for Mega

Post by spiney »

OK I have pasted the libraries but I get many errors when verifying, including twimaster, SdFat and RTC_Ds1307. I must leave this for the moment. I shall try hard wiring the Mega onto the logging shield and use my old code. I will come back again later if necessary. Thank you.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”