After loading few sketches (2 or 3, max 5) into my UNO I need to burn the bootloader
because any new sketch more isn't working properly**?**
You don't have to burn the bootloader.You probably just need to close and restart the IDE. You shouldn't ever have to burn the bootloader. Did you consult anyone before you did this ?
you say the sketches don't "work properly". What exactly happens? What is the problem? Is it always the same?
Of course, first I tried to restart ide or reset my UNO but it didn't help at all.
The problem is my DateTimeNow sketch and any Example sketch from the IDE
blink doesn't blink
Hello world doesn't appear on LCD (just some characters making no sense at all)
time is delayed or accelerated
While it is possible for a hardware failure on the chip's flash memory, its unlikely. i'd experiment
a bit more to rule out other possibilities like loose connections, bad supply voltage, RFI...
If you can load a program then the boot loader is ok. That's all it does, loads programs, nothing else. What ever is happening has nothing to do with the bootloader or with the IDE.
Mark
so what should I do**?** ![]()
I have an R2 that doesn't remember the last sketch loaded but never had it happen with an R3. Do you get any error messages?
im recently working with the DateTimeNow sketch (I found one in the web, hope it's a good one)
when I load it once it is working
but when I try to load it into another DS1307 it loads it with no errors
but time is wrong, like 5 minutes back
then I load it again (after disconnecting and connecting UNO to my PC and restarting IDE)
and It shows like 2 hours ahead
but when I burn the bootloader and load the sketch it's all good.
Post the sketch and a diagram of your hardware.
Does your RTC have battery backup?. Provide a link to the RTC you are using.
Mark
this is the diagram
and the sketch
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(9600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
// Serial.print(" since midnight 1/1/1970 = ");
// Serial.print(now.unixtime());
// Serial.print("s = ");
// Serial.print(now.unixtime() / 86400L);
// Serial.println("d");
// calculate a date which is 7 days and 30 seconds into the future
// DateTime future (now.unixtime() + 7 * 86400L + 30);
// Serial.print(" now + 7d + 30s: ");
// Serial.print(future.year(), DEC);
// Serial.print('/');
// Serial.print(future.month(), DEC);
// Serial.print('/');
// Serial.print(future.day(), DEC);
// Serial.print(' ');
// Serial.print(future.hour(), DEC);
// Serial.print(':');
// Serial.print(future.minute(), DEC);
// Serial.print(':');
// Serial.print(future.second(), DEC);
// Serial.println();
Serial.println();
delay(3000);
}
it's somewhere from the web I don't know programming ![]()
It's the sketch fine when the problem occurs? Your problem it's the time fact? sorry to repeat but i am from Greece and i can't
understand everything. If your problem is the time be aware that it might be the hardware's sleep feature that may cause the issue, a friend of mine had such a problem and when he tried it to an original pro mini everything got smoother.
How could it be sleep if the time is wrong just after loading the sketch?
Loading the sketch is always without any error.
I suspect that your sketch is not seeing the RTC as running during setup(), and/or that you have not fitted the battery.
Try adding a delay(1000); before this
if (! RTC.isrunning()) {
But you need to give us a link to the RTC you are using
Mark
I use simple DS1307 RTC
so I add this to the sketch...
EDIT
added and as for now it's working properly
btw... hour is like for example 21:37:4 can you help me to make it 21:37:04 ?
Look at the following article Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System It uses the same code as you right down to the layout error!
Mark
please read what have I added to my previous post...
Yes
the code is similar I only changed baud from 57600 to 9600
and commented lines to make it give me 1 line instead of 3 lines
because im trying to make the clock be displayed on 4 7-segment displays via PCF8574 and PNP-BC327
DS1307 THT or SMD they both gave me same results
You may find that you get problems as you have used a breadboard. The breakout board in the article I pointed would have saved you much head scratching.
Try this ,
upload the sketch you posted. Watch the time tick away nicely.
Now disconnect the line from the battery to the chip all should still be well. With that line still disconnected, unplug the Uno from the PC and wait a few mins.
Now reconnect the Uno to the PC and open the serial monitor, the time reported by the RTC will be behind by however long you left the Uno disconnected from the PC.
This is because the RTC was rest to the time the sketch was built and uploaded.
However if you leave the line from the battery to the RTC connected when you disconnect and then reconnect the PC you should have the correct time.
BUT, if, while the Uno is disconnected from the, there is any glitch in the power to the RTC it will go back to the time the sketch was loader. And breadboards are a real pain foe giving glitches when moved.
Mark
I have a similar breakout board with DS1307 quartz and battery from my RPi
but I don't know if I load RTC sketch to arduino then will it work back with my RPi
Yes that was what I was thinking about
without a battery the time will move
but I use a 3V battery and still the time was different so I wrote a topic on the forum...
but I use a 3V battery and still the time was different so I wrote a topic on the forum...
Which is why I think it's all down to a poor connection on the breadboard.
There is no problem moving the RTC breakout between a Pi and an uno
Mark