Sie sind auf Seite 1von 17

#include <enc28j60.

h>
#include <EtherCard.h>
#include <net.h>

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

#define APIKEY "L1DAJ2VIE00J45YM" // put your key here


#define ethCSpin 53 // put your CS/SS pin here.
void senddata(int a ,int b,int c);
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };
const char website[] PROGMEM = "api.thingspeak.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
byte session;
//timing variable
int res = 100; // was 0

SoftwareSerial mySerial(10, 11);


SoftwareSerial mySerial1(15, 14);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int tRice1 = 1000, toil1 = 1000;
int tRice2 = 2000, toil2 = 2000;
int tRice3 = 1000, toil3 = 1000;
int name1, qty, item;
int mot1 = 8;
int alert = 21;
int mot2 = 9;
int sol1 = 7, sol2, sol3, sol4, sol9, sol10, sol11, lt;
int c = 0, i1 = 0, ko, m1, df, ltt, ltd, ppp, pp;
int passo[3][8] = {{1, 2, 3, 4, 5, 6, 7, 8}, {2, 3, 4, 5, 6, 7, 8, 9}, {0, 1, 2,
3, 4, 5, 6, 7}};
int tag[8]; int b, j1, k, x = 0;
int key2[3][8] = {{0, 3, 2, 5, 5, 9, 1, 3}, {0, 3, 1, 4, 3, 0, 3, 1}, {1, 1, 1,
0, 1, 7, 6, 5}};
int key[15], pass = 1;
int row[] = {36, 38, 40, 42}; // Defining row pins of keypad connected to Aeduin
o pins
int col[] = {44, 46, 48, 50}; //Defining column pins of keypad connected to Ardu
ino
int i, j, m; // Two counter variables to count inside for loop
int col_scan; // Variable to hold value of scanned columns

void setup()
{
pinMode(mot1, OUTPUT);
pinMode(mot2, OUTPUT);
pinMode(sol1, OUTPUT);
pinMode(alert, OUTPUT);
mySerial.begin(9600);
mySerial1.begin(9600);
Serial.begin(9600);
for (i = 0; i <= 3; i++)
{
pinMode(row[i], OUTPUT);
pinMode(col[i], INPUT);
digitalWrite(col[i], HIGH);
}
lcd.begin(16, 2);
lcd.print("show your card");
// thingspeak code
Serial.begin(9600);

}
void loop()
{
for (i = 0; i <= 3; i++)
{
digitalWrite(row[0], HIGH);
digitalWrite(row[1], HIGH);
digitalWrite(row[2], HIGH);
digitalWrite(row[3], HIGH);
digitalWrite(row[i], LOW);
for (j = 0; j <= 3; j++)
{
col_scan = digitalRead(col[j]);
if (col_scan == LOW)
{
keypress(i, j);
delay(300);
}
}
}
if (mySerial.available() > 0)
{
j1 = mySerial.read();
tag[i1] = j1;
i1++;
}
if (i1 == 8 )
{
lcd.clear();
lcd.print("enter password ");
}
if (pass == 0)
{
lcd.clear();
lcd.print("******** ......");
delay(2000);
lcd.clear();
for (int i = 0; i <= 2; i++)
{
c = 0;
m1 = i;
for (int k = 0; k <= 7; k++)
{
//Serial.println(tag[k]);
if (tag[k] - key2[i][k] == 48 && key[k] - passo[i][k] == 0)
c++;
}
//Serial.print(c);
if (c == 8)
goto l;
}
l: if (c == 8)
{ pass = 1;
c = 0;
switch (m1)
{
case 0: if (tRice1 >= 500 || toil1 >= 500)
{
lcd.print(" Noor Adiba Mam");
name1 = 1111;
lcd.setCursor(0, 1);
lcd.print("Project Guide");
delay(5000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice1 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
item = 1;
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice1 = tRice1 - 500;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice1 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
item = 1;
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice1 = tRice1 - 1000;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil1 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
item = 2;
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
qty = 500;
senddata(name1, item, qty);
delay(15000);
digitalWrite(sol1, LOW);
lcd.clear();
toil1 = toil1 - 500;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil1 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(25000);
digitalWrite(sol1, LOW);
lcd.clear();
toil1 = toil1 - 1000;
delay(3000);
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol9 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
break;
case 1: if (tRice2 >= 500 || toil2 >= 500)
{
lcd.print(" Hanu");
lcd.setCursor(0, 1);
lcd.print("Red Card");
delay(3000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice2 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
name1 = 2222;
item = 1;
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice2 = tRice2 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice2 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice2 = tRice2 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil2 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
item = 2;
qty = 500;
senddata(name1, item, qty);
delay(5000);
digitalWrite(sol1, LOW);
lcd.clear();
toil2 = toil2 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil2 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(10000);
digitalWrite(sol1, LOW);
lcd.clear();
toil2 = toil2 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol10 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
break;
case 2: if (tRice3 >= 500 || toil3 >= 500)
{
lcd.print(" Panditji");
name1 = 3333;
lcd.setCursor(0, 1);
lcd.print("yellow card");
delay(5000);
lcd.clear();
lcd.print("Enter ur Choice");
lcd.setCursor(0, 1);
lcd.print("1:Rice 2:Oil");
ltt = 1;
if (tRice3 >= 500)
{
if (sol2 == 1)
{
lt = 1;
lcd.clear();
lcd.print(" Rice");
lcd.setCursor(0, 1);
lcd.print("3:500gm 4:1000gm");
if (sol3 == 1 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("500gm");
item = 1;
qty = 500;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(5000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice3 = tRice3 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
else if (sol3 == 2 && tRice3 >= 1000 )
{
lcd.clear();
lcd.print("Rice");
lcd.setCursor(0, 1);
lcd.print("1000gm");
item = 1;
qty = 1000;
senddata(name1, item, qty);
digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
delay(10000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, HIGH);
delay(2000);
digitalWrite(mot1, LOW);
digitalWrite(mot2, LOW);
lcd.clear();
tRice3 = tRice3 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
if (toil3 >= 500)
{
if (sol2 == 2)
{
lt = 1;
lcd.clear();
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("3:500ml 4:1000ml");
if (sol3 == 1)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("500ml");
item = 2;
qty = 500;
senddata(name1, item, qty);
delay(5000);
digitalWrite(sol1, LOW);
lcd.clear();
toil3 = toil3 - 500;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
if (sol3 == 2 && toil3 >= 1000)
{
lcd.clear();
digitalWrite(sol1, HIGH);
lcd.print("Oil");
lcd.setCursor(0, 1);
lcd.print("1000ml");
item = 2;
qty = 1000;
senddata(name1, item, qty);
delay(10000);
digitalWrite(sol1, LOW);
lcd.clear();
toil3 = toil3 - 1000;
sol3 = 0; pp = 1;
}
if (pp == 1)
{
lcd.clear();
lcd.print("Continue 0:Exit");
lcd.setCursor(0, 1);
ppp = 1;
lcd.print("1:Rice 2:Oil");
if (sol11 == 1)
{
lcd.clear();
pass = 1; c = 0; ppp = 0; lt = 0; ltt = 0, pp = 0;
sol2 = 0; goto ly;
}
}
}
}
}
else
{
lcd.clear();
sol9 = 1;
lcd.print("Come next month");
delay(3000);
goto ly;
}
}
}
else
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("wrong card");
digitalWrite(alert, HIGH);
delay(3000);
digitalWrite(alert, LOW);
pass = 1;
sol9 = 1;
lcd.clear();
}
}
ly : if (sol9 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice1 < 500)
lcd.print("Monthly ItemOver");
if (toil1 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol9 = 0; i1 = 0, m = 0, ltt = 0;
sol2 = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
if (sol10 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice2 < 500)
lcd.print("Monthly ItemOver");
if (toil2 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol10 = 0; i1 = 0, m = 0, ltt = 0;
sol2 = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
if (sol11 == 1)
{
lcd.clear();
lcd.print("Thank you");
delay(3000);
i = 0;
lcd.clear();
if (tRice3 < 500)
lcd.print("Monthly ItemOver");
if (toil3 < 500)
lcd.print("Monthly Oil Over");
for (int g = 0; g <= 7; g++)
key[g] = 0, tag[k] = 0;
sol2 = 0;
sol11 = 0; i1 = 0, m = 0, ltt = 0;
delay(3000);
lcd.clear();
lcd.print("Show your card");
}
}
void keypress(int i, int j)
{
lcd.clear();
if (i == 0 && j == 0)
{
lcd.print("1");
key[m] = 1; m++;
if (ltt == 1)
{
sol2 = 1, pass = 0, pp = 0;
}
if (tRice1 < 500 && ltt == 1 && m1 == 0 )
{
sol9 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (tRice2 < 500 && ltt == 1 && m1 == 1 )
{
sol10 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (tRice3 < 50 && ltt == 1 && m1 == 2)
{
sol11 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
}
if (i == 0 && j == 1)
{
lcd.print("2");
key[m] = 2; m++;
if (ltt == 1)
{
sol2 = 2, pass = 0, pp = 0;
}
if (toil1 < 500 && ltt == 1 && m1 == 0)
{
sol9 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (toil2 < 500 && ltt == 1 && m1 == 1)
{
sol10 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
if (toil3 < 500 && ltt == 1 && m1 == 2)
{
sol11 = 1, sol2 = 0, pass = 1, ltt = 0, lt = 0;
}
}
if (i == 0 && j == 2)
{
lcd.print("3");
key[m] = 3; m++;
if (lt == 1)
{
sol3 = 1, pass = 0;
}
}
if (i == 1 && j == 0)
{
lcd.print("4");
key[m] = 4; m++;
if (lt == 1)
{
sol3 = 2, pass = 0;
}
}
if (i == 1 && j == 1)
{
lcd.print("5");
key[m] = 5; m++;
}
if (i == 1 && j == 2)
{
lcd.print("6");
key[m] = 6; m++;
}
if (i == 2 && j == 0)
{
lcd.print("7");
key[m] = 7; m++;
}
if (i == 2 && j == 1)
{
lcd.print("8");
key[m] = 8; m++;
}
if (i == 2 && j == 2)
{
lcd.print("9");
key[m] = 9; m++;
}
if (i == 3 && j == 1)
{
lcd.print("0");
key[m] = 0; m++;
if (ppp == 1)
{
sol9 = 1, pass = 0;
lt = 0;
ltt = 0;
}
}
if (i == 3 && j == 2)
{
lcd.print("#");
pass = 0;
}
void senddata(int a, int b, int c)
{
//if correct answer is not received then re-initialize ethernet module
if (res > 220) {
initialize_ethernet();
}
res = res + 1;
ether.packetLoop(ether.packetReceive());

//200 res = 10 seconds (50ms each res)


if (res == 200) {
byte sd = stash.create();
stash.print("field1=");
stash.print(a);
stash.print("&field2=");
stash.print(b);
stash.print("&field3=");
stash.print(c);
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.0" "\r\n"
"Host: $F" "\r\n"
"Connection: close" "\r\n"
"X-THINGSPEAKAPIKEY: $F" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\
r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, PSTR(APIKEY), stash.size(), sd);
// send the packet - this also releases all stash buffers once done
session = ether.tcpSend();
// added from: http://jeelabs.net/boards/7/topics/2241
int freeCount = stash.freeCount();
if (freeCount <= 3) {
Stash::initMap(56);
}
}
const char* reply = ether.tcpReply(session);
if (reply != 0) {
res = 0;
Serial.println(F(" >>>REPLY recieved...."));
Serial.println(reply);
}
}
void initialize_ethernet(void) {
for (;;) { // keep trying until you succeed
//Reinitialize ethernet module
//pinMode(5, OUTPUT); // do notknow what this is for, i ve got something
elso on pin5
//Serial.println("Reseting Ethernet...");
//digitalWrite(5, LOW);
//delay(1000);
//digitalWrite(5, HIGH);
//delay(500);
if (ether.begin(sizeof Ethernet::buffer, mymac, ethCSpin) == 0) {
Serial.println( "Failed to access Ethernet controller");
continue;
}
if (!ether.dhcpSetup()) {
Serial.println("DHCP failed");
continue;
}
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);
//reset init value
res = 180;
break;
}
void senddata(int a, int b, int c)
{
//if correct answer is not received then re-initialize ethernet module
if (res > 220) {
initialize_ethernet();
}
res = res + 1;
ether.packetLoop(ether.packetReceive());

//200 res = 10 seconds (50ms each res)


if (res == 200) {
byte sd = stash.create();
stash.print("field1=");
stash.print(a);
stash.print("&field2=");
stash.print(b);
stash.print("&field3=");
stash.print(c);
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.0" "\r\n"
"Host: $F" "\r\n"
"Connection: close" "\r\n"
"X-THINGSPEAKAPIKEY: $F" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\
r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, PSTR(APIKEY), stash.size(), sd);
// send the packet - this also releases all stash buffers once done
session = ether.tcpSend();
// added from: http://jeelabs.net/boards/7/topics/2241
int freeCount = stash.freeCount();
if (freeCount <= 3) {
Stash::initMap(56);
}
}
const char* reply = ether.tcpReply(session);
if (reply != 0) {
res = 0;
Serial.println(F(" >>>REPLY recieved...."));
Serial.println(reply);

Das könnte Ihnen auch gefallen