reeedstudio 11 лет назад
Родитель
Сommit
62a2464db8
6 измененных файлов с 300 добавлено и 2 удалено
  1. 53 0
      High_Temp.h
  2. 131 0
      Hight_Temp.cpp
  3. 21 0
      License.txt
  4. 48 2
      README.md
  5. 25 0
      examples/getTemperature/getTemperature.ino
  6. 22 0
      keywords.txt

+ 53 - 0
High_Temp.h

@@ -0,0 +1,53 @@
+/*
+  High_Temp.h
+
+  2014 Copyright (c) Seeed Technology Inc.  All right reserved.
+  
+  Loovee
+  2013-4-14
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+#ifndef __HIGH_TEMP_H__
+#define __HIGH_TEMP_H__
+
+class HighTemp{
+
+public:
+
+    HighTemp(int _pinTmp, int _pinThmc);
+    
+    float getRoomTmp();                      // 
+    float getThmc();
+    
+
+
+private:
+
+    int pinRoomTmp;                         // pin of temperature sensor
+    int pinThmc;                            // pin of thermocouple
+    
+    float tempRoom;                         // room temperature
+    float tempThmc;                         // thermocouple temperature
+
+public:
+
+    int getAnalog(int pin);
+    float K_VtoT(float mV);                 // K type thermocouple, mv->oC
+    float getThmcVol();                     // get voltage of thmc in mV
+};
+
+
+#endif

+ 131 - 0
Hight_Temp.cpp

@@ -0,0 +1,131 @@
+/*
+  High_Temp.cpp
+
+  2014 Copyright (c) Seeed Technology Inc.  All right reserved.
+
+  Loovee
+  2013-4-14
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include <Arduino.h>
+#include "High_Temp.h"
+
+
+const float VOL_OFFSET = 350;                      // offset voltage, mv
+const float AMP_AV     = 54.16;                     // Av of amplifier
+
+
+const float Var_VtoT_K[3][10] =
+{
+    {0, 2.5173462e1, -1.1662878, -1.0833638, -8.9773540/1e1, -3.7342377/1e1,
+    -8.6632643/1e2, -1.0450598/1e2, -5.1920577/1e4},
+    {0, 2.508355e1, 7.860106/1e2, -2.503131/1e1, 8.315270/1e2,
+    -1.228034/1e2, 9.804036/1e4, -4.413030/1e5, 1.057734/1e6, -1.052755/1e8},
+    {-1.318058e2, 4.830222e1, -1.646031, 5.464731/1e2, -9.650715/1e4,
+    8.802193/1e6, -3.110810/1e8}
+};
+
+
+HighTemp::HighTemp(int _pinTmp, int _pinThmc)
+{
+    pinRoomTmp = _pinTmp;
+    pinThmc    = _pinThmc;
+    
+    tempRoom   = getRoomTmp();
+}
+
+
+float HighTemp::getThmc()
+{
+    float vol  = getThmcVol();
+
+    tempThmc = K_VtoT(vol) + tempRoom;
+    
+    return tempThmc;
+}
+
+
+int HighTemp::getAnalog(int pin)
+{
+    long sum = 0;
+
+    for(int i=0; i<32; i++)
+    {
+        sum += analogRead(pin);
+    }
+
+    return ((sum>>5));                                              // 3.3V supply
+}
+
+
+float HighTemp::getRoomTmp()
+{
+    int a = getAnalog(pinRoomTmp)*50/33;                                // 3.3V supply
+    float resistance=(float)(1023-a)*10000/a;                           // get the resistance of the sensor;
+    float temperature=1/(log(resistance/10000)/3975+1/298.15)-273.15;   // convert to temperature via datasheet ;
+    
+    tempRoom = temperature;
+    return temperature;
+}
+
+
+float HighTemp::getThmcVol()                     // get voltage of thmc in mV
+{
+    float vout = (float)getAnalog(pinThmc)/1023.0*5.0*1000;
+    float vin  = (vout - VOL_OFFSET)/AMP_AV;
+    return (vin);    
+}
+
+
+float HighTemp::K_VtoT(float mV)
+{
+    int i = 0;
+    float value = 0;
+
+    if(mV >= -6.478 && mV < 0)
+    {
+        value = Var_VtoT_K[0][8];
+
+        for(i = 8; i >0; i--)
+        value = mV * value + Var_VtoT_K[0][i-1];
+        
+        cout << "h1" << endl;
+        
+    }
+    else if(mV >= 0 && mV < 20.644)
+    {
+        value = Var_VtoT_K[1][9];
+
+        for(i = 9; i >0; i--)
+        {
+            value = mV * value + Var_VtoT_K[1][i-1];
+        }
+        
+        cout << "h2" << endl;
+    }
+    else if(mV >= 20.644 && mV <= 54.900)
+    {
+        value = Var_VtoT_K[2][6];
+
+        for(i = 6; i >0; i--)
+        value = mV * value + Var_VtoT_K[2][i-1];
+        
+        cout << "h3" << endl;
+    }
+
+    return value;
+}

+ 21 - 0
License.txt

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Seeed Technology Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 48 - 2
README.md

@@ -1,2 +1,48 @@
-Grove_HighTemp_Sensor
-=====================
+Seeed QTouch
+-------------------------------------------------------------
+![image](http://www.seeedstudio.com/wiki/images/3/33/Sidekick_19_0.png)
+
+LED Bar, common in volume display, is a common sensor component to display analog value. You can use a row of discrete LED lights to make division of this effect, you can also use our element mentioned here. 
+
+For more information, please refer to [Grove_LED_Bar][1]
+
+#Usage
+
+1. To judge certain key if touched
+
+    	unsigned char isTouch(int key)		// key- 0~6, if touched return 1
+
+2. Get touch state
+   
+   	bits 0 to 6 indicate which keys are in detection, if any. Touched keys report as 1, untouched or disabled
+    keys report as 0.
+
+		unsigned char getState()			// will touch state
+
+3. Get Touch Num
+
+		int touchNum();
+
+	if no touched, return -1. or will return the touched key number.
+
+----
+This software is written by Loovee for seeed studio<br>
+and is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Check License.txt for more information.<br>
+
+Contributing to this software is warmly welcomed. You can do this basically by<br>
+[forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above<br>
+for operating guide). Adding change log and your contact into file header is encouraged.<br>
+Thanks for your contribution.
+
+Seeed Studio is an open hardware facilitation company based in Shenzhen, China. <br>
+Benefiting from local manufacture power and convenient global logistic system, <br>
+we integrate resources to serve new era of innovation. Seeed also works with <br>
+global distributors and partners to push open hardware movement.<br>
+
+
+
+[1]:http://www.seeedstudio.com/wiki/LED_Bar
+
+
+
+[![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/Grove_LED_Bar)](https://github.com/igrigorik/ga-beacon)

+ 25 - 0
examples/getTemperature/getTemperature.ino

@@ -0,0 +1,25 @@
+// demo of Grove - High Temperature Sensor
+// Thmc -> A5
+// RoomTemp -> A4
+
+#include "Streaming.h"
+#include "High_Temp.h"
+
+
+HighTemp ht(A4, A5);
+
+
+void setup()
+{
+    Serial.begin(115200);
+    cout << "hello world" << endl;
+    
+    cout << "Room Temperature = " << ht.getRoomTmp() << endl;
+}
+
+void loop()
+{
+    cout << ht.getThmc() << endl;
+   //  cout << ht.K_VtoT(7) << endl;
+    delay(100);
+}

+ 22 - 0
keywords.txt

@@ -0,0 +1,22 @@
+LED_Bar	KEYWORD1
+Seeed_QTouch	KEYWORD1
+QTouch	KEYWORD1
+
+isTouch	KEYWORD2
+getState	KEYWORD2
+setLowPowerMode	KEYWORD2
+reset	KEYWORD2
+setMaxDuration	KEYWORD2
+calibrate	KEYWORD2
+
+
+ADDR_QTOUCH	KEYWORD3
+QTOUCH_REG_CHIPID	KEYWORD3
+QTOUCH_REG_VERSION	KEYWORD3
+QTOUCH_REG_DETSTATUS	KEYWORD3
+QTOUCH_REG_KEYSTATUS	KEYWORD3
+QTOUCH_REG_KEYSIGM	KEYWORD3
+QTOUCH_REG_LPMODE	KEYWORD3
+QTOUCH_REG_MAXDURA	KEYWORD3
+QTOUCH_REG_CALIBRATE	KEYWORD3
+QTOUCH_REG_RESET	KEYWORD3