arduino多点网络温度采集专项项目

上传人:pu****.1 文档编号:486699345 上传时间:2022-08-29 格式:DOCX 页数:37 大小:656.11KB
返回 下载 相关 举报
arduino多点网络温度采集专项项目_第1页
第1页 / 共37页
arduino多点网络温度采集专项项目_第2页
第2页 / 共37页
arduino多点网络温度采集专项项目_第3页
第3页 / 共37页
arduino多点网络温度采集专项项目_第4页
第4页 / 共37页
arduino多点网络温度采集专项项目_第5页
第5页 / 共37页
点击查看更多>>
资源描述

《arduino多点网络温度采集专项项目》由会员分享,可在线阅读,更多相关《arduino多点网络温度采集专项项目(37页珍藏版)》请在金锄头文库上搜索。

1、Ethernet Shield on Arduino - a webserver exampleProject note Arduino Ethernet Shield V1.0 1. SchematicThe Arduino Ethernet Shield V1.0 is dedicated for the Arduino boards. It uses the Microchips ENC28J60 SPI based stand-alone Ethernet controller (download datasheet here) and a compatible RJ45 socket

2、 with magnetics. Since the ENC28J60 is a 3V3 device that only drive 3V3 logic level output but capable of accepting 5V logic input, a 5V CMOS/TTL quad positive AND gates 74HCT08D is used to convert the 3.3 logic level output to 5V logic level.Fig 1. Arduino Ethernet Shield schematic 2. Software Stru

3、ctureThe Ethernet Shield software is in the format of Arduino library, which you can download from here. The library is implemented based on tuxgraphics.orgs open-source TCP/IP stack for Atmega88 and ENC28J60. The main files in the library are etherShield.cpp a wrapper cpp file, as an Arduino librar

4、y interface with tuxgraphics code ip_arp_udp_tcp.c simplified TCP/IP stack implementation enc28j60.c ENC28J60 SPI routines net.h network protocol definitions 3. TCP/IP implementationThe standard TCP is a protocl to establish a connection. To do this, a number of packets needs to be exchaged between

5、two sides first to establish the connection; then data packets can be exchaged. Usually a complicated state-machine is needed to implement the TCP protocol. For Auduinos ATMEGA168, a 8-bit AVR microcontroller with 1K SRAM, it is impossible to implement the full TCP stack. Also the webpage for 8-bit

6、microcontroller that normally is used to control a relay or read a temperature sensor etc., is very simple. Therefore, instead of implementing full TCP protocl, a single data packet TCP protocol is used. You webpage contents, including all html tags, must be in one packet. The length of packet is li

7、mited by the SRAM size, currently half of the RAM space (500 bytes) is used for network Packet buffer. It is sufficient for simple webpages as shown below.4. Ethersheild library installation & modificationFirst download the ethershield library here, then copy & unzip the library in your Arduino IDE

8、library directory (for example arduino-0010/hardware/libraries/). There are three examples in the ethershield library, you might need to change the ip address in the example sketch (.pde) files. The ip address must be a free address with your network rangestatic uint8_t mymac6 = 0x54,0x55,0x58,0x10,

9、0x00,0x24; static uint8_t myip4 = 192,168,1,15; static char baseurl=; Also you might like to change the webpage contents in the print_webpage funtion. Note that the webpage contents are stored in the PROGMEM (using PSTR declaration) to save the precious SRAM space. 5. ExamplesThree examples are incl

10、uded in the ethershield library ethershield_ping.pde a PING example ethershield_webserver.pde a general webserver example ethershield_web_temperature.pde a webserver with temperature sensor (DS18B20) readings ethershield_web_switch.pde New Webserver example, switch on/off LED#include etherShield.h/

11、please modify the following two lines. mac and ip have to be unique/ in your local area network. You can not have the same numbers in/ two devices:static uint8_t mymac6 = 0x54,0x55,0x58,0x10,0x00,0x24; static uint8_t myip4 = 192,168,1,15;static char baseurl=;static uint16_t mywwwport =80; / listen p

12、ort for tcp/www (max range 1-254)#define BUFFER_SIZE 500 static uint8_t bufBUFFER_SIZE+1; #define STR_BUFFER_SIZE 22static char strbufSTR_BUFFER_SIZE+1;/定义了两个数组一种是uint8_t buf(501),一种是strbuf(23)EtherShield es=EtherShield();/ prepare the webpage by writing the data to the tcp send buffer/准备网页向tcp发送寄存器

13、写入数据uint16_t print_webpage(uint8_t *buf, byte on_off);int8_t analyse_cmd(char *str);/ LED cathode 连接到 the Pin4, anode to 5V through 1K 电阻#define LED_PIN 4void setup() /*初始化 enc28j60*/ es.ES_enc28j60Init(mymac); es.ES_enc28j60clkout(2); / 变换输出时钟change clkout from 6.25MHz to 12.5MHz delay(10); /* Magj

14、ack leds configuration, 参见 enc28j60 datasheet, page 11 */ LEDA=green绿灯 LEDB=yellow黄灯/ 0x880代表 PHLCON LEDB=on, LEDA=on 灯AB都亮/ enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);es.ES_enc28j60PhyWrite(PHLCON,0x880);delay(500);/ 0x990代表 PHLCON LEDB=off, LEDA=off 灯AB都灭/ enc28j60PhyWrite(PHLCON,0b0000 1001

15、1001 00 00);es.ES_enc28j60PhyWrite(PHLCON,0x990);delay(500);/ 0x880 is PHLCON LEDB=on, LEDA=on/ enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);es.ES_enc28j60PhyWrite(PHLCON,0x880);delay(500);/ 0x990 is PHLCON LEDB=off, LEDA=off/ enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);es.ES_enc28j60PhyWrite(PHLCON,0x990);delay(500);/ / 0x476 is PHLCON LEDA=links status绿灯表达已连接, LEDB=receive/transmit红灯表达正在发送或接受数据 / enc28j60PhyWrite(PHLCON,0b0000 0100

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号