Sometimes the old solutions are the best. In this case the solution is “Turn it off and then on again”. I’m using a BME280 temperature, pressure and humidity sensor in the air quality monitor that I’m building. It works well, except sometimes, when it refuses to say hello when it starts up.
This has caused a certain amount of head-scratching. However, after a while I worked out that it only misbehaved after I had downloaded some code into the device. It’s as if it doesn’t like being woken up twice once it has been powered up.
Now if it gets stuck I just unplug the device and plug it back in. It’s something to be born in mind when you can’t get something to work.
I have a special category in my work (particularly with hardware) called “Things you do to make it work but you don’t know why”. This is another one.