0938.637.268

142ms- ENC28J60 SPI giao diện Ethernet

142ms- ENC28J60 SPI giao diện Ethernet

80,000

ĐẶT HÀNG NHANH

Giao hàng tận nơi miễn phí nội thành!
  • Mô tả
  • Đánh giá (0)

Mô tả

ENC28J60 SPI giao diện Ethernet

1. Chip ENC28J60-I / SO trên bo mạch

2, Xung nhịp 25MHZ

3, giao diện mạng HR911105A

4, Nguồn 4, 3,3V

5, kích thước bảng 56 (mm) x 34 (mm)

Một ứng dụng giám sát nhiệt độ độ ẩm qua Ethernet trên instructables

 

Code:

<p>//Experiment of ENC28J60 Temperature Web Server<br>//With 3.5 Inch LCD (320x480), ILI9488 SPI Interface driver
//And experiment of DHT22 digital temperature / humidity sensor
//Adafruit ILI9341 library is modified for ILI9488 (320x480)
//Demonstrates the use ENC28J60 Ethernet controller</p><p>// DHT22 Data line connected to Arduino digital IO 2</p><p>// ENC28J60 MOSI to Arduino digital IO D11
// ENC28J60 SCLK to Arduino digital IO D13
// ENC28J60 CS to Arduino digital IO D8
// ENC28J60 MISO to Arduino digital IO D12</p><p>// LCD MOSI to Arduino digital IO D11
// LCD SCLK to Arduino digital IO D13
// LCD CS to Arduino digital IO D10
// LCD RS / DS to Arduino digital IO D9</p><p>// Name:- M.Pugazhendi
// Date:-  08thSep2016
// Version:- V0.1
// e-mail:- muthuswamy.pugazhendi@gmail.com</p><p>//Include Libraries
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include  <DHT.h><dht.h>
#include "Timer.h"
#include "EtherCard.h"</dht.h></p><p>//Ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x76,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,214 };</p><p>byte Ethernet::buffer[500];
BufferFiller bfill;</p><p>// For the LCD shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10</p><p>// DHT22
#define DHTPIN 2    
#define DHTTYPE DHT22</p><p>#define SERIAL_DEBUG</p><p>// Initialize LCD
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);</p><p>// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);</p><p>// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);</p><p>//Initialize / create timer
Timer t;</p><p>//Variables
//Stores humidity value
float hum;  </p><p>//Stores temperature value
float temp; 
float fa,ke,ra = 0.00;</p><p>void setup () 
{</p><p> #ifdef SERIAL_DEBUG
    Serial.begin(9600);
    Serial.println("ENC28J60 Ethernet Temperature Server Test"); 
    Serial.println("DHT22 temperature / humidity sensor Test");
 #endif
 
 //Initialize TFT LCD
 tft.begin();
 //Rotate the screen to right direction
 tft.setRotation(1);</p><p> //Print the headers
 printHeader();
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
  {
    Serial.println(F("Failed to access Ethernet controller"));
  }
  ether.staticSetup(myip);</p><p>//Initialize the DHT sensor
  dht.begin();</p><p>  t.every(5000, printTemperature);
}</p>
<p>void loop () <br>{
  t.update();
  
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  if (pos)
  {
  // check if valid tcp data is received
    ether.httpServerReply(homePage()); // send web page data
  }</p><p>   //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp= dht.readTemperature();</p><p>  //Fahrenheit
    //T(°F) = T(°C) × 9/5 + 32
    fa = ( temp * 1.8 ) + 32;
    
  //Kelvin
    //T(K) = T(°C) + 273.15          
    ke = temp + 273.15;</p><p>    //Rankine
    //T(°R) = (T(°C) + 273.15) × 9/5          
    ra = temp + 273.15;
    ra = (ra * 1.8);
}</p><p>//Print header on LCD
unsigned long printHeader() 
{
   tft.fillRect(0,0,240, 64,ILI9341_GREEN);
  tft.fillRect(0,64,240, 64,ILI9341_RED);
  tft.fillRect(0,128,240, 64,ILI9341_CYAN);
  tft.fillRect(0,192,240, 64,ILI9341_YELLOW);
  tft.fillRect(0,256,240, 64,ILI9341_ORANGE);</p><p>  unsigned long start = micros();
  tft.setTextColor(ILI9341_BLACK);   
  tft.setTextSize(3);
  //
  tft.setCursor(50,0+20);
  tft.print("CELCIUS");</p><p>  //
  tft.setCursor(50,64+20);
  tft.print("FAHRENHEIT");
  //
  tft.setCursor(50,128+20);
  tft.print("KELVIN");</p><p>    //
  tft.setCursor(50,192+20);
  tft.print("RANKIN");</p><p>   //
  tft.setCursor(50,256+20);
  tft.print("HUMIDITY");
  
  return micros() - start;
}</p><p>//Print Temperature / humidity value
void printTemperature() 
{
  tft.fillRect(241,0,240, 64,ILI9341_CYAN);
  tft.fillRect(241,64,240, 64,ILI9341_YELLOW);
  tft.fillRect(241,128,240, 64,ILI9341_ORANGE);
  tft.fillRect(241,192,240, 64,ILI9341_GREEN);
  tft.fillRect(241,256,240, 64,ILI9341_RED);
    
  //tft.fillScreen(ILI9341_BLUE);
   tft.setTextColor(ILI9341_BLACK);   
  tft.setTextSize(4);</p><p>  #ifdef SERIAL_DEBUG
    Serial.print("Celsius = ");
    Serial.print(temp);
    //Print degree symbol
    Serial.write(176); 
    Serial.println("C");
  #endif
        
  tft.setCursor(250,0+20);
  tft.print(temp);
  tft.print(" ");
  tft.print((char)247);
  tft.println("C");</p><p>    //Fahrenheit
    //T(°F) = T(°C) × 9/5 + 32
   // converted = ( temp * 1.8 ) + 32;
  #ifdef SERIAL_DEBUG
    Serial.print("Fahrenheit = ");
    Serial.print(fa);
    //Print degree symbol
    Serial.write(176); 
    Serial.println("F");
  #endif
      
    tft.setCursor(250,64+20);
    tft.print(fa);
    tft.print(" ");
    tft.print((char)247);
    tft.println("F");</p><p>//Kelvin
    //T(K) = T(°C) + 273.15          
    //converted = temp + 273.15;
 #ifdef SERIAL_DEBUG    
    Serial.print("Kelvin = ");
    Serial.print(ke);
    Serial.println(" K");
 #endif
  tft.setCursor(250,128+20);
  tft.print(ke);
  tft.print(" ");
  tft.println("K");</p><p>   //Rankine
    //T(°R) = (T(°C) + 273.15) × 9/5          
    //converted = temp + 273.15;
    //converted = (converted * 1.8);
  #ifdef SERIAL_DEBUG
    Serial.print("Rankin = ");
    Serial.print(ra);
    //Print degree symbol
    Serial.write(176);    
    Serial.println("R");
  #endif
  tft.setCursor(250,192+20);
  tft.print(ra);
  tft.print(" ");
  tft.print((char)247);
  tft.println("R");</p><p> //Humidity
 #ifdef SERIAL_DEBUG
    Serial.print("Humidity =");
    Serial.println(hum);
 #endif
    
  tft.setCursor(250,256+20);
  tft.print(hum);
  tft.print(" ");
  tft.println("%");
}

static word homePage()
{ long t = millis() / 1000; word h = t / 3600; byte m = (t / 60) % 60; byte s = t % 60; bfill = ether.tcpOffset(); bfill.emit_p(PSTR(

“HTTP/1.0 200 OK\r\n” “Content-Type: text/html\r\n” “Pragma: no-cache\r\n” “\r\n” “<meta http-equiv=’refresh’ content=’1’/>”

“<title>DHT22 server</tile>”

“<h1> DHT22 Temperature / Humidity Server<br> </h1>”

“<h1><font color=blue> $D$D:$D$D:$D$D<br></h1>”

“<h1><font color=red>Celsius:$T°C<br>Fahrenheit:$T°C<br>Kelvin:$T<br>Rankine:$T°C<br></h1>”

“<h1><font color=green>Humidity:$T%<br></h1>”,

h/10, h%10, m/10, m%10, s/10, s%10,temp,fa,ke,ra,hum);

return bfill.position();

}

 

Đánh giá

Chưa có đánh giá nào.


Hãy là người đầu tiên nhận xét “142ms- ENC28J60 SPI giao diện Ethernet”