@tuftec, yes you are correct, the machine.deepsleep() machine.remaining_sleep_time() and pin_deepsleep_wakeup() functions all work fine.
I have isolated my problem was with the LoRa publishing code. When I commented out the lora_publish in my code below everything worked fine. The bug must be something to do with nvram functions i am using in my lora_publish function. Perhaps this bug is best published in a new thread. Thanks for the comment.
Code published to allow others a quick start!
import machine
import utime
from machine import Pin
import pycom
import config #user defined
#import LoRa_publish #user defined
rst=machine.reset_cause()
if rst != 3: # if not woken from deepsleep
utime.sleep(10) #to allow ctrl+C
pycom.nvs_set('counter', 0)
#button = Pin('P23', mode = Pin.IN, pull = Pin.PULL_UP)
machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
machine.deepsleep(60000)
else:
if (machine.wake_reason()[0])==1: #pin wakeup
total_count = pycom.nvs_get('counter') +1
pycom.nvs_set('counter', total_count)
print('remaining deepsleep time is {}'.format(machine.remaining_sleep_time()))
machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
machine.deepsleep(machine.remaining_sleep_time())
elif (machine.wake_reason()[0])==2: #RTC timer complete
print('timer completed')
total_count = pycom.nvs_get('counter')
print('counted {} button presses'.format(total_count))
#LoRa_publish.publish(total_count) #INT published to TTN
pycom.nvs_set('counter', 0)
machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True)
machine.deepsleep(60000) #this does not restart a new interval!!