Questions tagged [time]
Use this tag for questions regarding how to get the time on an Arduino, how to create or use clocks with an Arduino, or anything that has time as a substantial factor in it. Also consider using [programming] or other more specific tags.
212 questions
0
votes
1
answer
119
views
How to read my three-button inputs?
I am creating a three-person reaction time game but I would like to be able to read all three buttons' proximity to the start time - currently only the winner is displayed on the serial read.
Here is ...
-1
votes
1
answer
137
views
Use DS3231 with battery and vcc at the same time
I have ds3231 which i want to use to keep track of time even when the in my ase esp32 is without electricity. I however read some difference stuff regarding using the vcc and battery on he same time. ...
1
vote
1
answer
174
views
Fixing a pedestrian traffic light sequence pattern in a cycle using millis and without delay
I was emulating the pedestrian traffic light cyclic pattern (red, green, green flashing) in the next Arduino code. But when I run this code with my ESP8266 Wemos D1 mini controller, it appears the ...
0
votes
1
answer
182
views
Unable to get keypad key in while loop [closed]
I'm a beginner into Arduino so I have a little problem where I'm trying to do a countdown on LCD using while loop but I'm also trying to get a key input inside that same while loop. Problem is that ...
0
votes
2
answers
108
views
Serial Buffer stays empty as soon as it becomes empty once
I have a question regarding serial buffer readout.
At program start, I send a serial command to a sensor that 1. activates him and 2. let him send data - that works.
When I unplug the sensor, the ...
0
votes
1
answer
3k
views
(Why is) getLocalTime() on ESP32 taking several seconds to complete successfully
This is a cross-post from https://github.com/espressif/arduino-esp32/discussions/8653 as it didn't yield any results there.
I noticed that getLocalTime() is consistently taking 5-10+ seconds to ...
2
votes
1
answer
114
views
Functions delaying gesture sensor recognition
I am working on a simple little robot to cure my boredom and all it has is a 64 x 32 OLED for the eyes, and a PAJ7620 Gesture recognition sensor with a Seeeduino Xiao as the main board.
Basically, ...
-1
votes
1
answer
434
views
localtime - executing one after the other- different time_t, but getting same results
When I try to comapre 2 time_t values I get unexplained behavour
time_t t = 12345;
time_t T = 67890;
struct tm *tm = localtime(&t);
struct tm *Tm = localtime(&T);
char timeStamp[40];
...
2
votes
0
answers
142
views
I goofed: I used a digital output rather than an analog output
OK, I have a little hardware issue I need to fix in software for the time being. I say, "For the time being," because I already have the PC Boards printed, and I need to make do for this ...
0
votes
1
answer
1k
views
Arduino Nano 33 BLE getting the current time using RTC
I have a an arduino NANO 33 BLE and I'm trying to get the current time and date. Based on the documentation, the arduino has nRF52840 microcontroller which comes with a 24 RTC timer It is listed in ...
1
vote
4
answers
3k
views
What is the ideal way to check if time on ESP8266 via NTP is ready?
With ESP8266, I noticed that for the first 1 or 2 loops, localtime returns Unix epoch (1970 date) until it has finished getting the actual time from NTP, after which point I see the real date. ...
2
votes
1
answer
1k
views
Attiny timer interrupt does not make an interrupt every 1000ms
I'm making a stopwatch using an attiny85, the idea was to use the timer interrupts to count the seconds
my theory was: since I set the Attiny85 to run at 1Mhz, I can use a presale of 1024; 1000000 / ...
3
votes
0
answers
2k
views
How to correctly synchronize time with NTP server?
I want to synchronize time with NTP server once in some time. I am using DOIT ESP32 DEVKIT V1, I tried with getLocalTime() function but it returned true even without wifi, but as I know without wifi ...
1
vote
4
answers
2k
views
How to efficiently code a long duration timer
I'm working on a battery-powered project. I'm trying to write code, which checks the battery voltage every 30 minutes and changes the color of a LED accordingly. Should I still be using millis() or is ...
0
votes
1
answer
4k
views
`time.h` vs `TimeLib.h` on AVR boards
Why do I get wrong result when using time.h library when using AVR boards, such Nano/Uno/Pro Micro (while when using TimeLib.h).
OUTPUT (for given Epoch ):
TimeLib: 2022-04-02 16:11:20
time.h: 0152-03-...
2
votes
2
answers
134
views
Trying to keep my main code running unless an input is LOW for a certain amount of time
I have code that creates a sequential signal with 4 LEDS. It cascades to the right. This works when I hold down the input button. What I need help with is having the code run exactly the same when ...
0
votes
1
answer
4k
views
Set time() on ESP8266
If I call configTime() on a ESP8266 using ESP8266 Core, then time() gets changed from uptime to unixtime. However this sends a SNTP request. I have a DS3231 RTC attached without internet. How can I ...
0
votes
1
answer
771
views
sizeof tm struct (datetime) different on ESP32 vs linux64x
I am logging binary data to my SD. I log a datetime object of type 'tm', which is 36 bytes on ESP32.
When I create a datetime of type 'tm' on linux it is 56 bytes.
ESP32 write tm to SD:
[tm datetime = ...
-1
votes
1
answer
2k
views
`ConfigTime` daylight saving update
I'm using an ESP8266 to get clock NTP sync in this manner:
void myIOT2::_startNTP(const int gmtOffset_sec, const int daylightOffset_sec, const char *ntpServer)
{
configTime(gmtOffset_sec, ...
1
vote
1
answer
6k
views
ESP8266: error: 'getLocalTime' was not declared in this scope
I am getting
error: 'getLocalTime' was not declared in this scope
when I am compiling this code for ESP8266, however works for ESP32:
#include "time.h"
void gettime()
{
static int16_t ...
1
vote
2
answers
517
views
run a function for a certain amount of time! [duplicate]
i'm working on a project where i need to run a function for 20 minutes and the function writes to memory using EEPROM every minute. How can i make the function run for 20 minutes, i was thinking of ...
1
vote
0
answers
202
views
Inconsistent values from NTP client
Hardware- ESP8266 Based NodeMCU
I am using NTP Client for time in my alarm project.
I am facing an issue where NTP client is not returning proper values, in the sense that it works properly for the ...
1
vote
1
answer
3k
views
ESP8266 ISO 8601 string to tm struct
I have a web service that returns timestamps in ISO 8601 format, e.g., "2021-06-25T12:00:00"
I'm trying to turn the timestamp string into a tm type struct from the ESP8266 library <time.h&...
1
vote
1
answer
205
views
Get production count for current minute
I am trying to make a production counter for a machine. I want to display production count of the last minute for each seconds. So, display should update every second and should display real value of ...
1
vote
0
answers
87
views
Hello, help with CODE servo mechanism and DS1307
I am trying to make a auto feeder for birds!,
I can't setup my code, the aim is to move servo when the certain time comes,
My commend if doesnt work, what else commend can I use?
#include <Wire.h&...
0
votes
2
answers
94
views
Switching time of a multiple input switch
I basically have two switches
Both switches will be pressed simultaneously in different order
I want to know which switch was pressed first
1
vote
2
answers
853
views
unable to modify NTPClient to use static IP address
I tried the example File > Examples > ESP8266WiFi > NTPClient which requests the current time and it worked fine. Then I tried to modify it so that the ESP8266 would have a static IP ...
2
votes
2
answers
6k
views
Measure the time between 2 inputs
I am making a small project, and for that, I need to measure the time between 2 inputs.
basically, a program to measure the time elapsed from when digital pin 2 is high to when it again becomes high.
6
votes
5
answers
3k
views
Is there any better choice other than using delay() for a 6-hours delay?
I am designing an incubator system and I need to drive a motor forward and reverse every 6 hours. Is there any better choice other than using delay()? A 6-hours delay seems a little unprofessional.
2
votes
1
answer
289
views
Help with millis to get accurate timing
I'm essentially trying to create a music box which is light activated using an LDR. When it's open a song plays, while a servo rotates a figurine back and forth, and an LED dims and illuminates in ...
1
vote
0
answers
202
views
Can I record us (microseconds) with AnalogBinLogger example in SdFat's library?
I am using the AnalogBinLogger from the SdFat example library. I am using it to record 8 analog channels at 5kHz! which is amazing (thank you SdFat).
Is it possible to include a separate column to ...
2
votes
0
answers
76
views
Two LED Patterns Task Controlled by GUI
I am very new to Arduino and coding/programing. I set a task for myself to make a simple circuit of 5 LEDs controlled by pins 2, 4, 8, 11, 12. I want to be able to make two different pattern for the ...
0
votes
2
answers
1k
views
ESP32 feedback from NTP
The basic example for ESP32 NTP is very rough:
void setup() {
Serial.begin(115200);
//connect to WiFi
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while ...
-2
votes
1
answer
2k
views
Sync of Time Library and RTClib
Trying to understand the two libraries and setSyncProvider(RTC.now).
Using Arduino Uno with Adafruit ChronoDot. Aduino IDE 1.8.13.
The code below is simply to understand what is happening.
I am ...
1
vote
2
answers
9k
views
Arduino Time Library and RTC Libraries
I am using RTClib.h and TimeLib.h with an Uno.
Have been struggling for days in understanding the various RTC libraries available and how to use them with the Arduino Time Library.
Question 1.
If I do ...
2
votes
1
answer
807
views
what happens on Arduino power-on, and how long does it all take?
Here's what I think happens and how long it takes (FIXME means I don't know). I'd like to end up with solid max times for everything if possible.
Power-on, input caps to the 328P begin charging and ...
1
vote
0
answers
84
views
RTC and Time Library Problems
Want to use Arduino Time library and occasionally sync it with an external RTC (Maxim DS3231 chip). I am turning LEDs on and off based on time and using a shift register (Nexperia 74HC154PW) and ...
0
votes
1
answer
2k
views
Running a DC motor for a set amount of time
I am trying to run a DC motor for 100ms and then turn it off completely. Here is my code any suggestions on why it might not be working?
My Code
const int pirPin = 9;
const int motorPin = 2;
int ...
3
votes
3
answers
3k
views
How to create a 1-hour timer with an ATtiny13A microcontroller?
I want to control an AC load such that it powers on for 1 minute, then turns off for 1 hour, then on again for 1 min, and so on, in a loop.
I just modified the blink sketch to do:
Turn A1 on
Then ...
1
vote
0
answers
363
views
Run a dc motor for amount of time without delay
Hi everyone I have a project and I need to run a dc motor for amount of time without using delay I use DelayWithoutBlink technique.
In this code the motor should run for 5 second in cw then it will ...
2
votes
1
answer
3k
views
How to Set RTC in ES32 using NTP server?
I am working on ESP32 And want to set RTC from the NTP server. How can I get epoch value I have done this thing on CC3200 launchpad and used an NTP server library to obtain epoch value.
0
votes
1
answer
1k
views
Fail to convert time_T from past to tm struct
Continuing a Question asked few days ago, answered by Edgar, a new question has rised:
My goal was using a past time_t value, and convert it into a struct tm variable in order to use it, part as a ...
1
vote
2
answers
4k
views
How to keep track of millis during sleep mode
In my application, I need to keep track of the time the application has been running as well as use sleep modes. However, when using the sleep modes, Timer0 is disabled, and therefore millis stop ...
0
votes
1
answer
1k
views
Error passing a `time_t` and `struct tm`, ESP32
I need to create a converter from epoch time stored in a time_t variable, to a struct tm variable, in order to check / create a certain task every hour or a day. This function should get also a past ...
1
vote
1
answer
1k
views
Bluetooth: sync time from an NTP server via Internet connection shared with Android phone
I saw that it is possible to sync time from an NTP server over WiFi. I have the HC-06 Bluetooth module and an Android phone that can share its Internet connection with Arduino via Bluetooth. Would it ...
0
votes
1
answer
1k
views
Parola library and DS3231 clock
EDIT2: Well, this is the "new" code and it just displays random dots on the matrices:
#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define ...
1
vote
1
answer
1k
views
UNIX time in ms to human date time
Been struggling with something for a few days.
Loading data from a website via JSON and it includes an updated date time in milliseconds. This is an EPOCH date and I can get the right value using ...
1
vote
0
answers
82
views
How to pause the analog value according to input signal applied to a particular digital pin?
I'm working with a digital blood pressure meter using arduino nano. I need to display the pressure reading during inflation and deflation of the cuff instantly. And when an input signal applied to a ...
0
votes
1
answer
343
views
How to subtract micros()?
I am attempting to calculate the time between pulses by comparing the micros() timestamp. I understand that you cannot just simply subtract unsigned longs, but I cannot understand what the alternative ...
0
votes
1
answer
162
views
How to set a timer for a function and be able to reset it in the middle of the process?
Hello me and my friend have to do an assignment for school but we need some help. We have to make a LED turn on and of with a button and a relay. But when I press the button the LED should be on for ...