I've heard other people complain about their Tamagotchi suddenly not being able to connect. This may fix the problem for you (it has worked for some other people): press the reset button on the back, then select the download option from the download/reset menu on the screen.
Yea, definitely try being out of the sun, or even put your hands over the infrared part at the top. Just as long as the sun doesn't interfere you should be good to go. Unless there is a bigger problem, in which case you may have to reset or not be able to connect anymore.