adding threading and callbacks 

prelim save in case wifi cuts out. working on pushbutton and optical sensor