old_contents: import machine
  
  def have_internet(retry = 5):
    import urequests
    for x in range(retry):
      try:
        resp = urequests.request("HEAD", "http://jsonip.com/")
        return True
      except:
        None
    return False
    
  def setntptime(maxretries=10):
    # ntptime is a helper module which gets packaged into the firmware
    # Check https://raw.githubusercontent.com/micropython/micropython/master/esp8266/scripts/ntptime.py
    import ntptime
    for i in range (maxretries):
      try:
        ntptime.settime()
        break
      except:
        if i+1 == maxretries:
          raise
  
  def deepsleep(sleeptime=15*60*1000):
    # configure RTC.ALARM0 to be able to wake the device
    rtc = machine.RTC()
    rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
  
    # set RTC.ALARM0 to fire after some time. Time is given in milliseconds here
    rtc.alarm(rtc.ALARM0, sleeptime)
  
    #Make sure you have GPIO16 connected RST to wake from deepSleep.
    # put the device to sleep
    print ("Going into Sleep now for %d ms"%(sleeptime))
    machine.deepsleep()
new_contents: import machine
  
  def have_internet(retry = 5):
    import urequests
    for x in range(retry):
      try:
        resp = urequests.request("HEAD", "http://www.apache.org/")
        return True
      except:
        None
    return False
    
  def setntptime(maxretries=10):
    # ntptime is a helper module which gets packaged into the firmware
    # Check https://raw.githubusercontent.com/micropython/micropython/master/esp8266/scripts/ntptime.py
    import ntptime
    for i in range (maxretries):
      try:
        ntptime.settime()
        break
      except:
        if i+1 == maxretries:
          raise
  
  def deepsleep(sleeptime=15*60*1000):
    # configure RTC.ALARM0 to be able to wake the device
    rtc = machine.RTC()
    rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
  
    # set RTC.ALARM0 to fire after some time. Time is given in milliseconds here
    rtc.alarm(rtc.ALARM0, sleeptime)
  
    #Make sure you have GPIO16 connected RST to wake from deepSleep.
    # put the device to sleep
    print ("Going into Sleep now for %d ms"%(sleeptime))
    machine.deepsleep()
subject: change the url to check internet connection the old url is redirecting and urequests module doent support urls which redirect use apache.org which works and has no redirects. TODO - Find a better url