A simple Arduino gas detector example.

Overview

So you may be wondering why I tried this. Well, I wrote some code to check for dangerous gases released when charging lead acid batteries as a safety concern at work. This came about because we charge lots of sealed lead acid batteries which usually charge without any problems but on one occasion one battery had failed causing the room to fill with a rotten egg stink. This is not just a bad smell; in fact it was Hydrogen Sulphide we were smelling which is very toxic in large concentrations. This definitely was bad; the entire building stunk on both floors and it took all day to get rid of the stink with windows open. In the middle of winter I might add. Faulty batteries can also release hydrogen which is explosive if in a sealed room and with a high enough concentration although modern SLA batteries do not give off nowhere near as much as flooded types. However H2S gas is bad for your health in any concentration and is produced by all lead acid batteries when misused or overcharged. Such gases are also found in rubbish dumps and sewers and other areas with decomposing organic matter in enclosed spaces.

So I wrote code for a sensor that would detect these gases and display the levels on a LCD display triggering visual and audible alarms if thresholds were met. The software also triggered a relay which could turn off the chargers and turn on an extractor fan. Often batteries were left on charge overnight and automatic gas detection and prevention was a must. I also planned to add a remote monitoring facility as well.

Anyway for reasons I cannot explain the project was cancelled so I simplified my code and added a methane sensor to the mix as well. You guessed it; there is another use for my code…

Continue reading

Building an LCD alarm clock & DS1307 RTC accuracy

I’ve been working on a new Arduino project; the ultimate alarm clock which shows the time and date on a 16×2 LCD module and features multiple alarms with repeat / auto arm and radio function. I used a Tiny DS1307 RTC and EEPROM module which is a breadboard / veroboard compatible PCB containing a DS1307 RTC chip and a 24C32 i2C EEPROM. There is also a place for a DS18B20 thermal sensor but mine did not have this installed.

The clock functions great but I have found that the RTC module gains time about 6 seconds a day. This is due to a number of issues; the quality of the crystal used, the position of it on the PCB, the value of the load capacitors and it’s questionable if the DS1307 is a genuine Maxim chip or not. The module came from Banggood (China) at a cost of only a few pence of the chip itself (in bulk) so who knows.

The DS1307 is not known for it’s accuracy though; the DS3231 is a better choice if you need accuracy as it works with the basic functions of the DS1307 libraries. It just lacks some features such as onboard NVRAM. As I needed to use this NVRAM to store alarm settings etc I had to go with the DS1307 and write some code to halt the Arduino for 6 seconds then write the time back to the DS1307 minus 6 seconds. This should work in theory bringing the accuracy in line with the DS3231 and DS3232 RTC chips.

I have been testing it for a few days and I can now post the rest of the project details.

Continue reading