Arduino + EPSolar Tracer + AJAX

Automatizace, řízení, měření, logování a programování s využitím platformy Arduino.
Uživatelský avatar
rottenkiwi
Příspěvky: 5451
Registrován: pát úno 13, 2015 2:24 pm
Lokalita: SO, SK
Bydliště: SO, SK

Arduino + EPSolar Tracer + AJAX

Příspěvek od rottenkiwi »

Ak by ste potrebovali vyčítavať dáta z nejakého Ep. Tracera, tak tu je na to kód do Arduina.
MOžete si potom napr. urobiť zobrazovanie cez AJAX, alebo to dať do databázy cez Rasp. Pi
+ PHP + MySQL.
tracer_ttl_15082018.png
https://github.com/xxv/tracer/blob/master/README.md
https://github.com/xxv/tracer/blob/mast ... Tracer.ino
https://github.com/xxv/tracer/blob/mast ... r-MT-5.pdf
http://randomsporadicprojects.blogspot. ... -to_9.html
https://www.youtube.com/watch?v=RnJiKDCugoY

Kód: Vybrat vše

/*
  Software serial multple serial test

 Receives from the two software serial ports,
 sends to the hardware serial port.

 In order to listen on a software port, you call port.listen().
 When using two software serial ports, you have to switch ports
 by listen()ing on each one in turn. Pick a logical time to switch
 ports, like the end of an expected transmission, or when the
 buffer is empty. This example switches ports when there is nothing
 more to read from a port

 The circuit:
 Two devices which communicate serially are needed.
 * First serial device's TX attached to digital pin 2, RX to pin 3
 * Second serial device's TX attached to digital pin 4, RX to pin 5

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created 18 Apr. 2011
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's twoPortRXExample

 This example code is in the public domain.

 */
#include <SD.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SoftwareSerial.h>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <EEPROM.h>
// software serial #1: TX = digital pin 10, RX = digital pin 11
//SoftwareSerial portOne(13, 12);

// software serial #2: TX = digital pin 8, RX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
//SoftwareSerial portTwo(63, 62);

SoftwareSerial myserial(12, 13); // RX, TX

uint8_t start[] = { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,
                    0xEB, 0x90, 0xEB, 0x90, 0xEB, 0x90 };
uint8_t id = 0x16;
uint8_t cmd[] = { 0xA0, 0x00, 0xB1, 0xA7, 0x7F };

uint8_t buff[128];

#define REQ_BUF_SZ 100
File webFile;
char HTTP_req [REQ_BUF_SZ] = {0};
char req_index = 0;
const int chipSelect = 4;
const float ref_a = 1.238;
const float ref_b = 1.238;
const float ref_c = 1.238;
const float ref_d = 1.231;

boolean LED_state[4] = {0}; // stores the states of the LEDs
EthernetServer server(80);
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEC
};
IPAddress ip(192, 168, 1, 20);
boolean pass_OK = 0;

int ee_addr = 0;
const int max_bf = 70;
const int bfln = 17;
char buffer_in [max_bf] =  "a98765432109876540987654321098765409876543210987654098765432109876540";

const int v_index_max = 4;
int voltage [v_index_max] = {3};

  float battery;
  float pv;
  //13-14 reserved
  float load_current;
  float over_discharge;
  float battery_max;
  // 21 load on/off
  // 22 overload yes/no
  // 23 load short yes/no
  // 24 reserved
  // 25 battery overload
  // 26 over discharge yes/no
  uint8_t full;
  uint8_t charging;
  int8_t battery_temp;
  float charge_current;


   
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  pinMode(10, OUTPUT);
  digitalWrite(10,HIGH);
  
  pinMode(53, OUTPUT);
  digitalWrite(53,HIGH);

  myserial.begin(9600);
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());

    // start Ethernet and UDP
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    //for (;;)       ;
  }

  // Start each software serial port
  //portOne.begin(9600);
  //portTwo.begin(9600);
}

float to_float(uint8_t* buffer, int offset){
  unsigned short full = buffer[offset+1] << 8 | buff[offset];

  return full / 100.0;
}


void loop() {
  // By default, the last intialized port is listening.
  // when you want to listen on a port, explicitly select it:

  /*
  portOne.listen();
  Serial.println("Data from port one:");
  // while there is data coming in, read it
  // and send to the hardware serial port:
  byte ii = 0;
  while (portOne.available() > 0) {
    char inByte = portOne.read();
    buffer_in [ii++] = inByte; 
    Serial.write(inByte);
  
  }

 if ( StrContains(buffer_in, "FEFD") )
  {
    int  i = 0;
    i = StrIndex (buffer_in, "FEFD");
    i = i + 3;
    Serial.print(" i: ");
    Serial.println(i);
    Serial.write (buffer_in [i]);
    Serial.write (buffer_in [i+1]);
    voltage [0]= (int)( buffer_in [i]-'0' ) * 16 + (int) ( buffer_in [i+1] - '0' );
    voltage [0]= voltage [0] * 4;
    
    Serial.print("Voltage 1. is : ");    
    Serial.println(voltage [0]);

    Serial.print ("float : ");
    Serial.println (1024.0*ref_a/(float)voltage [0]);
  }

   if ( StrContains(buffer_in, "FDFC") )
  {
    int  i = 0;
    i = StrIndex (buffer_in, "FDFC");
    i = i + 3;
    Serial.print(" i: ");
    Serial.println(i);
    Serial.write (buffer_in [i]);
    Serial.write (buffer_in [i+1]);
    voltage [1]= (int)( buffer_in [i]-'0' ) * 16 + (int) ( buffer_in [i+1] - '0' );
    voltage [1]= voltage [1] * 4;
    
    Serial.print("Voltage 2. is : ");    
    Serial.println(voltage [1]);

    Serial.print ("float : ");
    Serial.println (1024.0*ref_b/(float)voltage [1]);
  }


  if ( StrContains(buffer_in, "FEFB") )
  {
    int  i = 0;
    i = StrIndex (buffer_in, "FEFB");
    i = i + 3;
    Serial.print(" i: ");
    Serial.println(i);
    Serial.write (buffer_in [i]);
    Serial.write (buffer_in [i+1]);
    voltage [2]= (int)( buffer_in [i]-'0' ) * 16 + (int) ( buffer_in [i+1] - '0' );
    voltage [2]= voltage [2] * 4;
    
    Serial.print("Voltage 3. is : ");    
    Serial.println(voltage [2]);

    Serial.print ("float : ");
    Serial.println (1024.0*ref_c/(float)voltage [2]);
  }

   if ( StrContains(buffer_in, "FDFA") )
  {
    int  i = 0;
    i = StrIndex (buffer_in, "FDFA");
    i = i + 3;
    Serial.print(" i: ");
    Serial.println(i);
    Serial.write (buffer_in [i]);
    Serial.write (buffer_in [i+1]);
    voltage [3]= (int)( buffer_in [i]-'0' ) * 16 + (int) ( buffer_in [i+1] - '0' );
    voltage [3]= voltage [3] * 4;
    
    Serial.print("Voltage 3. is : ");    
    Serial.println(voltage [3]);

    Serial.print ("float : ");
    Serial.println (1024.0*ref_d/(float)voltage [3]);
  }

  */

  // blank line to separate data from the two ports:

  // blank line to separate data from the two ports:
  Serial.println("Reading Tracer");
  myserial.write(start, sizeof(start));
  myserial.write(id);
  myserial.write(cmd, sizeof(cmd));
  int read = 0;
  for (int i = 0; i < 255; i++){
    if (myserial.available()) {
      buff[read] = myserial.read();
      read++;
    }
  }
  Serial.print("Read ");  Serial.print(read);  Serial.println(" bytes");
  for (int i = 0; i < read; i++){
      Serial.print(buff[i], HEX);
      Serial.print(" ");
  }
  Serial.println();
    battery = to_float(buff, 9);
  pv = to_float(buff, 11);
  //13-14 reserved
  load_current = to_float(buff, 15);
  over_discharge = to_float(buff, 17);
  battery_max = to_float(buff, 19);
  // 21 load on/off   // 22 overload yes/no   // 23 load short yes/no   // 24 reserved   // 25 battery overload
  // 26 over discharge yes/no
  full = buff[27];
  charging = buff[28];
  battery_temp = buff[29] - 30;
  charge_current = to_float(buff, 30);

  Serial.print("Load is ");
  Serial.println(buff[21] ? "on" : "off");

  Serial.print("Load current: ");
  Serial.println(load_current);

  Serial.print("Battery level: ");
  Serial.print(battery);
  Serial.print("/");
  Serial.println(battery_max);

  Serial.print("Battery full: ");
  Serial.println(full ? "yes " : "no" );

  Serial.print("Battery temperature: ");
  Serial.println(battery_temp);

  Serial.print("PV voltage: ");
  Serial.println(pv);

  Serial.print("Charging: ");
  Serial.println(charging ? "yes" : "no" );

  Serial.print("Charge current: ");
  Serial.println(charge_current);


  //voltage = 404.00;
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c = client.read();
          //read char by char HTTP request
          // buffer first part of HTTP request in HTTP_req array (string)
          // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
          if (req_index < (REQ_BUF_SZ - 1)) {
              HTTP_req[req_index] = c;          // save HTTP request character
              req_index++;
          }
          // last line of client request is blank and ends with \n
          // respond to client only after last line received
           
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Access-Control-Allow-Origin: http://rottenkiwi.no-ip.biz");
          // remainder of header follows below, depending on if
          // web page or XML page is requested
          // Ajax request - send XML file
              
                    if (StrContains(HTTP_req, "GET")
                                 && StrContains(HTTP_req, "ajax_inputs")) {
                        // send rest of HTTP header
                        client.println("Content-Type: text/xml");
                        client.println("Connection: keep-alive");
                        client.println();
                        SetLEDs ();
                        // send XML file containing input states
                        XML_response(client);
                    }
                    else
                    if (StrContains(HTTP_req, "POST")
                                 && StrContains(HTTP_req, "ajax_inputs=1")) {
                        // send rest of HTTP header
                        client.println("Content-Type: text/xml");
                        client.println("Connection: keep-alive");
                        client.println();
                        SetLEDs ();
                        // send XML file containing input states
                        XML_response(client);
                    }
                
                    else {  // web page request
                        // send rest of HTTP header
                        client.println("Content-Type: text/html");
                        client.println("Connection: close");
                        client.println();
                        if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
                              webFile = SD.open("index.htm");        // open web page file
                        }
                        if (StrContains(HTTP_req, "GET /favicon.ico")
                                 || StrContains(HTTP_req, "GET /favicon.ico")) {
                              webFile = SD.open("favicon.ico");        // open web page file
                        }
                        else if (StrContains(HTTP_req, "GET /logtr.htm")) {
                              webFile = SD.open("logtr.htm");        // open web page file
                        }
                        else if (StrContains(HTTP_req, "GET /page0.htm")) {
                              webFile = SD.open("page0.htm");        // open web page file
                        }   
                        else if (StrContains(HTTP_req, "GET /page1.htm")) {
                              webFile = SD.open("page1.htm");        // open web page file
                        }      
                        else if (StrContains(HTTP_req, "GET /lifelog.txt")) {
                              webFile = SD.open("lifelog.txt");        // open web page file
                        }      
                        else if (StrContains(HTTP_req, "GET /datalog.txt")) {
                              webFile = SD.open("datalog.txt");        // open web page file
                        }      
                        
                  
                        if (webFile) {
                            while(webFile.available()) {
                                client.write(webFile.read()); // send web page to client
                            }
                            webFile.close();
                        }
                    }
                    // display received HTTP request on serial port
                    Serial.print(HTTP_req);
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
          
/*          
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          int analogChannel = Amp_1_pin;
          client.print("<p style=""color:blue"">");
          
          int sensorReadingA = analogRead(analogChannel);
          sensorReadingA = analogRead(analogChannel);
           
            client.print("A: ");
            //client.println("<br />");
            //client.print(analogChannel);
            //client.print(" = ");
            //client.print( ( Amp_min - A_offset ) / A_call );
            //client.print(", ");     
            //client.print( ( Amp_max - A_offset ) / A_call );
            //client.print(", ");
            //client.print( ( Amp_avg - A_offset ) / A_call );
            //client.print(", ");
            client.print( ( Amp_med - A_offset ) / A_call );
            client.print(", ");
            client.print( ( sensorReadingA - A_offset ) / A_call );
            //client.println("<br />");
          //client.print("</p>");  
          
          analogChannel = U_1_pin;
          int sensorReadingU = analogRead(analogChannel);
          sensorReadingU = analogRead(analogChannel);
          
          client.print("<p style=""color:red"">");
          client.print(" V: ");
          //client.println("<br />");
          
          //client.print(analogChannel);
          //client.print(" = ");
          //client.print( U_min*5.0/1023*U_call );
          //client.print(", ");            
          //client.print( U_max*5.0/1023*U_call );
          //client.print(", ");
          //client.print( U_avg*5.0/1023*U_call );
          //client.print(", ");
          client.print( U_med*5.0/1023*U_call );
          client.print(", ");
          client.print( sensorReadingU*5.0/1023*U_call );
          //client.println("<br />");
          
          /*
          for ( analogChannel = 6; analogChannel < 8; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            
            client.print("Voltage ");
            client.print(analogChannel);
            client.print(" = ");
            client.print(sensorReading*5.0/1023*U_call);
            client.println("<br />");
          }
          */
          //client.print("</p>");
/*          
          client.print("<p style=""color:black"">");
                   
          client.print("W: ");
          //client.println("<br />");
          //client.print(analogChannel);
          //client.print(" = ");
          //client.print( ( ( Amp_min - A_offset ) / A_call ) * ( U_min*5.0/1023*U_call ) );
          //client.print(", ");            
          //client.print( ( ( Amp_max - A_offset ) / A_call ) * ( U_max*5.0/1023*U_call ) );
          //client.print(", ");
          //client.print( ( ( Amp_avg - A_offset ) / A_call ) * ( U_avg*5.0/1023*U_call ) );
          //client.print(", ");
          client.print( ( ( Amp_med - A_offset ) / A_call ) * ( U_med*5.0/1023*U_call ) );
          client.print(", ");
          client.print( ( ( sensorReadingA - A_offset ) / A_call ) * ( sensorReadingU*5.0/1023*U_call ) );
          //client.println("<br />");
          //client.print("</p>");  
          
          client.print(" Wh: ");
          //client.print(analogChannel);
          //client.print(" = ");
          client.print( P_day );
          //client.println("<br />");
          //client.print("</p>"); 
          
          client.print("<p style=""color:red"">");
          client.print(" DC Wh: ");
          //client.print(analogChannel);
          //client.print(" = ");
          client.print( P_Dc );
          //client.println("<br />");
          //client.print("</p>"); 
          
          
       
          client.print("<p style=""color:green"">");
          client.print("C: ");
          client.print(celsius);
          //client.print(" Celsius, ");
          client.println("<br />");
          
            client.println("<a href=\"/?r2on\"\">+L2</a>");
            client.println("<a href=\"/?r2off\"\">-L2</a><br />");
            client.println("<br>");

            client.println("<a href=\"/?r3on\"\">+L3</a>");
            client.println("<a href=\"/?r3off\"\">-L3</a><br />");
            client.println("<br>");

            client.println("<a href=\"/?r5on\"\">+L5</a>");
            client.println("<a href=\"/?r5off\"\">-L5</a><br />");
            client.println("<br>");

            client.println("<a href=\"/?r6on\"\">+L6</a>");
            client.println("<a href=\"/?r6off\"\">-L6</a><br />");
            client.println("<br>");

            client.println("<a href=\"/?r7on\"\">+L7</a>");
            client.println("<a href=\"/?r7off\"\">-L7</a><br />");
            client.println("<br>");

            client.println("<a href=\"/?r8on\"\">+L8</a>");
            client.println("<a href=\"/?r8off\"\">-L8</a><br />");
            client.println("<br>"); 
            
          client.println("</html>");          
          break;
*/          
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
/*    
    if(readString.indexOf("?r2on") > 0)//checks for on
  
      digitalWrite(2, HIGH);    // set pin 2 high
      Serial.println("Led On");
      client.println("L2 On");
      client.println("<br>");
    }

    if(readString.indexOf("?r2off") >0)//checks for off
    {
      digitalWrite(2, LOW);    // set pin 2 low
      Serial.println("Led Off");
      client.println("L2 Off");
      client.println("<br>");
    }

    if(readString.indexOf("?r3on") >0)//checks for on
    {
      digitalWrite(3, HIGH);    // set pin 4 high
      Serial.println("Led On");
      client.println("L3 On");
      client.println("<br>");
    }
    
    if(readString.indexOf("?r3off") >0)//checks for off
    {
      digitalWrite(3, LOW);    // set pin 4 low
      Serial.println("Led Off");
      client.println("L3 Off");
      client.println("<br>");
    }
    
    if(readString.indexOf("?r5on") >0)//checks for on
    {
      digitalWrite(5, HIGH);    // set pin 6 high
      Serial.println("Led On");
      client.println("L5 On");
      client.println("<br>");
    }
    
    if(readString.indexOf("?r5off") >0)//checks for off
    {
      digitalWrite(5, LOW);    // set pin 6 low
      Serial.println("Led Off");
      client.println("L5 Off");
      client.println("<br>");
    }
    
    if(readString.indexOf("?r6on") >0)//checks for on
    {
      digitalWrite(6, HIGH);    // set pin 7 high
      Serial.println("Led On");
      client.println("L6 On");
      client.println("<br>");
    }

    if(readString.indexOf("?r6off") >0)//checks for off
    {
      digitalWrite(6, LOW);    // set pin 7 low
      Serial.println("Led Off");
      client.println("L6 Off");
      client.println("<br>");
    }

    if(readString.indexOf("?r7on") >0)//checks for on
    {
      digitalWrite(7, HIGH);    // set pin 8 high
      Serial.println("Led On");
      client.println("L7 On");
      client.println("<br>");
    }

    if(readString.indexOf("?r7off") >0)//checks for off
    {
      digitalWrite(7, LOW);    // set pin 8 low
      Serial.println("Led Off");
      client.println("L7 Off");
      client.println("<br>");
    }

    if(readString.indexOf("?r8on") >0)//checks for on
    {
      digitalWrite(8, HIGH);    // set pin 9 high
      Serial.println("Led On");
      client.println("L8 On");
      client.println("<br>");
    }

    if(readString.indexOf("?r8off") >0)//checks for off
    {
      digitalWrite(8, LOW);    // set pin 9 low
      Serial.println("Led Off");
      client.println("L8 Off");
      client.println("<br>");
    }

   //clearing string for next read
   readString="";
*/    
    Serial.println("client disconnected");
  }
  
}

// checks if received HTTP request is switching on/off LEDs
// also saves the state of the LEDs
void SetLEDs(void)
{
  if (StrContains(HTTP_req, "12345678")) {
    pass_OK = 1;
     digitalWrite(5, HIGH);
    // LED 1 (pin 5)
    if (StrContains(HTTP_req, "LED1=1")) {
        LED_state[0] = 1;  // save LED state
        digitalWrite(5, HIGH);
    }
    else if (StrContains(HTTP_req, "LED1=0")) {
        LED_state[0] = 0;  // save LED state
        digitalWrite(5, LOW);
    }
    // LED 2 (pin 6)
    if (StrContains(HTTP_req, "LED2=1")) {
        LED_state[1] = 1;  // save LED state
        digitalWrite(6, HIGH);
    }
    else if (StrContains(HTTP_req, "LED2=0")) {
        LED_state[1] = 0;  // save LED state
        digitalWrite(6, LOW);
    }
    // LED 3 (pin 7)
    if (StrContains(HTTP_req, "LED3=1")) {
        LED_state[2] = 1;  // save LED state
        digitalWrite(7, HIGH);
    }
    else if (StrContains(HTTP_req, "LED3=0")) {
        LED_state[2] = 0;  // save LED state
        digitalWrite(7, LOW);
    }
    // LED 4 (pin 8)
    if (StrContains(HTTP_req, "LED4=1")) {
        LED_state[3] = 1;  // save LED state
        digitalWrite(8, HIGH);
    }
    else if (StrContains(HTTP_req, "LED4=0")) {
        LED_state[3] = 0;  // save LED state
        digitalWrite(8, LOW);
    }
  }
  else 
    digitalWrite(5, LOW);
}


// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
int StrContains(char *str, char *sfind)
{
    int found = 0;
    int index = 0;
    int len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}


int StrIndex (char *str, char *sfind)
{
    int found = 0;
    int index = 0;
    int len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return index;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}


// send the XML file containing analog value
void XML_response(EthernetClient cl)
{
    int analog_val;
    int count;                 // used by 'for' loops
    int sw_arr[] = {2, 3};  // pins interfaced to switches
    
    
    cl.println("<?xml version=\"1.0\"?>");
    cl.println("<inputs>");
    
    cl.print("<analog>");
    cl.print( pv );
    cl.println("</analog>");
    
    cl.print("<analog>");
    cl.print( charge_current );
    cl.println("</analog>");    
    
    cl.print("<analog>");
    cl.print( load_current );
    cl.println("</analog>");
    
    cl.print("<analog>");
    cl.print( (battery/battery_max) );
    cl.println("</analog>");
    
    cl.print("<analog>");
    cl.print((1024.0*1.24/(float)voltage[0]));
    cl.println("</analog>");
    
    cl.print("<analog>");
    cl.print((1024.0*1.24/(float)voltage[0]));
    cl.println("</analog>");
   
    cl.print("<analog>");
    cl.print( (1024.0*1.24/(float)voltage[0]));
    cl.println("</analog>");
    
    cl.print("<analog>");
    cl.print( (1024.0*1.24/(float)voltage[0]) );
    cl.println("</analog>");  

    cl.print("<LED>");
    if (LED_state[0]) {
        cl.print("checked");
    }
    else {
        cl.print("unchecked");
    }
    cl.println("</LED>");
    // LED2
    cl.print("<LED>");
    if (LED_state[1]) {
        cl.print("checked");
    }
    else {
        cl.print("unchecked");
    }
     cl.println("</LED>");
    
      // button LED states
    // LED3
    cl.print("<LED>");
    if (LED_state[2]) {
        cl.print("on");
    }
    else {
        cl.print("off");
    }
    cl.println("</LED>");
    // LED4
    cl.print("<LED>");
    if (LED_state[3]) {
        cl.print("on");
    }
    else {
        cl.print("off");
    }
    cl.println("</LED>");
    
 /*    
    cl.print("<analog>");
    cl.print(last_temp);
    cl.print("</analog>");
 */ 
 

    
    cl.println("</inputs>");
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

Ak potrebujete HTML kód k tým budíkom, napíšte PM alebo mail, lebo tu sa to nedá pridať.
DC-AC inverter REC Lion DC-AC ESP32 DIY inv. 15 GB za sekundu DIY MPPT Holder
Zjedz vsetko, co si kupil, v obchode a netreba ti tasku, auto ci chladnicku.

  • Podobná témata
    Odpovědi
    Zobrazení
    Poslední příspěvek