A method for digital temperature and drift compensation of a quartz crystal with a parabolic dependency on temperature from its nominal frequency for a sleep timer used for a NarrowBand Internet of Things (NB-IoT) device, the method comprising the following steps: - determining a temperature dependence of the quartz crystal frequency offset against an external reference, resulting in quartz crystal parameters, - storing the quartz crystal parameters for further processing, - acquiring a temperature measured by a temperature sensor , - calculating a deviation of the quartz crystal frequency offset due to its temperature dependence and the measured temperature, and - generating compensation pulses for the sleep timer according to the deviation of the quartz crystal frequency offset d(T) as a function of the measured temperature T to adjust a counter value of the sleep timer of the NB-IoT device, by compensating a counter bias C T = f 0 + d f ⋅ Δ t + { d c ⋅ Δ t for d f < 0 − d c ⋅ Δ t for d f ≥ 0 of the sleep timer by adding / subtracting compensation pulses d c• Δt wherein the counter bias reaches, in a given interval, a value which is too low or too high, wherein C T is the compensated counter bias, f 0 is the nominal frequency of the sleep timer, d f is an overall uncertainty of the quartz frequency offset describing a momentary deviation at a given point in time, Δt is a sampled interval, d c is a clock derived from an offset clock f T of the temperature-influenced quartz clock of the sleep timer, whereas the compensation pulses are performed in sleeping periods of the NB-IoT device according to the parabolic dependency on temperature of the quartz crystal frequency offset and acquired temperature, and wherein the temperature is acquired at fixed or adaptive temperature sampling intervals. - determining a temperature dependence of the quartz crystal frequency offset against an external reference, resulting in quartz crystal parameters, - storing the quartz crystal parameters for further processing, - acquiring a temperature measured by a temperature sensor , - calculating a deviation of the quartz crystal frequency offset due to its temperature dependence and the measured temperature, and - generating compensation pulses for the sleep timer according to the deviation of the quartz crystal frequency offset d(T) as a function of the measured temperature T to adjust a counter value of the sleep timer of the NB-IoT device, by compensating a counter bias C T = f 0 + d f ⋅ Δ t + { d c ⋅ Δ t for d f < 0 − d c ⋅ Δ t for d f ≥ 0 of the sleep timer by adding / subtracting compensation pulses d c• Δt wherein the counter bias reaches, in a given interval, a value which is too low or too high, wherein C T is the compensated counter bias, f 0 is the nominal frequency of the sleep timer, d f is an overall uncertainty of the quartz frequency offset describing a momentary deviation at a given point in time, Δt is a sampled interval, d c is a clock derived from an offset clock f T of the temperature-influenced quartz clock of the sleep timer, whereas the compensation pulses are performed in sleeping periods of the NB-IoT device according to the parabolic dependency on temperature of the quartz crystal frequency offset and acquired temperature, and wherein the temperature is acquired at fixed or adaptive temperature sampling intervals. <EOS>