Skip to content

Commit

Permalink
Alteracao Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomokshin committed Mar 8, 2012
1 parent c84d50d commit 0b5880b
Showing 1 changed file with 6 additions and 65 deletions.
71 changes: 6 additions & 65 deletions WebServerMonitor/WebServerMonitor.pde
Expand Up @@ -10,7 +10,6 @@
desligar saida 3 IS30
*/
#define DHT11_PIN 0 // ADC0
#define BUFSIZ 100
#include <SPI.h>
#include <Ethernet.h>
Expand All @@ -32,12 +31,8 @@ boolean fimComando;

void setup(){

DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
Serial.begin(9600);
Serial.println("Ready");



for (int i=0;i<=7;i++){
pinMode(i, OUTPUT);
Expand Down Expand Up @@ -189,51 +184,12 @@ void Header(Client client){

}

void TemperaturaUmidade(Client client){
byte dht11_dat[5];
byte dht11_in;
byte i;// start condition
// 1. pull-down i/o pin from 18ms
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);
DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);

dht11_in = PINC & _BV(DHT11_PIN);
if(dht11_in)
{
client.println("dht11 start condition 1 not met");
return;
}
delayMicroseconds(80);
dht11_in = PINC & _BV(DHT11_PIN);
if(!dht11_in)
{
client.println("dht11 start condition 2 not met");
return;
}

delayMicroseconds(80);// now ready for data reception
for (i=0; i<5; i++)
dht11_dat[i] = read_dht11_dat();
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];// check check_sum
if(dht11_dat[4]!= dht11_check_sum)
{
client.println("DHT11 checksum error");
}
client.print("<span>Umidade Relativa = ");
client.print(dht11_dat[0], DEC);
client.print(".");
client.print(dht11_dat[1], DEC);
client.print("%</span>");
void Temperatura(Client client){

client.print("<span>Temperatura = ");
client.print(dht11_dat[2], DEC);
client.print(1, DEC);
client.print(".");
client.print(dht11_dat[3], DEC);
client.print(2, DEC);
client.println("C</span>");


Expand All @@ -245,9 +201,9 @@ void Inputs(Client client){
client.println("<br/>");


TemperaturaUmidade(client);
Temperatura(client);

for (int analogChannel = 2; analogChannel <=5; analogChannel++) {
for (int analogChannel = 1; analogChannel <=5; analogChannel++) {
client.print("<span>Entrada Analogica ");
client.print(analogChannel);
client.print(" = ");
Expand Down Expand Up @@ -303,20 +259,5 @@ void Footer(Client client){
client.println("</div></div></body></html>");
}

byte read_dht11_dat()
{
byte i = 0;
byte result=0;
for(i=0; i< 8; i++)
{
while(!(PINC & _BV(DHT11_PIN))); // wait for 50us
delayMicroseconds(30);
if(PINC & _BV(DHT11_PIN))
result |=(1<<(7-i));
while((PINC & _BV(DHT11_PIN))); // wait '1' finish
}
return result;
}



0 comments on commit 0b5880b

Please sign in to comment.