ethercard php_使用Arduino和ENC28J60以太网LAN网络模块发送HTTP POST请求
首先,您需要安装以下库:
https://github.com/jcw/ethercard
用6个引脚将模块连接到arduino:
> ENC SO – > Arduino引脚12
> ENC SI – > Arduino引脚11
> ENC SCK – > Arduino引脚13
> ENC CS – > Arduino引脚8
> ENC VCC – > Arduino 3V3引脚
> ENC GND – > Arduino Gnd pin
然后使用以下代码:
#include
// your variable
#define PATH "example.php"
#define VARIABLE "test"
// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
char website[] PROGMEM = "www.mydomain.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
void setup () {
Serial.begin(57600);
Serial.println("\n[webClient]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 10000;
byte sd = stash.create();
stash.print("variable=");
stash.print(VARIABLE);
stash.print("&action=Submit");
stash.save();
// generate the header with payload - note that the stash size is used,
// and that a "stash descriptor" is passed in as argument using "$H"
Stash::prepare(PSTR("POST http://$F/$F.csv HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Content-Length: $D" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\r\n"
"\r\n"
"$H"),
website, PSTR(PATH), website, stash.size(), sd);
// send the packet - this also releases all stash buffers once done
ether.tcpSend();
}
}
ethercard php_使用Arduino和ENC28J60以太网LAN网络模块发送HTTP POST请求相关推荐
- PIC以太网开发板——基于微芯最新ENC28J60以太网控制器
PIC以太网开发板--基于微芯最新ENC28J60以太网控制器 PIC以太网开发板--基于微芯最新ENC28J60以太网控制器 导航栏 ENC28J60芯片 ...
- ethercard php_关于EtherCard的webClient代码分析
以下代码摘自EtherCard的webClient实例,主要功能是打开指定网址, Serial.print((const char*) Ethernet::buffer + off);这一行显示服务器 ...
- ENC28j60以太网芯片驱动程序简介
转载: 本介绍可分为三块内容: 1.以太网数据帧结构 符合IEEE802.3标准的以太网帧的长度是介于64-1516字节之间.主要由目标MAC地址.源MAC地址.类型/长度字段.数据有效负载.可选填充 ...
- STM32(三) ENC28J60以太网(一)
2.1 寄存器定义 首先分析一下ENC28J60.h这个头文件.阅读数据手册之后,会发现ENC28J60寄存器数量较多,通过分析和整理,操作ENC28J60的寄存器需要注意以下3点. [1]共有三种不 ...
- php enc28j60,uip0.9+ENC28J60 缓存的读写发送
当接收到TCP数据,执行如下的代码,将受到的TCP数据发回去. void example0_app(void) { u16_t i;// if(uip_connected()){ printu(&qu ...
- python多维数据post给php_使用Python中的POST将数据发送到PHP
看看这个python: import urllib2, urllib mydata=[('one','1'),('two','2')] #The first is the var name the s ...
- Linux 下值得一试的实用工具
第三方工具介绍 wpa_supplicant : wifi客户端(client)加密认证工具,和iwconfig不同,wpa_supplicant支持wep.wpa.wpa2等完整的加密认证,而iwc ...
- 网络安全自学笔记05 - 网络协议基础与攻击
一.ARP协议 1.ARP协议概念 1.什么是ARP address resollution protocol,地址解析协议. 将一个已知的IP地址解析成MAC地址 ARP协议通过IP地址向MAC地址 ...
- 如何使用Arduino Web服务器连接ENC28J60以太网模块
在本篇文章中,我们将学习如何将ENC28J60以太网模块与Arduino Web服务器进行连接,以在LAN局域网或无线网络中的计算机与Arduino之间建立通信.我们将ENC28J60以太网控制器与A ...
最新文章
- 4 次版本迭代,我们将项目性能提升了 360 倍!
- linux 定时器和sleep,linux中sleep函数的使用和总结
- kubernetes 中 label的作用_Kubernetes生产环境的16条建议
- mysql gui 修改密码_MySQL修改root密码的各种方法整理
- 高通发布一系列新型WiFi芯片:兼容WiFi 6技术
- MySoft.Data新版v2.7.3 beta发布,修正较多bug,新增功能尚未完全测试
- 【瑕疵检测】基于matlab GUI OTSU织物疵点检测【含Matlab源码 860期】
- 【sql的四大连接】
- python 全栈开发,Day113(方法和函数的区别,yield,反射)
- 《AutoCAD .NET开发指南2012版》翻译整理已完成,欢迎大家下载!
- Cesium 修改鼠标操作习惯
- 【2020年第七次人口普查】省市县三级人口婚姻状况和妇女生育状况
- pubg服务器维护公告7月31日,2021绝地求生3月31日更新公告_3.31更新维护内容一览_3DM网游...
- java导出Excel增加下拉框选项,解决小数据量和大数据量下拉框选项的问题
- arm-linux-gnueabihf-gcc 安装 OpenBLAS
- 数据库原理和应用(4)—— 三个世界及有关概念、数据模型
- 大中华区总裁孙振耀退休感言
- linux查看nfs挂载信息,Linux NFS挂载
- 字符串核对之Boyer-Moore算法
- 关于Stram流(1)——循环遍历
热门文章
- springboot整合dubbo_springboot整合dubbo设置全局唯一ID进行日志追踪
- 基于Mixin Network的PHP比特币开发教程 之一:创建机器人
- mybatis-mapper
- MySQL count(*)空表为何会很慢
- 便利的开发工具 CppUnit 快速使用指南
- JS的IE和Firefox兼容性汇编(原作:hotman_x)- -
- 极客新闻——15、软件测试自动化的最新趋势
- 架构与思维:系统容量设计
- 快手二面:Java 里的 for (;;) 与 while (true),哪个更快?
- 记一次线上商城系统 Tomcat、JVM 高并发的优化