thingspeak with enc28j60 & arduino | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
thingspeak with enc28j60 & arduino
No permission to create posts
May 17, 2015
11:24 pm
Avatar
hanguyen
New Member
Members
Forum Posts: 4
Member Since:
January 7, 2015
sp_UserOfflineSmall Offline

below is the code which i run sucessful to upload Analogread A0 successful. Cool
/*
| Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the
| ENC28J60 chip.
| Based on the Ethercard example from http://www.jeelabs.org
| Phil Grant Jan 2014
*/
#include
// change these settings to match your own setup
#define APIKEY "xxxxxxxxxxxx" // write API key

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

char website[] PROGMEM = "api.thingspeak.com";

byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;

void setup () {
Serial.begin(57600);
Serial.println("
[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() + 16000; //Transmit every minute
// sensors.requestTemperatures();
delay(200);
// generate two fake values as payload - by using a separate stash,
// we can determine the size of the generated message ahead of time
byte sd = stash.create();
stash.print("field1=");
stash.println(String(analogRead (A0),DEC));

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 /update HTTP/1.1" "
"
"Host: $F" "
"
"Connection: close" "
"
"X-THINGSPEAKAPIKEY: $F" "
"
"Content-Type: application/x-www-form-urlencoded" "
"
"Content-Length: $D" "
"
"
"
"$H"),
website, PSTR(APIKEY), stash.size(), sd);

// send the packet - this also releases all stash buffers once done
ether.tcpSend();
}
}

June 2, 2016
3:09 pm
Avatar
angeloventura
New Member
Members
Forum Posts: 1
Member Since:
April 1, 2016
sp_UserOfflineSmall Offline

Great Job!!!
Which library works??? Do you have a link???

Thank u

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: Hans, agrisensezm
38 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Archieter, JamesExedo, IrbosHich, brodi, kasko, franklin castro

Administrators: Hans: 387, lee: 457