I have a weather station project feeding information to my nodeRed platform using MQTT and Mosquitto. I want to pull the data every 60 seconds. Would a 555 timer keep time drift to a minimum (if so please go ahead and explain what the purpose is apart from keeping time in check) or would the 16MHZ oscillator I have on my 328P should do?
TIA
Nathanial
The accuracy of "a 555 timer" is affected by its external timing components and the stability of its power supply among many things. Since the timing signal is provided by the charge and discharge times of a capacitor through one and two resistors, any change in supply voltage would alter the charge rate of the capacitor and therefore the rate of change of the voltage signal that triggers either one of two comparators internally. Changes in temperature affect the resistance of resistors, thus also affecting the rate of charge and discharge of the capacitor. The stability of the external components, the power supply and to some extent the temperature of the device itself all influence accuracy. The 555 family are multivibrators rather than timers. It is common practice to refer to them as timers, but not particularly correct. Different circuit arrangements allow the use of the 555 family as astable or bistable devices. It is as an astable that the "timer" function is implemented. They can be used in many other useful configurations as well, once the internal circuitry is understood. You don't need to implement such a timer to do what you want.
The AVR328P has 3 internal timers that can be set to provide a range of timing options. The datasheet, and many articles on this site details how these can be used. You might use Arduino functions (Delay()) to time the delay between pulls, for example. This function has the disadvantage that it prevents any processing while a delay is underway. You might also use the millis function as explained in the "Blink without delay" example sketch, which allows ongoing processing while the timing interval is underway.
I use the second method to provide multiple timing intervals in my own weather station, so that wind speed can be averaged every 2 minutes and temperatures measured every 10 minutes at which time the data sample is sent to a server. The accuracy that can be achieved has been demonstrated consistently over 9 years of operation. It is not perfect, but then how accurate is enough?
The '555 doesn't have a single purpose, its a toolkit for making astables, monostables, relaxation oscillators
and anything else you can wrangle from its internal components. CMOS versions like the ICM7555 better
behaved, take less power and are recommended these days (well since the 1980's in fact!)
Its not highly stable for timing, that takes a quartz crystal.
If your ATmega328P is using a quartz oscillator rather than ceramic resonator it will be capable of far
superior timing than any '555.
If you want to log dates/times an RTC module is probably the way to go.
[ BTW when the NE555 first came out it was seen as a big thing to have a voltage divider chain,
more than one comparator and some glue-logic all combined in one device. Its certainly stood
the test of time better than most things from that era ]
I agree that a 555 is not a stable way to do some timing, but supply voltage tends to NOT be an issue due to the voltage divider that is used for charging, discharging, high trigger and low trigger.
Nathanial777:
I have a weather station project feeding information to my nodeRed platform using MQTT and Mosquitto.
You have a network connection. You can use the NTP protocol to get the time from a time server.
Your crystal will provide you a constant time when the environment (voltage and temperature) stays stable. But the frequency of the crystal is within a certain tolerance. Every crystal is slightly different. Therefore, over time the actual time will drift. But the drift should be predictable.
Let your board run for a day and you will get a time difference. Use that to choose a interval for your NTP synchronization. e.g. if you have 1 second drift over 24h update once a day, when you have 10 seconds update time every hour.
If you are just worried about getting a measurement every 60 seconds (and not the actual time) you do not need to do anything. Just use millis() to measure a 60 second interval. If your crystal creates a 59,99 second interval. That interval will be the same in 5 minutes or 10 days.