i am building something like a temperature data logger.
Every minute i want to write temperature on SD card. I am using millis function as a timer. I also have LCD to display temperature.
My problem is a little bit strange. If i power circuit over USB cable and with LCD backlight turned on, it works. If i put SD card into card reader i can see temperature in txt file. But if i unplug LCD back light or if i power the circuit over stable outside power supply, the txt file stays empty so temperature is no longer writing on SD card.
I am using Arduino Nano, DS18B20 sensor, 1 GB SD card and 2x16 LCD display. I tried to put some delay in function but result was the same.
Any ideas, what could be wrong?
Here is part of the code:
// SD CARD
if ((long)(millis() - waitUntil) >= 0)
{
myFile = SD.open("test.txt", FILE_WRITE); // OPEN
myFile.println(temp); // WRITE
myFile.close(); // CLOSE
waitUntil = waitUntil + interval; // WAIT UNTIL ANOTHER INTERVAL
}
If i put LED and make it blink in this function (instead of part for writing on SD card) it blinks every interval time without problems (for a few milliseconds but it blinks constantly). Is that what you mean?
I will make outside power supply with LM7805 and try to power the whole circuit with it.
I was thinking that you would add a startup sequence that blinked the LEDs in some recognisable way at startup, and some different recognisable way while it was running normally, and in yet another recognisable way if it detected an error (such as SD initialisation or write failure).
This would let you find out whether the Arduino is successfully starting up and running without error and without being reset subsequently.
Unbelievable just $2 free shipping. Unfortunately there is no schematic so I don’t know if the 3.3V logic is properly translated to 5V. Is there anything on the underside of the board? If not, there is no proper logic shifting. I only see a power supply-ish part and a few resistors.
I have the exact same SD card reader and it works fine as follows with a nano.
Dont forget you have to drive the SD card signals at 3.3V, so the best way to do this is run the whole system at 3.3v
I do this by connecting my input power >6V into the 5V input of the card reader, the card has its own 3.3 reg,
use this 3.3V output to drive the power to your Arduino. I connect it to the regulated 5V side (pin 27 nano) of the Arduino that way the system then runs at 3.3V. There are resistors on the board but they are just pullups to get a good edge and not level dividers so this card is designed to run at 3.3V signal levels.
For development I use one of those USB-TTL $4 devices that provides the 3.3v and not the onboard usb as this would drive the system at 5V, only problem is you have to hit the reset to do the download, no big deal.
I think this is a good option rather than using level shifters and especially voltage dividers given that the original posters problems appears to be in this area.
I will try this on monday because right now i am not in my workshop.. I will try to power the whole circuit on 3,3V, like you said, or use a few resistors.
Can't you easily switch to the internal 8 MHz speed, even if the resonator and caps are physically in place ?
Just change fuses ?
Is there a predefined suitable Board in the IDE, or is it necessary to add one ?
Respect the spec sheet and don’t go beyond the specs. If you go beyond the specs and have questions, no one including the manufacturer is interested in answering them. You can use internal oscillators yes but I heard you need to calibrate it so it may be good enough for loading sketches. You may also need to flash an older bootloader that runs at lower serial baud rate since the internal oscillators are more depending on things like temperature etc. If you want 3.3V, get a 3.3V arduino board. External crystals are 8MHz and bootloader is ready.
So, after all i read it is better to run on 5V.. Now i don't know if this SD card module that i am using can be connected directly to Arduino or it need some extra outside resistors or something?
What you can get away with depends on many factors. Ultimately the best approach is to run a 16Mhz system on 5V and use a bi-directional level shifter for 3.3V devices, I dont think anyone denies that, the problem is all these lego type blocks that people are trying to glue together. Many people manage to use a pair of resistors to divide down but this has its problems, depending on the speed of your SD card and its sensitivity to edge detection etc, the physical length of your bus, the number of devices on your bus etc etc.
This card reader has intended pull ups on it as I described, that will affect any divider you try and implement, what I offered in my original reply was a way of using the card in a stable way for myself at least. Unfortunately the discussion quickly degenerated into the suitability of running a 16M device with 3V. What I can tell you is, it works fine for me and many others, presumably Ladyada's moded board worked fine see her last statement about the overclocking at the end, and the Sparkfun's openlog http://www.sparkfun.com/datasheets/DevTools/Arduino/OpenLog-v11.pdf works OK despite being another 16M 3V setup doing exactly what you are trying to.
These problems are sometimes very sensitive as you found out in your original post, or even robust and work for the wrong reasons, like the guy in my post who had a working system without any power to the reader, which just happened to work. All I can say is have a go and learn something along the way, I will try and post some pics or something to show how my setup is with this card working.