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
2answers
111 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 ...
0
votes
0answers
56 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 ...
0
votes
1answer
56 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
1answer
60 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 ...
0
votes
2answers
117 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
1answer
56 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 ...
0
votes
1answer
70 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
1answer
165 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 ...
0
votes
1answer
54 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 ...
0
votes
0answers
49 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
1answer
46 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
1answer
43 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
0answers
26 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
36 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
82 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
503 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
1k 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
25 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
1k 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
35 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
69 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
36 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
869 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
30 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
54 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
107 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
98 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
53 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
135 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
61 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
1answer
60 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
54 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
336 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
1answer
49 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
120 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 ...
1
vote
0answers
391 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
240 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
65 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
4k 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
917 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
1k 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
53 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
62 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
293 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
104 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
1k 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
363 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
149 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
445 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
3k 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 ...