Projet domotique : teleinfo + 4 relais + T°C 1wire

J'ai peut-être pas donné assez d'information ? Il faut quoi en plus ?

Pas facile de débuter ....

Il faut quoi en plus ?

Mettre le code dans les balises [.code] [./code] (sans les points) :wink:

Pas facile de débuter ....

Euuuhh oué, enfin tu dois pas vraiment débuter vu ton code ::slight_smile: Perso je peux pas t'aider parce que j'y comprend pas grand chose !! Et vu la taille en plus ^^

//*****************************************************************************************
//
// Function : Serveur Web
//
//*****************************************************************************************
#define BUFFER_SIZE 600
static uint8_t buf[BUFFER_SIZE+1];
#define STR_BUFFER_SIZE 30
static char strbuf[STR_BUFFER_SIZE+1];
// prepare the webpage by writing the data to the tcp send buffer
uint16_t print_webpage(uint8_t *buf);
uint16_t print_webpage4(uint8_t *buf);
uint16_t print_webpage2(uint8_t *buf,int cmd,char Pile_num);
uint16_t print_webpage3(uint8_t *buf,int cmd,char Pile_num);
int analyse_cmd(char *str);
static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254)

EtherShield es=EtherShield();

////////////////////////////////////////////////////////////////////
// init
///////////////////////////////////////////////////////////////////
void init_ethernet(void)
{
  
  /*initialize enc28j60*/
       es.ES_enc28j60Init(mymac);
   es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
   delay(10);
        
      /* Magjack leds configuration, see enc28j60 datasheet, page 11 */
      // LEDA=greed LEDB=yellow
      //
      // 0x880 is PHLCON LEDB=on, LEDA=on
      // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
      es.ES_enc28j60PhyWrite(PHLCON,0x880);
      delay(500);
      //
      // 0x990 is PHLCON LEDB=off, LEDA=off
      // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
      es.ES_enc28j60PhyWrite(PHLCON,0x990);
      delay(500);
      //
      // 0x880 is PHLCON LEDB=on, LEDA=on
      // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00);
      es.ES_enc28j60PhyWrite(PHLCON,0x880);
      delay(500);
      //
      // 0x990 is PHLCON LEDB=off, LEDA=off
      // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00);
      es.ES_enc28j60PhyWrite(PHLCON,0x990);
      delay(500);
      //
  // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
  // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);
  es.ES_enc28j60PhyWrite(PHLCON,0x476);
      delay(100);
        
  //init the ethernet/ip layer:
  es.ES_init_ip_arp_udp_tcp(mymac,myip,80);

  
}
//////////////////////////////////////////////////////////////////////////////
// Recherche D'une clef dans un string
////////////////////////////////////////////////////////////////////////////////
uint8_t find_key_val(char *str,char *key)
{
        uint8_t found=0;
        uint8_t i=0;
        char *kp;
        kp=key;
        while(*str &&  *str!=' ' && found==0){
                if (*str == *kp){
                        kp++;
                        if (*kp == '\0'){
                                str++;
                                kp=key;
                                if (*str == '=')found=1;
                        }
                }else kp=key;
                str++;
        }
        if (found==1){
                // copy the value to a buffer and terminate it with '\0'
                while(*str &&  *str!=' ' && *str!='&' && i<STR_BUFFER_SIZE){
                        strbuf[i]=*str;
                        i++;
                        str++;
                }
                strbuf[i]='\0';
        }
        return(found);
}
/////////////////////////////////////////////////////////////////////
// Serveur HTPP, Analyse la requet, envoie la réponse
/////////////////////////////////////////////////////////////////////
void web_server()
{
  uint16_t plen, dat_p;
 static int cmd;
  plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

      /*plen will ne unequal to zero if there is a valid packet (without crc error) */
  if(plen!=0){                 
    // arp is broadcast if unknown but a host may also verify the mac address by sending it to a unicast address.
    if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
      es.ES_make_arp_answer_from_request(buf);
      return;
    }

    // check if ip packets are for us:
    if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){
      return;
    }
    
    if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
      es.ES_make_echo_reply_from_request(buf,plen);
      return;
    }
    // tcp port www start, compare only the lower byte
    if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){
      if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){
         es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does already send the syn,ack
         return;     
      }
      if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){
        es.ES_init_len_info(buf); // init some data structures
        dat_p=es.ES_get_tcp_data_pointer();
        if (dat_p==0){ // we can possibly have no data, just ack:
          if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){
            es.ES_make_tcp_ack_from_any(buf);
          }
          return;
        }
        if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){
                // head, post and other methods for possible status codes see:
            // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
            plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1>200 OK</h1>"));
            goto SENDTCP;
        }
       if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){
                plen=print_webpage4(buf);
            goto SENDTCP;
         }
        cmd=analyse_cmd((char *)&(buf[dat_p+5]));
        if (cmd==1){
             plen=print_webpage(buf);
             goto SENDTCP;
        }
        if ((cmd==0)||((cmd >9)&&(cmd <1000 ))){
             plen=print_webpage2(buf,cmd,1);
             goto SENDTCP;
        }
        if ((cmd >=1000)&&(cmd <2000 )){
             plen=print_webpage2(buf,cmd,0);
             goto SENDTCP;
        }
        if ((cmd >=2000)&&(cmd <3000 )){
             plen=print_webpage3(buf,cmd,0);
             goto SENDTCP;
        }
        plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 404 Not Found\r\nContent-Type: text/html\r\n\r\n<TITLE>Error 404</TITLE>ERROR 404 The requested URL was not found on this server."));
        //sprintf(test, "cmd= %d;", cmd);
        //plen=es.ES_fill_tcp_data(buf,plen,test);
       
SENDTCP:  es.ES_make_tcp_ack_from_any(buf); // send ack for http get
          es.ES_make_tcp_ack_with_data(buf,plen); // send data       
      }
    }
  }
}

/////////////////////////////////////////////////////////
// affichage page Valeurs courantes Compteur
// !!  Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////

uint16_t print_webpage(uint8_t *buf)
{
        uint16_t plen;
           plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
       sprintf(test, "<html><head><title>Tele %ldW</title>", papp);
        // plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<meta http-equiv=\"refresh\" content=\"15\" /></head>") );  
       plen=es.ES_fill_tcp_data(buf,plen,test);

             plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" <h3><font color=\"blue\">"));
       sprintf(test, "
   %d:%d:%d    %d/%d/%d", hour(),minute(),second(),day(),month(),year());
        plen=es.ES_fill_tcp_data(buf,plen,test);
      sprintf(test, "
Ind_HC : %ld", hchc);
       plen=es.ES_fill_tcp_data(buf,plen,test);
      sprintf(test, "
Ind_HP : %ld", hchp);
       plen=es.ES_fill_tcp_data(buf,plen,test);
sprintf(test, "
P_Inst : %ld", papp);
       plen=es.ES_fill_tcp_data(buf,plen,test);
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h3>") );  

        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<img src='http://chart.apis.google.com/chart?chs=300x150&cht=gom&chco=00FF00,FFFF00,FF0000&chls=3|10,1,1&chd=t:") );  
       sprintf(test, "%ld&chds=0,8000&chl=%ld'>" ,papp,papp);

      plen=es.ES_fill_tcp_data(buf,plen,test);
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=1000'>Histo Conso</a>") );  
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=0'>Histo Puissance</a>") );  
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<a href='t.htm?cmd=1'>Valeurs Brut</a>") );  

        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</html>") );  
        
        return(plen);
 }
 /////////////////////////////////////////////////////////
// affichage page Valeurs courantes Compteur
// !!  Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////

uint16_t print_webpage4(uint8_t *buf)
{
        uint16_t plen;
           plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
       sprintf(test, "<html><head><title>Tele %ldW</title></head>", papp);
       plen=es.ES_fill_tcp_data(buf,plen,test);
             plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" <h2><font color=\"blue\">"));
       sprintf(test, "
   %d:%d:%d    %d/%d/%d", hour(),minute(),second(),day(),month(),year());

       plen=es.ES_fill_tcp_data(buf,plen,test);
       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
 ADCO = "));
       plen=es.ES_fill_tcp_data(buf,plen,adco);
       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
 OPTARIF = "));
       plen=es.ES_fill_tcp_data(buf,plen,optarif);
      sprintf(test, "
ISOUSC = %ld", isousc);
       plen=es.ES_fill_tcp_data(buf,plen,test);
      sprintf(test, "
HCHC = %ld", hchc);
       plen=es.ES_fill_tcp_data(buf,plen,test);
      sprintf(test, "
HCHP = %ld", hchp);
       plen=es.ES_fill_tcp_data(buf,plen,test);

       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
 PTEC = "));
       plen=es.ES_fill_tcp_data(buf,plen,ptec);
      sprintf(test, "
IINST = %ld", iinst);
       plen=es.ES_fill_tcp_data(buf,plen,test);
       sprintf(test, "
IMAX = %ld", imax);
       plen=es.ES_fill_tcp_data(buf,plen,test);
       sprintf(test, "
PAPP = %ld", papp);
       plen=es.ES_fill_tcp_data(buf,plen,test);
       sprintf(test, "
HHPHC = %c", hhphc);
      plen=es.ES_fill_tcp_data(buf,plen,test);
       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
 MODETAT = "));
       plen=es.ES_fill_tcp_data(buf,plen,motdetat);
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  
</font></h2></html> ") );  
        return(plen);
 }
 
/////////////////////////////////////////////////////////
// affichage page Historique
// !!  Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////
 uint16_t print_webpage2(uint8_t *buf,int cmd,char Pile_num)
{       // Attention 550 char Max
 
 unsigned int base = DIM_ENTETE * Pile_num;
 unsigned int Deb_pile = Read_int(base);
  int Taille_pile = Read_int(base + 2);

  long Time_wrap = Read_long(base+4);
  int Interval =  Read_int(base+8);
 unsigned int Ptr =  Read_int(base+ 10);
  unsigned long Time_evt;
  static int len = 10;
  int pos_fin;
  int pos_deb;
 unsigned char value;

        uint16_t plen;
        int position;
        plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
       sprintf(test, "<html><head><title>Teleinfo Historique</title></head>");
       plen=es.ES_fill_tcp_data(buf,plen,test);
 
             plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(" <h2><font color=\"blue\">"));
  
        if(Pile_num == 1) position =cmd;
        if(Pile_num == 0) position =cmd-1000;
        
        if (cmd ==0) position=0;
        pos_fin = position +len;
        pos_deb = position;
         Time_evt = Time_wrap ;
       sprintf(test, " %d/%d/%d  
",day(Time_evt),month(Time_evt),year(Time_evt));
        plen=es.ES_fill_tcp_data(buf,plen,test);

 
        while (( position < pos_fin)&& (position <= Taille_pile))
        {
          if (position > Ptr) Time_evt = Time_wrap + ((position-Taille_pile-1)*Interval);
          else  Time_evt = Time_wrap +(position*Interval);
          value = EEPROM.read(Deb_pile+position);
          if(value < 255)
            {
           sprintf(test, "
%d:%d:%d", hour(Time_evt),minute(Time_evt),second(Time_evt));
           plen=es.ES_fill_tcp_data(buf,plen,test);
            if(Pile_num == 1)sprintf(test, " %5d W", (value*40));
            if(Pile_num == 0)sprintf(test, " %5d Kw/h",value);

             plen=es.ES_fill_tcp_data(buf,plen,test);
            }
          position++;
        }
        if(position - pos_deb ==len)
        {
            if(Pile_num == 0) position = position + 1000;
            sprintf(test, "
<a href='t.html?cmd=%d'>></a>", position);

            plen=es.ES_fill_tcp_data(buf,plen,test);
        }
 
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  
</font></h2></html> ") );
 
        return(plen);
 }
 
/////////////////////////////////////////////////////////
//     affichage page Dump EEPROM
// !!  Longueur max de trame Ethernet 600 Octets
/////////////////////////////////////////////////////////
 uint16_t print_webpage3(uint8_t *buf,int cmd,char Pile_num)
{       // Attention 550 char Max
        uint16_t plen;
        int position;
        plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));

             plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Teleinfo Dump</title></head> <h2><font color=\"blue\">"));
 
        position=cmd-2000;
        while ( position < cmd-2000+50)
        {
            sprintf(test, " %x;", EEPROM.read(position));
            plen=es.ES_fill_tcp_data(buf,plen,test);
            position++;
        }
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  
</font></h2></html> ") );
        return(plen);
 }
 
 
 /////////////////////////////////////////////////////////////////////////
 // Analyse des paramétre de la ligne de Commande
 ////////////////////////////////////////////////////////////////////////
 
 int analyse_cmd(char *str)
{
  int r=0;
  int i=0;
  if (find_key_val(str,"cmd"))
  {   // is a ASCII number, return it
      while (strbuf[i] < 0x3a && strbuf[i] > 0x2f)
      {
        r=(r*10)+(strbuf[i]-0x30);
        i++;
      }
  }
  else return (-1);
  return r;
}
 #include "print.h"
#include "string.h"
#include "etherShield.h"
#include "stdio.h"
#include "Time.h" 
#include "EEPROM.h"
#include "param.h"
time_t prevDisplay = 0; // when the digital clock was displayed

#include "teleinfo.h"
#include "log.h"
#include "serveur_web.h"
#include "ntp.h"
char power;
char index;
void setup()
{
  init_ethernet();
  Serial.begin(1200);
          // parite paire E
          // 7 bits data
  UCSR0C = B00100100;
         ///////////////////////////////////////////////////////////////////////////
         // Avec cette commande serial monitor ne fonctionne pas normalement!
         // il faut etablir une liaison avec hyperterminal
         // attention l'uploading necessite de déconnecter la pin0 Rx
         ////////////////////////////////////////////////////////////////////////////
  setSyncInterval(interval_synchro);    
  setSyncProvider( client_process_NTP);  //set function to call when sync required
////////////////////////////////////////////////////////////////////////////////////////////////////
//Taille des piles d'enregistrement mémoire Max 1024 Bits
///////////////////////////////////////////////////////////////////////////////////////////////////
  test_init_pile ( 30, 500, 60, 1); // init de la pile (Offset, longueur, Intervall temps, N°pile)
  test_init_pile (540, 450, 1800, 0); // init de la pile (Offset, longueur, Intervall temps, N°pile)
}

void loop()
{
  web_server();
  read_teleinfo();

    // display heure
  if( now() != prevDisplay) //update the display only if the time has changed
  {
      power=papp/40;
      Write_log( now(), power, 1);                // Ecriture pile Puissnce
     
      if (ptec[1]=='C') index = (hchc/1000)%250;  // Sauve Index Heure Creuse
      else index = (hchp/1000)%250;               // Sauve Index Heure Creuse
      Write_log( now(), index, 0);                // Ecriture Pile Index Kw/h

      prevDisplay = now();
     // digitalClockDisplay();  
  }
}

//*****************************************************************************************
//
// Function : Affichage liaison serie
//
//*****************************************************************************************

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

************le .pde

J'ai bien des ex de code pour le onewire + dallas mais c'est où les placer dans mon code (enfin le code que j'ai trouvé) et les incorporer aussi sur une des 4 page web ou rajouter une 5eme page.
pareil pour les relais (contact on/off).

Pas facile ou plus de place mem. ou j'ai loupé un épisode :cry:

// get current temperature
#define TEMP_PIN  3
void getCurrentTemp( int *sign, int *whole, int *fract);

je pense le mettre en pageweb 1 (si cela fonctionne j'essaierai de le mettre en page 5 à créer).

   // initialize DS18B20 datapin
    digitalWrite(TEMP_PIN, LOW);
    pinMode(TEMP_PIN, INPUT);      // sets the digital pin as input (logic 1)

et celui là après //init the ethernet/ ip layer:

        getCurrentTemp(temp_string);
        
        plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><p><h1>Welcome to Arduino Ethernet Shield V1.0  </h1></p> "));
         
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>
<form METHOD=get action=\""));
        plen=es.ES_fill_tcp_data(buf,plen,baseurl);
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> Current Temperature is </h2> "));
       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#00FF00\"> "));
         
       
        while (temp_string[i]) {
                buf[TCP_CHECKSUM_L_P+3+plen]=temp_string[i++];
                plen++;
        }

       plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  &#176C</font></h1>
 ") );
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=1>"));
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"Get Temperature\"></form>"));
        plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</center><hr> <p> V1.0 <a href=\"http://www.nuelectronics.com\">www.nuelectronics.com<a>"));

et ce code dans la pageweb 1 entre la ligne :
sprintf (test, "%ld&chds=0,8000&chl=%ld'>" ,papp, papp) ;

et celle qui suit
plen=es_fill_tcp_data_p (buf, plen, test);

Pour afficher en page 1 la T°C.

void OneWireReset(int Pin) // reset.  Should improve to act as a presence pulse
{
     digitalWrite(Pin, LOW);
     pinMode(Pin, OUTPUT); // bring low for 500 us
     delayMicroseconds(500);
     pinMode(Pin, INPUT);
     delayMicroseconds(500);
}

void OneWireOutByte(int Pin, byte d) // output byte d (least sig bit first).
{
   byte n;

   for(n=8; n!=0; n--)
   {
      if ((d & 0x01) == 1)  // test least sig bit
      {
         digitalWrite(Pin, LOW);
         pinMode(Pin, OUTPUT);
         delayMicroseconds(5);
         pinMode(Pin, INPUT);
         delayMicroseconds(60);
      }
      else
      {
         digitalWrite(Pin, LOW);
         pinMode(Pin, OUTPUT);
         delayMicroseconds(60);
         pinMode(Pin, INPUT);
      }

      d=d>>1; // now the next bit is in the least sig bit position.
   }
   
}

byte OneWireInByte(int Pin) // read byte, least sig byte first
{
    byte d, n, b;

    for (n=0; n<8; n++)
    {
        digitalWrite(Pin, LOW);
        pinMode(Pin, OUTPUT);
        delayMicroseconds(5);
        pinMode(Pin, INPUT);
        delayMicroseconds(5);
        b = digitalRead(Pin);
        delayMicroseconds(50);
        d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position
    }
    return(d);
}


void getCurrentTemp(char *temp)
{  
  int HighByte, LowByte, TReading, Tc_100, sign, whole, fract;

  OneWireReset(TEMP_PIN);
  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec

  OneWireReset(TEMP_PIN);
  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0xbe);

  LowByte = OneWireInByte(TEMP_PIN);
  HighByte = OneWireInByte(TEMP_PIN);
  TReading = (HighByte << 8) + LowByte;
  sign = TReading & 0x8000;  // test most sig bit
  if (sign) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25

  whole = Tc_100 / 100;  // separate off the whole and fractional portions
  fract = Tc_100 % 100;


      if(sign) temp[0]='-';
      else              temp[0]='+';
      
        if(whole/100==0)
           temp[1] =' ';
        else
        temp[1]= whole/100+'0';
      temp[2]= (whole-(whole/100)*100)/10 +'0' ;
      temp[3]= whole-(whole/10)*10 +'0';
      
      temp[4]='.';
      temp[5]=fract/10 +'0';
      temp[6]=fract-(fract/10)*10 +'0';
      
      temp[7] = '\0';


      
}

Celui là je pense le mettre tout à la fin.

Voilà, vous en pensez quoi ? des erreurs ?

PS : après, je verrai pour les relais ON/OFF simple.

int8_t analyse_cmd(char *str)
{
        int8_t r=-1;
     
        if (find_key_val(str,"cmd")){
                if (*strbuf < 0x3a && *strbuf > 0x2f){
                        // is a ASCII number, return it
                        r=(*strbuf-0x30);
                }
        }
        return r;
}

Il y a ce code qui est diffèrent entre les deux (le mien et celui mis pour la T°C juste au dessus). Je pense qu'il risque d'y avoir conflit si je le rajoute ? ou si je le transforme ?
Je me demande si ce n'est pas là mon problème pour joindre les deux :-/

Ou cela concerne juste l'appel de la page ?

Bon, mon projet ne semble intéresser personne. Dommage pour moi.

Détrompe toi, je pense plutôt que tu n'as pas de réponse parce que ton code dépasse largement les compétences de beaucoup d'entre nous.

Ce n'est malheureusement pas le mien mais j'ai l'autorisation de l'auteur pour l'utiliser et le mettre ici. Je ne pouvais pas plus l'embêter pour m'aider car déjà son boulot est superbe.

D'après lui, le rajout n'est pas difficile mais je comprends pourquoi car son niveau est déjà important.

Je vais essayer de modifier tout seul et de mettre les résultats et les erreurs peut-être cela fera avancer.

Oui, ce sera mieux de présenter l'évolution de ton travail par étape, ce sera aussi plus facile pour la compréhension et l'aide qui pourrait t'être apportée.

si t'es hyper newby, t'as pas chois la facilité, car d'apres ton code tu as un shield ethernet plus compliqué que l'officiel à programmer me semble-t-il
es-tu vraiment dans ce cas ?
as tu encore le choix, de prendre un shield officiel de qq euros plus cher mais bien plus simple à programmer ?

J'ai donc collé les lignes que j'avais marqué précédemment :

  • // get current temperature
  • // initialize DS18B20 datapin
  • getCurrentTemp
  • void onewirereset

A la compilation j'obtiens les erreurs :
1/ serveur_web.h : in fonction 'uint16_t print_webpage (uint8_t*)':
2/ serveur_web.h : 208 error 'temp_string' was not declared in this scope
3/ serveur_web.h : 214 error 'baseur1' was not declared in this scope
4/ serveur_web.h : 220 error 'i' was not declared in this scope

Il me faut rajouter quoi ou changer ?

PS : le code télé info fonctionne parfaitement - je cherche juste à rajouter si possible la T°C et relay.

salut,

je veux bien t'aider, mais là j'avoue que je n'arrive pas à avoir une vision d'ensemble de ton problème, j'ai du mal à suivre :-/
Il y a des bouts de code qui se ballade un peu partout dans le topic. Quel est le code de départ, et que veux-tu rajouter ?
Quel shield Ethernet utilises-tu ?

Gromain

Je vais essayer de reprendre :
mon post 5 et 6 (les deux premiers codes) correspondent au serveur_web.h
le post 7 (qui suit) c'est le teleinfo.pde

***Là, c'est ce qui est existant et qui fonctionne super bien.

A cela, je désirerais rajouter une ou des sondes DS18B20 (en onewire) et si il reste de la place 4 relais simple on/off (sur la même page web ou sur une autre).

J'ai trouvé des exemples de codes que j'ai mis dans mes "reply #9, 10 et 11" et que j'ai essayé d'intégrer. Apres compilation, il m'a sorti les erreurs que j'ai décrit (reply#18).

J'utilise le enc28j60.