Context is incorrect when calling from a timer
Override the context.

With the timers running partial functions in their own thread, cannot rely on having many context members available. The usual suspects window, screen, scene, object will be None.

One exception is the window manager. 

Test script, starts the timer with the index of the context window in the window managers windows collection.

From the window, the screen, area, space and region can be added to a context override dictionary to pass to the operator.

Test script, renders the largest 3d view open in the current screen.

import time, bpy, functools
from bpy import context

def render(od):
    timestr = time.strftime("%Y%m%d-%H%M%S")
    print(timestr)
    # uncomment below line for error...
    bpy.ops.render.opengl(od, animation=False, sequencer=False, write_still=True, view_context=True)
    return 5.0

def loop(idx):
    window = context.window_manager.windows[idx]
    screen = window.screen
    views_3d = sorted(
            [a for a in screen.areas if a.type == 'VIEW_3D'],
            key=lambda a: (a.width * a.height))
    if views_3d:
        a = views_3d[0]
        # override
        o = {"window" : window,
             "screen" : screen,
             "area" : a,
             "space_data": a.spaces.active,
             "region" : a.regions[-1]
         }
        return render(o)
    return 2.0

#f = functools.partial(loop, bpy.context.screen.name)

if __name__ == '__main__':
    idx = bpy.context.window_manager.windows[:].index(bpy.context.window)
    bpy.app.timers.register(functools.partial(loop, idx), first_interval=5.0)


Note: The big issue here re polling is not all context is available to the timer thread. 

for k, v in bpy.context.copy.items():
    if v is None:
        print(k) 


in loop method above will demonstrate which context members are not available (set to None).

and hence would recommend using a modal timer operator (wired to use context), that you could turn on and off from a button 

Related 

How to run a python script at regular intervals?

Need help moving a set of cubes from one end to the other on x-axis with python scripting