using 1.1v Vref on the Arduino analog to digital converter for better precision
This commit is contained in:
parent
dd4757f56c
commit
acd1248fa5
@ -7,17 +7,17 @@ TMPFILE="/tmp/dd2data"
|
|||||||
IMAGE="graphe.png"
|
IMAGE="graphe.png"
|
||||||
NB_READ=5000
|
NB_READ=5000
|
||||||
|
|
||||||
./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
|
./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
|
||||||
|
|
||||||
gnuplot << __EOC__
|
gnuplot << __EOC__
|
||||||
set term png size 3200,512
|
set term png size 3200,640
|
||||||
set output "${IMAGE}"
|
set output "${IMAGE}"
|
||||||
set grid
|
set grid
|
||||||
set title "Temperature dans le Double Dragon 2"
|
set title "Temperature dans le Double Dragon 2"
|
||||||
set xdata time
|
set xdata time
|
||||||
set timefmt "%s"
|
set timefmt "%s"
|
||||||
set format x "%a, %H:%M:%S"
|
set format x "%a, %H:%M:%S"
|
||||||
set yrange [ 5.0 : 30.0]
|
set yrange [ 0.0 : 30.0]
|
||||||
plot "${DATAFILE}" using 1:2 title " foo" with lines, \
|
plot "${DATAFILE}" using 1:2 title " foo" with lines, \
|
||||||
"${DATAFILE}" using 1:3 title " bar" with lines, \
|
"${DATAFILE}" using 1:3 title " bar" with lines, \
|
||||||
"${DATAFILE}" using 1:4 title "quux" with lines, \
|
"${DATAFILE}" using 1:4 title "quux" with lines, \
|
||||||
|
@ -45,12 +45,18 @@ return value;
|
|||||||
/*
|
/*
|
||||||
* this fonction is specific to the LM35 thermo-sensor
|
* this fonction is specific to the LM35 thermo-sensor
|
||||||
* connected to a ADC pin of an Arduino Mega
|
* connected to a ADC pin of an Arduino Mega
|
||||||
|
*
|
||||||
|
* WARNING !
|
||||||
|
* this function _must_ be modofied if you change the
|
||||||
|
* Vref of the Analog to Digital converter on the
|
||||||
|
* Arduino !
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
int values2temperature(float array[4])
|
int values2temperature(float array[4])
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
for (foo=0; foo<4; foo++) {
|
for (foo=0; foo<4; foo++) {
|
||||||
array[foo] *= (5.0 / 1023.0 * 100.0);
|
array[foo] *= (1.1 / 1023.0 * 100.0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,9 @@ float datas[4];
|
|||||||
for (count=0; count<iters; count++) {
|
for (count=0; count<iters; count++) {
|
||||||
foo = getline_to(sfd, ligne, 100, 0);
|
foo = getline_to(sfd, ligne, 100, 0);
|
||||||
//
|
//
|
||||||
if (verbosity > 1) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "getline #%d on %d -> %d\n",
|
/* fprintf(stderr, "getline #%d on %d -> %d\n",
|
||||||
count, iters, foo);
|
count, iters, foo); */
|
||||||
fprintf(stderr, "%s\n", ligne);
|
fprintf(stderr, "%s\n", ligne);
|
||||||
}
|
}
|
||||||
foo = parse4values(ligne, 'T', datas);
|
foo = parse4values(ligne, 'T', datas);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
|
|
||||||
#define NBVAL 4
|
#define NBVAL 4
|
||||||
#define DELAI 10000
|
#define DELAI 12000
|
||||||
|
|
||||||
int values[NBVAL];
|
int values[NBVAL];
|
||||||
|
|
||||||
@ -13,7 +13,14 @@ void setup() {
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
Serial.print("\n");
|
Serial.print("\n");
|
||||||
delay(2000);
|
/* XXX */
|
||||||
|
/* changing the voltage reference of the ADC
|
||||||
|
* greatly increase the prcision on the limited
|
||||||
|
* range of our temperatures.
|
||||||
|
*/
|
||||||
|
analogReference(INTERNAL1V1); // Pour Arduino Mega2560
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
void updatevalues(void)
|
void updatevalues(void)
|
||||||
@ -21,7 +28,7 @@ void updatevalues(void)
|
|||||||
int foo;
|
int foo;
|
||||||
for (foo=0; foo<NBVAL; foo++) {
|
for (foo=0; foo<NBVAL; foo++) {
|
||||||
values[foo] = analogRead(A0);
|
values[foo] = analogRead(A0);
|
||||||
delay(500);
|
delay(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------- */
|
/* -------------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user