premiere mesure de temperature avec le LM35

This commit is contained in:
tth 2019-01-12 16:26:15 +01:00
parent efdf127033
commit 7332f87654
6 changed files with 90 additions and 8 deletions

View File

@ -5,9 +5,9 @@ DATAFILE="foo.dat"
TMPFILE="/tmp/dd2data"
IMAGE="graphe.png"
NB_READ=12000
NB_READ=50
./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
gnuplot << __EOC__
set term png size 1600,512

View File

@ -33,7 +33,7 @@ for (count=0; count<iters; count++) {
fprintf(stderr, "getline #%d -> %d\n", count, foo);
fprintf(stderr, "%s\n", ligne);
}
foo = parse4values(ligne, 'X', datas);
foo = parse4values(ligne, 'T', datas);
//
if (foo >= 0) {
temps = time(NULL);

View File

@ -0,0 +1,47 @@
/*
* lecture des capteurs de temperature LM35
*/
/* -------------------------------------------------- */
#define NBVAL 4
#define DELAI 5000
int values[NBVAL];
/* -------------------------------------------------- */
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
delay(2000);
}
/* -------------------------------------------------- */
void updatevalues(void)
{
int foo;
for (foo=0; foo<NBVAL; foo++) {
values[foo] = analogRead(A0);
delay(50);
}
}
/* -------------------------------------------------- */
void sendvalues(void)
{
int foo;
Serial.print("T");
for (foo=0; foo<NBVAL; foo++) {
Serial.print(" ");
Serial.print(values[foo]);
}
Serial.print("\n");
}
/* -------------------------------------------------- */
void loop() {
updatevalues();
sendvalues();
delay(DELAI);
}
/* -------------------------------------------------- */

View File

@ -15,6 +15,41 @@
int verbosity;
/* ---------------------------------------------------------------- */
int afficheur_7segs(WINDOW * win, int lig, int col, int bits, int k)
{
int numbit, mask;
for (numbit=0; numbit<8; numbit++) {
mask = 1 << numbit;
switch(mask) {
case 0x01:
case 0x02:
case 0x04:
case 0x08:
case 0x10:
case 0x20:
case 0x40:
case 0x80:
/* decimal point */
break;
default:
fprintf(stderr, "%s mask is wrong\n", __func__);
break;
}
}
return -1;
}
/* ---------------------------------------------------------------- */

View File

@ -33,7 +33,7 @@ char buffer[200];
tp = " DD2 MONITORING by tTh 2019 ";
if (NULL != title) tp = title;
barre_inverse('+', 0);
barre_inverse(' ', 0);
standout();
mvaddstr(0, 2, tp);
#if TRACE

View File

@ -22,16 +22,16 @@ water = open_waterfall("premier essai", 0);
for (loop=0; loop<nbl; loop++) {
sprintf(line, "%04X %04X", loop, rand()&0xffff);
sprintf(line, "%06X %04X", loop, rand()&0xffff);
mvwaddstr(stdscr, LINES-1, 1, line);
wrefresh(stdscr);
for (foo=0; foo<4; foo++) {
if (rand()%100<42) {
rvals[foo] += 3.8*(foo + 1);
rvals[foo] += 3.9 * (foo + 1);
}
if (rvals[foo] > 1023.0) {
rvals[foo] = (float)(rand() % 15);
rvals[foo] = (float)(rand() % 25);
}
}
@ -77,7 +77,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
fond_ecran(" Demonstrator ");
demo(90000, 0);
demo(190000, 0);
/*
* plop, on a fini, restaurer la console