Saturday, April 12, 2014

Arduino on a breadboard with AMT1001 sensor and seven segment display

As efficient as attiny85 may be, you can't run the seven segment library without using another chip.  So for this project, I will have the arduino display the readings of a humidity and temperature from a cheap AMT1001 sensor into a 4-digit seven segment display I salvaged from an old clock. Instead of using an arduino board, I will make an arduino on a breadboard and save the arduino for another project later on.  


Here's the detailed instruction on how to build the arduino on a breadboard. I skipped the parts for the power supply as I plan to power mine with 4 AA  rechargeable batteries. I also did not include the usb to serial board since I will use my arduino to program the atmega chip on the breadboard.
 
It is tight but everything fits on the small breadboard with no room to spare. The seven segment I salvaged was meant to display time so I just stuck a small tape on one of the dots of the colon to make it a decimal. Here it is ready to be powered.

Until now, I still can't believe how the seven segment library works. It is so clever! I thought I would at least see a little bit of flicker because only one segment would be lit at any given time.  I'm really surprised that the numbers look steadily lit.  Even at 60 frames per second, it doesn't flicker at all.

Here it is displaying temperature and humidity.  I programmed it to read the sensors very 4 seconds but it displays the values alternately every second. 

Notes on the AMT1001 sensor:

There isn't a lot on the arduino community using this sensor so I had to dig long and hard to find the calculations to be done on the sketch.  The humidity part is straightforward but I find the temperature reading to be a couple of degrees inaccurate. It uses a thermistor and I had to use an external 10Kohm resistor for the temperature reading.  I compared the value to the LM35 reading and it's giving me a reading of at least 2 degrees lower. To triple check the values, I compared it to a room thermometer and the LM35 is very close.  So I concluded that it's really the AMT1001 that is off. I would probably just use it for the humidity reading and stick with LM35 for the temperature.

Here's a video of it with the thermometer for comparison: http://youtu.be/ShHf0ecPVl8






7 comments:

  1. as you can see it is hard to deal with, so can you share some samples of your sketch

    ReplyDelete
  2. Sure. Here's the part of the sketch that was for temperature...

    float calc_temp(float adval)
    {
    float Temp;
    Temp = log((10240000/adval) - 10000); //you can use the actual measured value of the resistor used
    Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
    Temp = Temp - 273.15; // Convert Kelvin to Celcius
    return Temp*100;
    }

    I think this is based on this link in arduino playground:
    http://playground.arduino.cc/ComponentLib/Thermistor2

    ReplyDelete
  3. Hi, I found that using this thermistor is better to use a lookup table and ensure precision. Is possible to share your sketch to don't start from Zero?
    Thanks - Alvaro

    ReplyDelete
  4. Friend.

    here is what worked fine for me, just couple of decimal points error.


    float Thermistor(int RawADC) {
    long Resistance;
    float Temp; // Dual-Purpose variable to save space.

    Resistance=pad*((1024.0 / RawADC) - 1);
    Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
    Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
    Temp = Temp - 273.15; // Convert Kelvin to Celsius

    but hygrometer not working at all, can you share your humidity code?? also it drifts with temperature.

    Thanks

    ReplyDelete
    Replies
    1. Nice to know you found something that works for you. Here's the code for humidity:

      This part is what's in the loop:
      adval = ad_conv(0, 32); // 32 samples on Channel 0
      RH10 = calc_RH10(adval);
      Serial.print(RH10);

      And this part is the function:

      float calc_RH10(float adval)
      {
      float RH10;
      RH10 = 0.163 * adval;
      return(RH10);
      }

      Delete
  5. Could you post the complete Sketch for Temperature and Humidity? Thanks

    ReplyDelete
    Replies
    1. Here's the sketch. I removed some parts for displaying the output to the LEDs so you might need to adjust some parts if you get an error. You can also try Alvaro's tip above to get a more accurate result.



      int ad_conv(byte channel, byte num);
      float calc_RH10(float adval);
      float calc_TC10(float adval);
      int flg=0;
      int adval, RH10, TC10;

      void setup()
      {
      Serial.begin(9600);
      delay(100);
      }

      void loop()
      {
      //getting the readings from the sensors
      adval = ad_conv(0, 30); // 30 samples
      RH10 = calc_RH10(adval); // humidity
      Serial.println(RH10);

      adval = ad_conv(1, 30); // 30 samples
      TC10 = calc_TC10(adval); // temperature
      Serial.println(TC10);
      }



      int ad_conv(byte channel, byte num)
      {
      long sum = 0;
      byte n;

      for (n=0; n<num; n++)
      {
      sum = sum + analogRead(channel);
      }
      return(sum / num);
      }


      float calc_RH10(float adval)
      {
      //int RH10;
      //RH10 = adval + 6 * adval / 10 + 3 * adval / 100; // 1.63 * adval
      float RH10;
      RH10 = 0.163 * adval;
      return(RH10)*100;
      }


      float calc_TC10(float adval)
      {
      //int TC10;
      //TC10 = adval + 2 * adval / 10 + adval / 100 - 380;
      //return(TC10);
      float Temp;
      // double Thermister(int RawADC)
      // double Temp;
      Temp = log(((10240000/adval) - 10000)); //9730 is the actual measured value of the resistor used
      Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
      Temp = Temp - 273.15; // Convert Kelvin to Celcius
      //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
      return Temp*100;
      }

      Delete