EcoRenovator  

Go Back   EcoRenovator > Improvements > Appliances & Gadgets
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts


Closed Thread
 
Thread Tools Display Modes
Old 09-26-11, 05:59 AM   #61
David_L_G
Lurking Renovator
 
Join Date: Sep 2011
Location: Clarence Gardens, South Australia
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey thanks. Its good to know I don't have to reinvent the wheel. I'm a bit of a Python fan too, so this could be fun!

David_L_G is offline  
Old 10-10-11, 01:14 PM   #62
strider3700
Master EcoRenovator
 
Join Date: Dec 2008
Location: Vancouver Island BC
Posts: 745
Thanks: 23
Thanked 37 Times in 30 Posts
Default

I started working on getting the ethernet shield working last night. Right away I hit an issue of the arduino no longer showing up as a serial device when connected. Lots of errors in my logs about an unknown USB device. Remove the shield plug the arduino back in and it's recognized just fine. Many hours later this morning adafruit support suggested I try powering it via battery and check the voltages. Sure enough it works when powered by 9V. Checking the voltages the arduino it's self is screwed up when it comes to the 3.3v and 5V lines.

Moral of the story, cheap chinese knockoffs aren't necessarily as good as the original Since this will long term be powered via 9V wallwart and I have no money I'll continue on with what I've got.

I still haven't done anything other then plug the two together and verify that it's at least recognized by the PC.
strider3700 is offline  
Old 10-18-11, 02:48 AM   #63
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 961
Thanks: 188
Thanked 110 Times in 86 Posts
Default

The first project with my new Arduino Duemilanove was to measure the temperature with a MCP9700 thermistor. No problem, I even got a second one going. Next, I'd like to log the data, either from the serial port or straight to the Seeed Studio SD card shield I have.

I'm just starting my journey with Arduino, and my programming background is C, not C++, C#, Java, or any other object or script stuff So here are the problems I've encountered (any help would be very welcome):
  1. I have no idea how to log what's coming in through the serial port. I've searched around and found some VBScript on a few forums, but I have no idea how use that code I have to use WinXP for the next few months, but hopefuly I'll be back to Linux after that.
  2. I also have no idea how to program the Arduino to use the SD card shield, or how to write to it.
  3. The SD shield uses the 3.3V, 5V, GND, and digital 9-13 pins on my Duemilanove, so how can get 3.3V or 5V for the sensors I'd be logging data from? Will I have to get my solder iron out?
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.

Last edited by Piwoslaw; 10-18-11 at 02:58 AM..
Piwoslaw is offline  
Old 10-18-11, 11:30 AM   #64
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default

Quote:
Originally Posted by Piwoslaw View Post
Next, I'd like to log the data, either from the serial port or straight to the Seeed Studio SD card shield I have.
Piwoslaw,

I mentioned a locally-designed Arduino board in previous posts, that integrates the SD card shield.




Here is the board.


What might be more interesting for you is the firmware that you might be able to learn from, that already does a lot of the functions you want to do. Of course, you have to tweak bits of the code to work properly in your setup.

Regards,

-AC_Hacker
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline  
Old 10-19-11, 04:27 AM   #65
David_L_G
Lurking Renovator
 
Join Date: Sep 2011
Location: Clarence Gardens, South Australia
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have been eyeing off an Arduino "compatible" board with both Ethernet and micro SD card slot in one unit. Its called an Etherten from FreeTronics and I would be interested in opinions on this sort of thing too. Are there good reasons to instead go for a basic board then add the different shields for ethernet and SD card?

Unfortunately my post count on this forum won't allow me to post a link or image, but its from jaycar.com.au search for "etherten"

regards
David

EDIT (Piwoslaw): Here is the link: EtherTen - JayCar Electronics

Last edited by Piwoslaw; 10-19-11 at 05:07 AM.. Reason: Added url
David_L_G is offline  
Old 10-19-11, 05:20 AM   #66
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 961
Thanks: 188
Thanked 110 Times in 86 Posts
Default

AC - Thanks, I saw that link before and even looked for it locally, but couldn't find it. The board I got was on sale since it's been discontinued, and the SD shield was cheap when ordered with it. Now I see that I should have researched it. Anyhow, I've found firmware for my SD card shield, but I have no idea how to use it, yet. I thought that maybe someone here has used this shield and had some tips ready.
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline  
Old 10-28-11, 03:48 AM   #67
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 961
Thanks: 188
Thanked 110 Times in 86 Posts
Default

OK, it looks like I've solved most of the problems
First, the power supply. As mentioned earlier, Seeedstudio's SD card shield plugs into both the digital pins (D9-D13 plus GND) and the power supply pins (3.3V, 5V, and 2xGND). Luckily, the shield can be powered either from the 3.3V pin, or from D9, you choose this with a small switch. So by switching to D9 and adding the following lines to the code, the shield doesn't really need the power supply pins.
Code:
pinMode(9, OUTPUT); 
digitalWrite(9, HIGH);
Now that the shield doesn't need the power supply sockets, but my sensors do, I only pressed the digital pins into the sockets, slightly bending the pins:
It's not elegant, but it works.
Another workaround (which I may end up doing) is to use the ICSP socket to power my sensors (pin 2 = 5V, pin 6 = GND).

Next, I got the Arduino to write, then append, data onto the SD card by using the FAT16 libraries. I took one of the ready examples and hacked away.

When I was testing the data logging with two temperature sensors I started getting problems. The basic program opened a file for append, recorded both readings, closed the file, waited 1 second, 60 times. When hooked up to the computer through the USB the reading would be very jumpy - anywhere from 14°C to 19°C, but when powered by a 12V wallwart they more or less smoothed out. At least in the beginning, because when repeating the program the first sensor's readings would be around 33°C. Only the first run after uploading the sketch would be OK. I then changed the program to close then open the file every ten seconds and what I got was every tenth reading from sensor 1 was too high. So I added a 'dummy' read and delay before the real sensor read. This seems to work OK.
Now the only problem seems to be that even now and then there is a random reading. This doesn't happen every time the program is run, but when it does there is only reading which is off, for example:
Quote:
...
26: 16.89 16.89
27: 16.89 16.89
28: 16.89 16.89
29: 16.89 16.89
30: 16.89 17.38
31: 16.89 28.61
32: 16.89 16.89
33: 16.89 16.89
34: 16.89 16.89
35: 16.89 16.89
36: 16.89 16.89
37: 16.89 17.38
38: 16.89 17.38
...
or
Quote:
...
27: 19.82 19.82
28: 19.82 19.82
29: 19.82 19.82
30: 19.82 19.82
31: 19.82 19.82
32: 19.82 19.82
33: 48.63 19.82
34: 19.82 19.82
35: 19.82 19.82
36: 19.82 19.82
37: 19.82 19.82
38: 19.82 19.82
...


Below is the whole code I'm using, hopefully it'll help someone.
Code:
#include <Fat16.h>
#include <Fat16util.h> // use functions to print strings from flash memory

SdCard card;
Fat16 file;
float temp;

void setup(void) {
  pinMode(9, OUTPUT); 
  digitalWrite(9, HIGH);
      
  // initialize the SD card
  card.init();
  
  // initialize a FAT16 volume
  Fat16::init(&card);

  // create a new file
  char name[] = "WRITE00.cvs";
  for (uint8_t i = 0; i < 100; i++) {
    name[5] = i/10 + '0';
    name[6] = i%10 + '0';
    // O_CREAT - create the file if it does not exist
    // O_APPEND - seek to the end of the file prior to each write
    // O_WRITE - open for write
    if (file.open(name, O_CREAT | O_APPEND | O_WRITE)) break;
  }
  if (!file.isOpen()) exit;
  file.close();
  
  // clear write error
  file.writeError = false;

  // write data to file
  for (char i=0; i<60; i++) {
    if (!(i%10)) if (!file.open(name, O_CREAT | O_APPEND | O_WRITE)) break;
    file.print(i,DEC);
    file.print(": ");
    if (!(i%10)) {
      temp = analogRead(0);
      delay(100);
    }
    temp = analogRead(0)*5/1024.0;
    temp = temp - 0.5;
    temp = temp / 0.01;
    file.print(temp);
    file.print(" ");
    temp = analogRead(1)*5/1024.0;
    temp = temp - 0.5;
    temp = temp / 0.01;
    file.println(temp);
    if (!((i+1)%10)) {
      if (!file.close()) break;
      delay(900);}
      else delay(1000);
  }
  
  // close file and force write of all data to the SD card
  file.close();
}

void loop(void) {};
Attached Thumbnails
Click image for larger version

Name:	SDArduino.jpg
Views:	1333
Size:	56.9 KB
ID:	1818  
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline  
Old 10-28-11, 07:25 AM   #68
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

If your wires are long (perhaps even if they're short) you could be getting noise over the wire. I had this problem when I did my attic fan project. All I did was add a capacitor inline with the sensor signal wire and it smoothed the signal out. Of course this also slows response time a bit.
__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline  
Old 10-28-11, 08:41 AM   #69
Piwoslaw
Super Moderator
 
Piwoslaw's Avatar
 
Join Date: May 2009
Location: Warsaw, Poland
Posts: 961
Thanks: 188
Thanked 110 Times in 86 Posts
Default

The wires were short, just to the breadboard, while the USB cable was a standard 1.8m (though this probably didn't make a difference). This evening I'll try to rig up a few 1 meter wires to start some real testing. But it's good to know about the caps. Is there a rule about the cap size vs wire length?
__________________
Ecorenovation - the bottomless piggy bank that tries to tame the energy hog.
Piwoslaw is offline  
Old 10-28-11, 08:51 AM   #70
Daox
Administrator
 
Daox's Avatar
 
Join Date: Aug 2008
Location: Germantown, WI
Posts: 5,525
Thanks: 1,162
Thanked 374 Times in 305 Posts
Default

Not that I know of. I just put a small one on, I think it was 10uf. It still responds plenty fast and I'm only sampling every second anyways. From my testing (holding the sensor in my hand or blowing on it to heat it up) it responded well enough for my application.

__________________
Current project -
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
&
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
Daox is offline  
The Following User Says Thank You to Daox For This Useful Post:
Piwoslaw (10-28-11)
Closed Thread


Tags
data, logging


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design