France-based Hexalyse has hooked up an AS3935 Franklin Lightning Sensor to his Raspberry Pi. This sensor is able to detect the approach of a storm by detecting lightning up to 40km away and it comes on a little breakout board that can interact with the Pi over the I2C bus. He used a library that someone else had written and Python to detect the lightning flashes and, if certain circumstances are satisfied (such as number of strikes within a time frame), the system Tweets via the Tweepy library. He’s uploaded the code to GitHub and written up the project on his blog. You can get hold of the sensor from Embedded Adventures (although I’m sure it can be found elsewhere too).