Thingspeak connection

Good day,
Can ask anyone who know how to update my channel every minute instead of min. 5 minutes interval?
my channel link is here
thingspeak.com/channels/139786
sometimes im having problem with updating it just stops after 2-3 days.

thank you so much for any input

#include <EtherCard.h>

//#include <Wire.h>
//#include <Adafruit_BMP085.h>

// change these settings to match your own setup
//#define FEED "000"
#define APIKEY "" // put your key here
#define ethCSpin 10 // put your CS/SS pin here.
 
// 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

//Adafruit_BMP085 bmp;

#include <DHT.h>
#define DHTPIN 7    // what pin we're connected DHT11/22
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22

DHT dht(DHTPIN, DHTTYPE);
//float te;
//int has;

float hit; // heat index, see http://www.eaglewings.ro/indicele-de-confort-termic/
// also see https://en.wikipedia.org/wiki/Heat_index

void setup () {
  Serial.begin(9600);
  Serial.println("\n[ThingSpeak example]");

  //Initialize Ethernet
  initialize_ethernet();

  /*
   if (!bmp.begin()) {
  Serial.println("Could not find a valid BMP085 sensor, check wiring!");
  while (1) {}
  }
*/

 dht.begin();  // DHT init 
  
}


void loop () { 
  //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) {
 /*  
  float temp = bmp.readTemperature();
  //t = t*100; // multiplicam cu 100 sa vedem si virgulele
  float p = bmp.readPressure();
  p = p/101.325;
  int pres = p*0.760;
*/

  float humidity = dht.readHumidity();
//float humidity = random(3000,5000);
//humidity = humidity / 100;
  
delay(500);  
  float d=dht.readTemperature();
  float e=d*0.05;
  float t=d-e;

  float temperature = t;
//float temperature = random (2000,2500);
//temperature = temperature / 100;

delay(500);

hit = (temperature*1.8+32) - (0.55-0.0055*humidity)*((temperature*1.8+32)-58);
//$itu = ($t * 1.8 + 32) – (0.55 – 0.0055 * $u) * (($t * 1.8 + 32) – 58);
// http://www.eaglewings.ro/indicele-de-confort-termic/

    // generate two fake values as payload - by using a separate stash,
    // we can determine the size of the generated message ahead of time
    // field1=(Field 1 Data)&field2=(Field 2 Data)&field3=(Field 3 Data)&field4=(Field 4 Data)&field5=(Field 5 Data)&field6=(Field 6 Data)&field7=(Field 7 Data)&field8=(Field 8 Data)&lat=(Latitude in Decimal Degrees)&long=(Longitude in Decimal Degrees)&elevation=(Elevation in meters)&status=(140 Character Message)
    byte sd = stash.create();
    stash.print("field1=");
 //   stash.print(temp);
   stash.print(temperature);
    stash.print("&field2=");
//    stash.print(pres);
   stash.print(humidity);
    //stash.print("&field3=");
    //stash.print(msje);
   stash.print("&field3=");
   stash.print(hit);

    stash.save();

    //Display data to be sent
    Serial.print(temperature); 
    Serial.println(" gr.C");
    Serial.print(humidity);
    Serial.println(" %RH");
    Serial.print("heat index = ");
    Serial.print(hit);
 if (hit <= 65) Serial.println(" ---> OK !");
 if ((hit > 65) and (hit < 79 )) Serial.println(" ---> CAUTION !");
 if (hit >= 80) Serial.println(" ---> DANGER !");
    Serial.println("-----------");

    
    // 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); } 

  }  // aici se termina bucla de transmisie

   const char* reply = ether.tcpReply(session);
     Serial.println("reset");
   void(* resetFunc) (void) = 0; //declare reset function @ address 0
   
   if (reply != 0) {
     res = 0;
     Serial.println(F(" >>>REPLY recieved...."));
     Serial.println(reply);
   }
   delay(1500);
//   delay(150);

}  // end main loop

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;
  }
}

Your code has roughly 2.5s delay() built in with 3 delay() calls at different places - plus time to execute when sending and 1.5s delay when looping without sending - the delay() at the end

When you loop, you increase the res variable by 1 and you execute the code only each time res is 200

if (res == 200) {

So every 300 (200 * 1.5 sec) seconds give or take which is 5 minutes you send something

If you change the 200 to something lower or change the delays at the very end of the code then you will send more often

who modified the delays BTW?? They are not what they used to be as There is a comment stating each res is 50ms while yours is 1.5sec+ so someone modified something there

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

Note also that the code waits for the reply from the server and if not times out after res is > 220, and reset the Ethernet connection - not sure that's done well...

that's what you do at the beginning of the loop with

void loop () { 
  //if correct answer is not received then re-initialize ethernet module
  if (res > 220){
    initialize_ethernet(); 
  }

Note that initialize_ethernet reset res to 180,

    //reset init value
    res = 180;

so you should send a new POST " soon" - in your case after (200-180)*1.5 seconds

I've no clue what this in for doing at every loop

Serial.println("reset");
   void(* resetFunc) (void) = 0; //declare reset function @ address 0

Seems very weird...and not a proper way to reset your arduino. Watchdog seems better option...

Seems very weird...and not a proper way to reset your arduino. Watchdog seems better option...

i just tried to add a few things and see how the loop works and ended up resetting each time so i removed it anyway....

void loop () {
  //if correct answer is not received then re-initialize ethernet module
  if (res > 220){
    initialize_ethernet();
  }

this call initialize_ethernet is calling....

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);

am i right? now i understand a little bit how the loop works. i just copied the whole code from another forum dated 2014, since it is the only code i could find that works.

what do you think of this initialize_ethernet_void? is this a power on 5v output command to enc28j60? thank you so much for your time, really appreciate it

So the code you commented out

    //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);

was probably that the original writer of this code had pin 5 of his arduino connected to the reset hardware pin of the ethernet shield and he was bringing it LOW and then HIGH which was performing a physical hardware reset on the module.

Not sure how safe Calling multiple times ether.begin(sizeof Ethernet::buffer, mymac, ethCSpin) is if you have not done a hard reset of the module.