2022 Developer Survey is open! Take survey.

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.

Filter by
Sorted by
Tagged with
1 vote
3 answers
76 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 ...
user avatar
0 votes
1 answer
49 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-...
user avatar
  • 790
2 votes
2 answers
57 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 ...
user avatar
  • 73
0 votes
1 answer
151 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 ...
user avatar
  • 11
0 votes
1 answer
101 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 = ...
user avatar
-1 votes
1 answer
512 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, ...
user avatar
  • 790
1 vote
1 answer
2k 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 ...
user avatar
  • 11
1 vote
2 answers
96 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 ...
user avatar
1 vote
1 answer
67 views

Code no longer waits when button is not pressed

So here is the code const int buttonPin = 2; const int ledPin = 13; int wait_time = 10; bool wait_finished = false; // variables will change: int buttonState = 0; void setup() {...
user avatar
0 votes
0 answers
446 views

About Finxing ESP8266-01 ERROR UPLOAD ARDUINO IDE (esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header)

I have one ESP8266 01 and can not write blinking example on it, so I have made the below connection on it based on this video, but I get the below error: Global variables use 27980 bytes (34%) of ...
user avatar
1 vote
0 answers
73 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 ...
user avatar
  • 452
1 vote
1 answer
540 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&...
user avatar
  • 95
1 vote
1 answer
72 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 ...
user avatar
  • 177
1 vote
0 answers
12 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&...
user avatar
0 votes
2 answers
40 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
user avatar
  • 9
1 vote
2 answers
164 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 ...
user avatar
1 vote
2 answers
357 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.
user avatar
  • 11
6 votes
5 answers
2k views

Is there any better choice other than using delay() for a 6 hours delay?

I am designing this 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.
user avatar
  • 63
3 votes
1 answer
156 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 ...
user avatar
1 vote
0 answers
98 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 ...
user avatar
  • 115
2 votes
0 answers
51 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 ...
user avatar
0 votes
2 answers
433 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 ...
user avatar
  • 265
-2 votes
1 answer
484 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 ...
user avatar
  • 41
1 vote
2 answers
2k 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 ...
user avatar
  • 41
2 votes
1 answer
85 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 ...
user avatar
1 vote
0 answers
48 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 ...
user avatar
  • 41
0 votes
1 answer
666 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 ...
user avatar
2 votes
2 answers
992 views

How to create a 1 hour timer with ATtiny13A microcontroller?

I want to control an AC load such that it powered on for 1 minute, then 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 delay ...
user avatar
1 vote
0 answers
193 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 ...
user avatar
  • 23
2 votes
1 answer
1k 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.
user avatar
0 votes
1 answer
441 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 ...
user avatar
  • 790
0 votes
2 answers
1k 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 ...
user avatar
0 votes
1 answer
420 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 ...
user avatar
  • 790
1 vote
1 answer
552 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 ...
user avatar
0 votes
1 answer
696 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 ...
user avatar
1 vote
1 answer
294 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 ...
user avatar
1 vote
0 answers
54 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 ...
user avatar
  • 11
0 votes
1 answer
175 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 ...
user avatar
0 votes
1 answer
48 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 ...
user avatar
  • 13
1 vote
0 answers
28 views

I need to happen a process between 2 given times in Arduino

In my project i have a function which i only need to execute if the current time is between given 2 times. Note that the time is fetched from RTC so its 24hr. For example if current time is 23:00,...
user avatar
0 votes
0 answers
73 views

Arduino acting strange with photoresistor data

So I stumbled into strange problem. I have this circuit, where I connect 2 photoresistors and bluetooth HC05 to Arduino. When one of the resistors senses bright light bluetooth sends '1' or '3' ...
user avatar
0 votes
1 answer
412 views

How to set a time out like Serial.setTimeout() for Serial.read()?

I read a comment form here: "Serial.setTimeout() sets the maximum milliseconds to wait for serial data when using Serial.readBytesUntil(), Serial.readBytes(), Serial.parseInt() or Serial.parseFloat()...
user avatar
0 votes
1 answer
2k views

Set the wall clock time or change GMT offset without ntp server?

I have been able to get the current time from an NTP server and set what appears to be an internal clock using the configTime() function from the ESP32 core. I can then get the current time with the ...
user avatar
0 votes
1 answer
7k views

ESP32 documentaiont for "time.h"

I am working from the example sketch in that installed with the ESP32 Dev Module into the Arduino IDE. It includes <WiFi.h> and "time.h". I have a number of questions about how to use the ...
user avatar
-1 votes
1 answer
44 views

execute if function in a timed loop

I have a school project where I had to make a piece of code work for 1 minute and then return. I first used a RFID reader which didn't work for me so I decided to use the serial monitor. I did this ...
user avatar
  • 13
1 vote
1 answer
4k views

ESP32 seconds from epoch

When using ESP8266 - getting seconds from epoch is done using NTP.begin(NTPserver, 2, true); delay(delay_tries); time_t t = now(); while t stores amount of seconds from 1-1-1970. When trying to do ...
user avatar
  • 790
0 votes
1 answer
37 views

Missing time when using timer

I have set up Timer2 to count every tick at 16MHz, or 62.5ns per tick. Then I run the following code: int t = 0; for (int i=0;i<64;i++){ data[4*i] = TCNT2; data[4*i+1] = TCNT2; byte now =...
user avatar
0 votes
1 answer
177 views

When does the ADC take the reading?

I'm experimenting with the "2 pin capacitance meter" and trying to make it more accurate. Currently I've made the Arduino read 62.5 ns intervals but this means the time for the ADC to read is taking ...
user avatar
0 votes
1 answer
42 views

How to execute commands over desired amount of time

I have a program that receives 4 commands on 4 channels to change the color of an LED using mqtt communication. Lets just focus on two of the channels, the time and the red. I am sending a length of ...
user avatar
1 vote
2 answers
3k views

Converting human readable date to a unix timestamp [duplicate]

Can anyone provide a sample code that would convert a human readable date like 2019-10-27 22:10:35 to a unix timestamp like 1572214235? I found many topics about it, but they eider refer to out of ...
user avatar
  • 242

1
2 3 4 5