Hydrogen Sulfide sensing with Arduino Due


Performance and characteristics

This little hydrogen sulfide sensor has some pretty impressive specifications.

  • The measurement range is from 0 to 10ppm, with a resolution of 10 ppb (parts per billion).
  • Measurement accuracy is 15% of the reading
  • Measurement repeatability is below ±3% of reading
  • Very important, it has a low cross-sensitivity to other gases:
    • 10ppm chlorine will be registered as -2.2ppm H2S
    • 10ppm NO2 will be registered as -2.0ppm H2S
    • 20ppm SO2 will be registered as 1.7ppm H2S
    • 50ppm NO will be registered as 1.2ppm H2S
    • 400ppm CO will be registered as 1.1ppm H2S
    • Other gases such as ozone (5ppm), methane (500ppm), ammonia (100ppm) will alter the H2S readings by less than 1ppm.
  • The sensor is designed to be powered from 3.3V, with a range of 2.6 to 3.3V power supply voltage
  • Power consumption is 1mW for 1 minute triggered samples and 12mW for continuous operation.
  • Its environmental characteristics allow it to operate outside
    • Temperature Range is 20 to 40 C (-30 to 55 C intermittent)
    • Humidity Range is 15 to 95% (0 to 100% non – condensing intermittent)
    • Sensor lifespan is over 5 years.

Arduino code for the H2S sensor

Here comes the fun part: using the sensor with an Arduino board. I used one Arduino Due, as that board works with 3.3V logic levels. The on;y thing to keep in mind is that the Due is a 32-bit board, and as such the int variable is 32 bit (ranges from -2,147,483,648 to 2,147,483,647). On 8-bit boards some readings will have to be recorded as floats.

Considering the sensor connected to UART1, UART0 being used by the serial monitor, the code I propose performs an EEPROM dump, showing all the settings of the sensor, and then triggers a measurement every 10 seconds. The results are sent to the PC using the Serial Monitor in Arduino IDE.

Some comments regarding the code

The DGS-H2S 968-036 operating manual of the sensor (version March 2017) is a bit ambiguous regarding the UART communication protocol. On page 5 it states that a command is recognized if it’s received within 1-second from a TRIGGER event. On the next page, we find a 5-seconds interval for a command to be recognized.

I have found that the commands are recognized within an 800-milliseconds interval after the trigger event (before the sensor starts sending back the measured values). As a result, configuring the sensor with a terminal program such TeraTerm is next to impossible.

Also, the commands must NOT be terminated with \r\n or with \n, Just the command letter is enough.

Code examples for other commands will be published soon,

When starting for the first time, you will get some extreme readings. This is because the way this sensor works. In one of the technical documents, I have found a piece of information that compares this sensor with a capacitor, with bias placed across the working and reference electrodes being similar to the voltage across the plates of a capacitor. The high current observed at the sensor startup is like the charging current of a capacitor. As such, it is recommended to leave the sensor run for about one hour after power-up to get accurate readings.

[Update 23 October 2018] This is how to use the sensor with an Arduino Uno.

1 2


    • Teodor Costachioiu on

      The sensor is 3.3V only, so it will require some level translators to work with the Arduino Uno.
      The communication protocol is serial, but Arduino Uno has a single serial port. So, if you wish to do serial debugging or to send data to PC, then you will have to use software serial.
      I will try next week to post some images regarding the connections, and maybe a code example for the Arduino Uno, but it will take me a few days to do this.

    • Teodor Costachioiu on

      The analog version requires some extensive computations, especially when speaking on temperature and humidity compensation. The digital version does all this internally, and its easier to use.

  1. Ted,

    What PPB readings are you getting for “clean” air? I’m getting around 250 or so, even after running for several hours.

    • Teodor Costachioiu on

      It will detect H2S, even in very low amounts. However, this won’t be an accurate indicator of “smelliness”, as there are other gases that contribute to the overall odor.

        • Teodor Costachioiu on

          Hi Thomas,

          The cheaper alternative is MQ136 sensor. Also MQ137 might be interesting to detect ammonia. See https://playground.arduino.cc/Main/MQGasSensors for more info on MQ sensors.

          Please note that MQ series sensors are analog. Their output needs to be applied on a pin with A/D function, like A0-A5.

          Also, they are not calibrated. Their output is just proportional with the amount of gas in the air, but you won’t be able to tell exactly how much of the nasty gas is present.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.