葱头同学 发表于 2013-4-13 14:43:27

enc28j60 和 nrf24l01+ 同时使用如何实现?

参考了前辈们的文章:
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=2520
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=1228
想做个室外温度采集,采集端用的是一块arduino mini,温度感应模块采集温度数据然后用nrf24l01传送给接收端,接收端是arduino uno,nrf24l01接到数据后由enc28j60网络模块上传到yeelink,自己试着整合了一下代码,但是通不过编译,跪求大神指点啊!!! (编译环境1.01)

#include "SPI.h"
#include "Mirf.h"
#include "nRF24L01.h"
#include "MirfHardwareSpiDriver.h"
#include <EtherCard.h>
#define OUT
#define REQUEST_RATE 10000 // milliseconds
#define SENSOR1 4
#define SENSOR2 5
#define SENSOR3 6
#define LANcsPin 8
#define RFcsPin 10
int data;
int aaa;
int aaaa;
// ethernet interface mac address
static byte mymac[] = {
0x74,0x69,0x69,0x2D,0x30,0x31 };

// remote website name
char website[] PROGMEM = "api.yeelink.net";
char urlBuf[] PROGMEM = "/v1.0/device/2464/sensor/3315/datapoints";
char apiKey[] PROGMEM = "U-ApiKey: -------------------------------------------";

byte Ethernet::buffer;
static long timer;

// called when the client request is complete
static void my_result_cb (byte status, word off, word len) {
Serial.print("<<< reply ");
Serial.print(millis() - timer);
Serial.println(" ms");
Serial.println((const char*) Ethernet::buffer+off);
}

void setup () {
SPI.begin();
pinMode(LANcsPin,OUTPUT);
pinMode(RFcsPin,OUTPUT);
Serial.begin(9600);
Serial.println("");
digitalWrite(RFcsPin,HIGH);
digitalWrite(LANcsPin,LOW);
randomSeed(analogRead(0));
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");

if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

ether.printIp("My IP: ", ether.myip);
// ether.printIp("Netmask: ", ether.mymask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);

if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
ether.printIp("Server: ", ether.hisip);

timer = - REQUEST_RATE; // start timing out right away
digitalWrite(LANcsPin,HIGH);
digitalWrite(RFcsPin,LOW);
Mirf.spi = &MirfHardwareSpi;   //加载24L01SPI
Mirf.init();
Mirf.setRADDR((byte *)"serv1");//接收到"接收地址"
Mirf.payload = sizeof(int);   //接收类型(整数)
Mirf.config();
}
void loop () {
if(Mirf.dataReady()){
   Mirf.getData((byte *)&data); //接收数据
   aaa = data;
   Mirf.rxFifoEmpty();
}
delay(10);
digitalWrite(RFcsPin,HIGH);
digitalWrite(LANcsPin,LOW);
   ether.packetLoop(ether.packetReceive());
if ((millis() > timer + REQUEST_RATE) && !aaa == aaaa) {
    aaaa = aaa;
    timer = millis();
    Serial.println(">>> REQ");
    static char buf;
    get_send_string(buf);
    if (!ether.dnsLookup(website))
      Serial.println("DNS failed");
    ether.printIp("Server: ", ether.hisip);
    ether.httpPost (urlBuf, website, apiKey, buf, my_result_cb);
}
}
void get_send_string(OUT char *p){
if (!aaaa == 1111){
uint16_t whole = 50;
sprintf(p,"{\"value\":%d}",whole);}
else{
   uint16_t whole = 0;
sprintf(p,"{\"value\":%d}",whole);}
   
}

北斗 发表于 2013-4-28 20:36:54

我不是大神。。。不过你没说你编译没过时错误代码是什么啊
页: [1]
查看完整版本: enc28j60 和 nrf24l01+ 同时使用如何实现?