Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
40 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
82 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
102 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
30 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
52 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
432 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
134 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
126 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
59 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
75 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
60 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
469 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
101 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
105 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
139 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> ...
0
votes
7answers
784 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
53 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
296 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
92 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
69 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
69 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
85 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
48 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
668 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
65 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; } ...
1
vote
1answer
167 views

How can I handle micros() double rollover?

I know that I can handle a single rollover with subtraction: if (micros() - lastTime > period) { lastTime = micros(); ... } But how it can be handled if this is not true or it is not checked ...
0
votes
1answer
265 views

Is it possible to disable functions/methods?

I recently started using the TimeAction library (which allows for proto-threading) and I noticed it has a really useful function for enabling/disabling threads. I want to use the same idea but apply ...
0
votes
1answer
49 views

Increasing number of iterations not increasing time

I am using Arduino Uno with Atmel Atmega328. I am using micros() function in Arduino IDE to measure time taken for execution. Here is my code: void setup() { Serial.begin(9600); } void loop() { ...
0
votes
2answers
322 views

Alternative of relay

I am carrying out a physics experiment using an Arduino. This experiment requires accurate time measurements of upto a millisecond. However I am using a relay to turn on/off an electromagnet and there ...
3
votes
3answers
654 views

Can't stop my variable value at zero?

In my recent project, I want to set my time according to the requirement. And somehow I'm able to manage that. But when I'm decreasing my time value then one weird problem happens. When decreasing my ...
1
vote
2answers
577 views

How to fade an LED in response to a sensor?

As the sensor "sees" an object nearby, it makes the LED go to full brightness and it remains like that for as long as the sensor keeps on sensing the object. Then, as soon as the sensor stops sensing ...
0
votes
2answers
38 views

Does old/low charge battery affects internal clock?

Totally newbie in eletronics here, but could not find the answer for this one. When a battery is nearly-exhausted, it's voltage and or amperage dims, right? My question is if this kind of scenario (...
0
votes
0answers
63 views

5 * tm1637 displaying different school bells timings

I am working on a project which displays time of School bells for a school, I have got 5*TM1637 Display Tubes which displays 5 Periods/Classes start timings.I can set digits of each TM1637 using the ...
1
vote
5answers
3k views

What is a faster alternative to parseInt()?

I'm making an LED spectrum analyzer with an Arduino Due and my PC. The audio processing is done on the PC, and then sent to the Arduino. The exact data sent is a 'coordinate', or more specifically, a ...
3
votes
3answers
3k views

The exact time for functions or CPU cycles for any function

I'm trying to read input data from the parallel port of a PC and send it to another device. For this purpose the input data is saved, when it's available and is sent if a flag is set. The whole ...
1
vote
0answers
15 views

Deceleration time logger between frequencies

i need to measure the air resistance and roll resistance of a vehicle. I plan on using a toothed disc with a proximity sensor which will output a square wave signal in to an arduino. Then I will drive ...
0
votes
0answers
1k views

Getting current epoch time in seconds and milliseconds

Using Arduino Yun. My code: time_t today; time_t now; ... void setup() { time(now); ... Serial.println( asctime(gmtime(&now))); What I get is: Sat Jan 01 00:00:00 2000 I am expecting ...
1
vote
5answers
4k views

Using millis(), in nested loops

I am using millis() to flash some lights (neopixels) on an arduino pro mini. The problem is that I cannot flash the lights for the desired period. More specifically, the lights flash for ~250 ms, ...
2
votes
4answers
680 views

How to get elapsed seconds since Jan 1, 1970?

I am building a time-critical system using Arduino. Is there any way to get the elapsed seconds like time.h of C in Arduino? I tried time(NULL) but it returns 0. Then moved forward to use now() in ...
0
votes
1answer
48 views

Time Library Adjust Default on Windows

Looking at this Time Arduino library because I would like to send time stamps with data across my HC05-PC channel. https://playground.arduino.cc/Code/Time I wrote this function to get the time at ...
3
votes
1answer
177 views

Why don't these sketches produce a similar output?

I compiled the following two sketches with the compiler used by the Arduino IDE and ran them on an Arduino UNO (smd edition). I'm using: Arduino IDE v. 1.8.0 Arduino AVR Boards v. 1.6.20 1. void ...
3
votes
1answer
6k views

'tmElements_t' does not name a type

I've connected a real time clock ZS-042 to my Arduino Uno. I tried to set the time, using an example from DS1307RTC library. Here is my code: #include <DS1307RTC.h> #include <Time.h> #...
2
votes
1answer
12k views

Get hour with ctime (time library with 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(...
1
vote
0answers
345 views

Time to read/write memory on the DUE

I am onto a project where a need more memory. I saw the 23LC1024 chips are very popular with the Arduino DUE. A very helpful person told me he did some timing tests on the 23LC1024 and a page read/...
0
votes
1answer
71 views

Trigger countdown with 433MHz transmission

I would like to use an arduino to read 433 MHz transmission from multiple Soil Moisture Sensors. Since I can never be sure all transmissions reach the receiver I'd like to set a countdown from the ...
1
vote
1answer
576 views

Measuring distance based on time [closed]

I have written a arduino sketch which is used to measure the distance travelled. Since distance = speed * time , I have initiated speed = 6. I have initiated time = millis() variable and it calculates ...
2
votes
1answer
570 views

Pause in the program for some time

I have a variable timeInSec which records the time as loop begins. It is defined as timeInSec = millis();. I have two conditions. If (timeInSec - lastRun)< 5 (that is 5 sec) , the first condition ...
7
votes
3answers
19k views

Convert to and from Unix Timestamp

What is the best way to convert between date, hours, min, seconds to Unix timestamp in milliseconds in Arduino? I need to have this conversion, since I'm using RTC (date, hours, min, secs etc) and ...
1
vote
1answer
668 views

How do I use ultrasound to track a moving object?

I'm trying to create a small scale, dumb-downed version of the pitch tracking systems used to detect the speed and direction of baseballs. I'm currently working with an HC-SRO4 sensor and an Arduino, ...
1
vote
1answer
845 views

Setting Time to UTC with Data Logger Shield (with RTC DS1387)

I own an Adafruit Data Logger Shield https://www.adafruit.com/product/1141 I followed this tutorial https://learn.adafruit.com/adafruit-data-logger-shield/using-the-real-time-clock This part of code ...