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
0
votes
1answer
39 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 ...
0
votes
1answer
21 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,...
0
votes
0answers
29 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' ...
0
votes
1answer
36 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()...
0
votes
1answer
81 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 ...
0
votes
1answer
173 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 ...
-1
votes
1answer
21 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 ...
1
vote
1answer
247 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 ...
0
votes
1answer
25 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 =...
0
votes
1answer
54 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 ...
0
votes
1answer
30 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 ...
1
vote
2answers
261 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 ...
0
votes
0answers
23 views

Send information from computer to Arduino via USB (basic clock)

I've created a small project using an Uno. I usually mess around with ESP8266 chips, because they have WiFi and are relatively easy to work with. However, this time I've decided to go right back to ...
-1
votes
1answer
45 views

how to convert date to timestamp? [duplicate]

How should I convert date format(dd-mm-yyyy) to timestamp value . Can anyone suggest code how to convert and where to put code .
0
votes
1answer
73 views

Time information from GPS receiver: how to tell whether it is fresh or stale?

I see that TinyGPS++ library extracts time information from GxRMC and GxGGA NMEA sentences streamed by GPS receiver. However, in my experiments I observed that both of my GPS receivers generate GxRMC ...
0
votes
4answers
88 views

When GPS can't see satellites, how can I continue to tick off a smooth-ish time?

I'm getting 10 updates/sec from my GPS unit (The MTK3339 used in the Adafruit breakout board), and using it to update a clock display. This works well enough, though there's one minor problem that I'd ...
-1
votes
1answer
51 views

Using a Force Sensing Resistor and time input

So the code below measures how much force is exerted on the FSR. I would like to know what would I have to change in this code so that it can record for how long the FSR is being pressed for. So ...
0
votes
1answer
92 views

Arduino is running as a server, but want to occasionally act as a client to update time

My Arduino (actually an ESP32-based Adafruit HUZZAH32) is running as a wifi server. Its main job is to service GET requests from a user, and to periodically turn devices on and off based on the ...
0
votes
1answer
50 views

Why does a function inside void set up is repeating after some minutes

I am trying to time sync my arduino hardware to NTP server. I have a `setSyncProvider(getNtpTime)´ function to do it and called inside the void setup. I have another function (mainFunction) inside the ...
0
votes
0answers
76 views

Send time with ctime to firebase (time library , esp8266)

#include <ESP8266WiFi.h> #include <time.h> const char* ssid = ""; const char* password = ""; int timezone = 3; int dst = 0; void setup() { Serial.begin(115200); Serial.setDebugOutput(...
0
votes
1answer
43 views

RDTSC alternative for Arduino

To calculate an operation execution time, I was saving the millis() result before and after the operation to calculate the interval time. Is there an alternative on the Arduino Uno like the RDTSC ...
0
votes
2answers
38 views

Timestamping AnalogBinLogger data

I would like to timestamp the data collected from AnalogBinLogger.ino on an Arduino Uno. The sketch uses 512-byte buffers, and I have read that writing data in 512-byte chunks is 'better' in terms of ...
2
votes
1answer
281 views

NTP rollover-safe design with ESP8266 (Curiosity)

The Arduino NTP implementation is rather naive in some respects. It basically just grabs the time in seconds from the raw packet, and then converts it to Unix time via subtraction. How would it be ...
0
votes
0answers
186 views

Create file with timestamp

I have a code which creates a file then store relevant data. My first purpose was creating then rewriting (delete & write again) with same filename. However, now I have to log different data to ...
0
votes
1answer
47 views

How do I start a task and have it run for a set amount of time?

I have a project where I need to turn a 24V solenoid on for a set amount of time, then have it turn off. I am rather new to Arduino and not certain how to do this or really where to start. Ideally the ...
0
votes
2answers
98 views

Is there a way to get my MacBook's date and time into Arduino IDE?

I am using a DS3231 RTC module. It requires to set the time every time it is reset. I was wondering if I could read my MacBook's time and date and feed into the module at the setup stage. Is this ...
0
votes
0answers
343 views

Set local stratum 0 NTP server without internet

Currently, I'm doing a running track timing gate project to measure an accurate acceleration (a runner for example). The idea is when the runner triggers the first gate (start gate), the system will ...
0
votes
1answer
156 views

Verifiy NTP server update - at start

I have function to start an NTP service, right after obtaining wifi connection ( using ESP8266 board ). from time to time, I get an error saying date and time is01-01-1970... which I assume is due to ...
2
votes
0answers
62 views

Why would using the += operator on an unsigned long crash my sketch? [closed]

I wrote a simple Timer class that's designed to work even in the face of the 49 day wrap of the millis() counter. I wanted a library that I could easily re-use and I could never remember the right way ...
0
votes
1answer
2k views

How to converte EPOCH time into time and date on Arduino?

I have a question on how to convert EPOCH timestamps, which I receive as char*, into DD.MM.YYYY and HH:MM:SS format seperately? Here are more information to my Arduino project: The Arduino is ...
-1
votes
1answer
561 views

Handling overflow in micros() [duplicate]

The documentation for micros() says: Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately ...
0
votes
1answer
739 views

How to find the difference between two timestamps

I'm using this time library to access the properties of unix timestamps like hours / minutes / etc. What I want to do is get the current time, and an estimated arrival time, and find the difference ...
0
votes
1answer
49 views

Loops fail after ~5 minutes when making two API calls every 10 seconds using WiFi client

I am running into an issue with a loop call on an Arduino MKR1000. I have tried the solutions suggested in this question and it usually works for 5 minutes and then collapses. I am trying to make two ...
0
votes
1answer
61 views

How to know which event fired first?

I want to automate the chicken coop of my grandmother. To do so, I want to use Arduinos and NodeMCUs, respectively. I want to check if all chickens are in the coop at night and then close a little ...
0
votes
1answer
193 views

TimeAlarms stops working when using setSyncProvider(RTC.get) DS1307

Been working on this project for some time now, like title states when I un-comment setSyncProvider(RTC.get) in the setup the program fails to get any of the Alarm.timerOnce to run. I have been stuck ...
0
votes
1answer
89 views

What is the smallest duration that can be measured using micros()? [closed]

What is the least value of time that I could measure(count) using micros()?
0
votes
2answers
920 views

Getting FFT arduino code to run over 9+ hours, utilizing micros()

I am a beginner in Arduino, coding, and electrical engineering (learning on my own time) and am working on creating an EEG. I've got the hardware down and have managed to get numerical data output ...
0
votes
1answer
255 views

Hibernate Arduino for 12hrs with rtc1302 module

ok, Good morning, guys, with a data acquisition project, in this, I get data every 12 hours, even if it's only 12 hours, the arduino gets connected directly, and it's being powered by a 9v battery, ...
0
votes
2answers
134 views

Parse UNIX-time from char[]

I want to parse a large number to sync time on my arduino. For this i send it a string with the current time in Unix time format wich looks somethink like this: 1535441277 For this I just call a ...
0
votes
4answers
347 views

How to repeat the code

I want to make my biped robot keep walking, but it only move for twice, this biped robot project is important for my Capstone project. The code below is the code that I used #include <Servo.h> ...
1
vote
7answers
2k views

How to parse 20180810T143000Z to time_t

What is the shortest/most elegant way (i.e. use existing lib functions) to parse a string in the form of 20180810T143000Z to a time_t? Note that the literal always represents a UTC timestamp. I ...
0
votes
1answer
93 views

Arduino sketch- How to add Time Stamp for outgoing MQTT

I'm writing a sketch in order to upload to a Sonoff device ( Remote relay, based ESP8266 ). All is working great, but I wish my MQTT pubs to contain following format: [ DATE & TIME ] msg ...
0
votes
1answer
584 views

Arduino - Calculating the time for which a Pushbutton is pressed and held without being released

I'm working on a project that requires calculating the time for which a pushbutton is kept pressed without being released. Is there a code snippet that i can use for this particular need ?
3
votes
2answers
228 views

What precision can I expect by syncronising DS3231 with PC serial?

The point here is to syncronise a DS3231 module (on an Arduino) via serial port with NTP time by computer. The problem here is that I'd like to know how much time is taken by the serial and I2C ...
1
vote
2answers
124 views

Need Input: Wait for voltage input to begin script & when voltage maintains 0V for X amount of time Reset and wait for Voltage Input

So I'm currently working on an automotive set up. I'm using a 555 timer to emulate a turn-signal alternating voltage pulse (12V to 0V and repeat) for debugging purposes which is output to turnPin/A1. ...
0
votes
1answer
216 views

Set computer time on arduino uno [closed]

How to set computer time on Arduino Uno, and then control it (Arduino) with Serial monitor. For example show time on LCD. I have no idea, how to make it using Arduino IDE. So, maybe I can write code ...
0
votes
1answer
115 views

comparison in a time sequence [closed]

in an Arduino sketch a user is invited to input a number representing a time in the format HH:MM, this number is to be added at the end of an ordered and limited sequence of times --the first input (...
0
votes
2answers
53 views

Tian stops working after some hours

I'm having a very strange problem. I have a Tian that is programmed to send out sensor data to a server every x seconds. My program run well but after 14,15 hours of operation it stops working and I ...
1
vote
2answers
1k views

How do I execute some code at a certain time without RTC module?

I am building a project when I need my arduino to execute some code at two given hours of the day, for example one at 19:00 and another at 06:00. I know that with a RTC module I can do this easily, ...
1
vote
0answers
83 views

Storing random and different values of millis() while inside a loop? [closed]

Is it possible to store a value of time while you're inside a loop? Entertain the condition: if (condition && value > 0) { timeTrans = millis() + 2000; timeTrans - millis() = value; } ...