daily_automated
This commit is contained in:
4
trunk/Arduino/libraries/MD_LM335A/README.md
Normal file
4
trunk/Arduino/libraries/MD_LM335A/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Designed for efficient implementation:
|
||||
* Does not need floating point library.
|
||||
* Temperatures held in hundredths of degree (23C = 2300).
|
||||
* Vcc parameter implemented as LM335 accuracy is very sensitive to voltage level (nominal 5V).
|
||||
@@ -0,0 +1,29 @@
|
||||
// Temperature sensor testing
|
||||
// LM335K temperature sensor on A0, read through the MD_LM335 library
|
||||
#include <MD_LM335A.h>
|
||||
|
||||
LM335A Temp(A0);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(57600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// read the value from the sensor
|
||||
Temp.Read();
|
||||
|
||||
// display the value - note this is returned in 1/100 of a degree
|
||||
// eg, 32F = 3200
|
||||
Serial.print(Temp.raw);
|
||||
Serial.print(" = ");
|
||||
Serial.print(Temp.dK);
|
||||
Serial.print("K, ");
|
||||
Serial.print(Temp.dC);
|
||||
Serial.print("C, ");
|
||||
Serial.print(Temp.dF);
|
||||
Serial.println("F, ");
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
6
trunk/Arduino/libraries/MD_LM335A/keywords.txt
Normal file
6
trunk/Arduino/libraries/MD_LM335A/keywords.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
LM335A KEYWORD1
|
||||
Read KEYWORD2
|
||||
dF KEYWORD2
|
||||
dC KEYWORD2
|
||||
dK KEYWORD2
|
||||
raw KEYWORD2
|
||||
9
trunk/Arduino/libraries/MD_LM335A/library.properties
Normal file
9
trunk/Arduino/libraries/MD_LM335A/library.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
name=MD_LM335A
|
||||
version=1.0
|
||||
author=majicDesigns
|
||||
maintainer=marco_c <8136821@gmail.com>
|
||||
sentence=Library for using a LM335A temperature sensor.
|
||||
paragraph=Does not need floating point library as temperatures held in hundredths of degree. Analog input is calibrated using Vcc parameter.
|
||||
category=Sensors
|
||||
url=https://github.com/MajicDesigns/LM335A
|
||||
architectures=*
|
||||
59
trunk/Arduino/libraries/MD_LM335A/src/MD_LM335A.cpp
Normal file
59
trunk/Arduino/libraries/MD_LM335A/src/MD_LM335A.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
MD_LM335A - Library for using a LM335A temperature sensor.
|
||||
|
||||
Created by Marco Colli April 2012
|
||||
- Does not need floating point library. Temperatures held in hundredths of degree (23C = 2300)
|
||||
- Vcc parameter as LM335 is very sensitive to voltage level (nominal 5V)
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "MD_LM335A.h"
|
||||
|
||||
int readVcc()
|
||||
// Calculate current Vcc in mV from the 1.1V reference voltage
|
||||
{
|
||||
#if defined(__AVR_ATMega168__) || defined(__AVR_ATMega328__)
|
||||
long result = 5000;
|
||||
|
||||
// Read 1.1V reference against AVcc
|
||||
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
||||
delay(2); // Wait for Vref to settle
|
||||
ADCSRA |= _BV(ADSC); // Convert
|
||||
while (bit_is_set(ADCSRA,ADSC));
|
||||
result = ADCL;
|
||||
result |= ADCH<<8;
|
||||
result = 1126400L / result; // Back-calculate AVcc in mV
|
||||
|
||||
return(result);
|
||||
#else
|
||||
return(5000);
|
||||
#endif
|
||||
}
|
||||
|
||||
LM335A::LM335A(int pin)
|
||||
{
|
||||
pinMode(pin, INPUT);
|
||||
_pin = pin;
|
||||
_Vcc = -1;
|
||||
}
|
||||
|
||||
LM335A::LM335A(int pin, int Vcc)
|
||||
{
|
||||
pinMode(pin, INPUT);
|
||||
_pin = pin;
|
||||
_Vcc = Vcc;
|
||||
}
|
||||
|
||||
void LM335A::Read()
|
||||
{
|
||||
if (_Vcc == -1)
|
||||
_Vcc = readVcc()/10;
|
||||
raw = analogRead(_pin);
|
||||
dK = ((100L * raw * _Vcc) / 1024L); // convert
|
||||
dC = dK - 27315L;
|
||||
dF = 3200L + (((long)dC * 9L)/5L);
|
||||
}
|
||||
35
trunk/Arduino/libraries/MD_LM335A/src/MD_LM335A.h
Normal file
35
trunk/Arduino/libraries/MD_LM335A/src/MD_LM335A.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
MD_LM335A - Library for using a LM335A temperature sensor.
|
||||
|
||||
Created by Marco Colli April 2012
|
||||
- Does not need floating point library. Temperatures held in hundredths of degree (23C = 2300)
|
||||
- Vcc parameter as LM335 is very sensitive to voltage level (nominal 5V)
|
||||
|
||||
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.
|
||||
*/
|
||||
#ifndef MD_LM335A_h
|
||||
#define MD_LM335A_h
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
class LM335A
|
||||
{
|
||||
public:
|
||||
LM335A(int pin);
|
||||
LM335A(int pin, int Vcc);
|
||||
void Read(void);
|
||||
long dF; // in 1/100 of degree (32k = 3200)
|
||||
long dC; // in 1/100 of degree
|
||||
long dK; // in 1/100 of degree
|
||||
long raw;
|
||||
|
||||
private:
|
||||
int _pin;
|
||||
int _Vcc; // in 1/100 V (5V = 500)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user