Mudanças entre as edições de "O termômetro mais complicado do mundo"
| (8 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
| − | Depois de meses passando frio na Nuvem, já era hora de entender se a sensação térmica era real, imaginária ou provocada pela umidade. Juntando algumas do jardim para epicuro (da cinthia) e | + | Depois de meses passando frio na Nuvem, já era hora de entender se a sensação térmica era real, imaginária ou provocada pela umidade. Juntando algumas peças do jardim para epicuro (da cinthia) e da minha fonte para pescar satélites, fiz o termômetro que provavelmente é o mais desnecessariamente complicado. Ficou bonito. |
[[Arquivo:termometro.jpg]] | [[Arquivo:termometro.jpg]] | ||
| + | |||
| + | Aqui vai o esquema de funcionamento do circuito. Um 7805 regula a voltagem do transformador em 5v, o que alimenta o arduino, sensor e tela oled. O regulador de voltagem do arduino também dá 5v mas a corrente que ele fornece era insuficiente para a tela. | ||
| + | |||
| + | [[Arquivo:Circuito-termometro.jpg]] | ||
| + | |||
| + | O sensor de temperatura LM35 dá a temperatura em Celsius, mas o arduino precisa de uma voltagem de referência para a entrada analógica. Por isso conectamos duas saídas do sensor. O arduino faz as contas e envia o número usando o protocolo serial do display oled. | ||
| + | |||
| + | Aqui vão as datasheets dos componentes: | ||
| + | |||
| + | |||
| + | * LM35 - [[Arquivo:Lm35.pdf]] | ||
| + | * Oled - protocolo serial [[Arquivo:GOLDELOX-SGC-COMMANDS-SIS-rev3.pdf ]] | ||
| + | * Oled - pinout etc [[Arquivo:UOLED-160-G1SGC-DS-rev4.pdf]] | ||
| + | |||
| + | |||
| + | O programa de arduino está abaixo: | ||
| + | |||
| + | |||
| + | |||
| + | #include<stdlib.h> | ||
| + | #define LM35pin 2 | ||
| + | #define LM35ref 1 | ||
| + | long referencia; | ||
| + | float v_alim, temp_c; | ||
| + | byte data[20]; | ||
| + | void setup() { | ||
| + | // initialize serial communications at 9600 bps: | ||
| + | Serial.begin(19200); | ||
| + | delay(1000); | ||
| + | Serial.write("U"); // send an U to the oled so it can fix the baud rate | ||
| + | delay(100); | ||
| + | } | ||
| + | void loop() { | ||
| + | delay(1000); | ||
| + | Serial.write("E"); //clear screen | ||
| + | delay(100); | ||
| + | int analogVal = 0; | ||
| + | for(int i = 0; i < 10; i++) { // read 10 times the sensor and calculates the average | ||
| + | analogVal += (analogRead(LM35pin)-analogRead(LM35ref)); | ||
| + | delay(10); | ||
| + | } | ||
| + | temp_c = (5.0 * analogVal * 10) / 1023; | ||
| + | char t[5]; | ||
| + | dtostrf(temp_c,2,1,t); //convert to string | ||
| + | printSgc(t, 10,50,0,255,255,5,5); //send the string to the display | ||
| + | //Serial.println(temp_c); | ||
| + | } | ||
| + | boolean printSgc(char * text, int x, int y, int font, int color_1, int color_2, int w, int h) { | ||
| + | Serial.write("S"); | ||
| + | Serial.write(x); | ||
| + | Serial.write(y); | ||
| + | Serial.write(font); | ||
| + | Serial.write(color_1); | ||
| + | Serial.write(color_2); | ||
| + | Serial.write(w); | ||
| + | Serial.write(h); | ||
| + | for (int i = 0; i< strlen(text); i++){ | ||
| + | Serial.write(text[i]); | ||
| + | } | ||
| + | Serial.write(0,1); | ||
| + | delay(10); | ||
| + | int result = Serial.read(); | ||
| + | if (result==6) | ||
| + | return true; | ||
| + | else | ||
| + | return false; | ||
| + | } | ||
| + | } | ||
Edição atual tal como às 11h24min de 14 de fevereiro de 2012
Depois de meses passando frio na Nuvem, já era hora de entender se a sensação térmica era real, imaginária ou provocada pela umidade. Juntando algumas peças do jardim para epicuro (da cinthia) e da minha fonte para pescar satélites, fiz o termômetro que provavelmente é o mais desnecessariamente complicado. Ficou bonito.
Aqui vai o esquema de funcionamento do circuito. Um 7805 regula a voltagem do transformador em 5v, o que alimenta o arduino, sensor e tela oled. O regulador de voltagem do arduino também dá 5v mas a corrente que ele fornece era insuficiente para a tela.
O sensor de temperatura LM35 dá a temperatura em Celsius, mas o arduino precisa de uma voltagem de referência para a entrada analógica. Por isso conectamos duas saídas do sensor. O arduino faz as contas e envia o número usando o protocolo serial do display oled.
Aqui vão as datasheets dos componentes:
- LM35 - Arquivo:Lm35.pdf
- Oled - protocolo serial Arquivo:GOLDELOX-SGC-COMMANDS-SIS-rev3.pdf
- Oled - pinout etc Arquivo:UOLED-160-G1SGC-DS-rev4.pdf
O programa de arduino está abaixo:
#include<stdlib.h>
#define LM35pin 2
#define LM35ref 1
long referencia;
float v_alim, temp_c;
byte data[20];
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(19200);
delay(1000);
Serial.write("U"); // send an U to the oled so it can fix the baud rate
delay(100);
}
void loop() {
delay(1000);
Serial.write("E"); //clear screen
delay(100);
int analogVal = 0;
for(int i = 0; i < 10; i++) { // read 10 times the sensor and calculates the average
analogVal += (analogRead(LM35pin)-analogRead(LM35ref));
delay(10);
}
temp_c = (5.0 * analogVal * 10) / 1023;
char t[5];
dtostrf(temp_c,2,1,t); //convert to string
printSgc(t, 10,50,0,255,255,5,5); //send the string to the display
//Serial.println(temp_c);
}
boolean printSgc(char * text, int x, int y, int font, int color_1, int color_2, int w, int h) {
Serial.write("S");
Serial.write(x);
Serial.write(y);
Serial.write(font);
Serial.write(color_1);
Serial.write(color_2);
Serial.write(w);
Serial.write(h);
for (int i = 0; i< strlen(text); i++){
Serial.write(text[i]);
}
Serial.write(0,1);
delay(10);
int result = Serial.read();
if (result==6)
return true;
else
return false;
}
}

