Getting an error 507: unable to connect to device, are you sure it is on

It worked for me with simpler code.