• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
problem z kodem
#1
Witam, mam oto taki kod:
Kod:
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>

// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192, 168, 0, 177);

// fill in your Domain Name Server address here:
IPAddress myDns(192, 168, 0, 1);

// initialize the library instance:
EthernetClient client;

//char server[] = "www.arduino.cc";
IPAddress server(192,168,0,102);

unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers
 SoftwareSerial HC12(53, 54); // HC-12 TX Pin, HC-12 RX Pin
 
void setup() {
 // start serial port:
 Serial.begin(9600);
 HC12.begin(9600);               // Serial port to HC12

 // give the ethernet module time to boot up:
 delay(1000);
 // start the Ethernet connection using a fixed IP address and DNS server:
 Ethernet.begin(mac, ip, myDns);
 // print the Ethernet board/shield's IP address:

}

void loop() {
 // if there's incoming data from the net connection.
 // send it out the serial port.  This is for debugging
 // purposes only:
 if (client.available()) {
   char c = client.read();
   Serial.write(c);
 }

 // if ten seconds have passed since your last connection,
 // then connect again and send data:
 if (millis() - lastConnectionTime > postingInterval) {
   httpRequest();
 }

}

void httpRequest() {

 client.stop();

 // if there's a successful connection:
 if (client.connect(server, 80)) {
   Serial.println("connecting...");
   client.println("GET /index.php?dane=");

while (HC12.available()) {            
    Serial.write(HC12.read());
    client.write(HC12.read());
   }
   
  client.print(" HTTP/1.1");
   client.println("Host: 192.168.0.102");
   client.println("Connection: close");
   client.println();

   lastConnectionTime = millis();
 } else {

   Serial.println("connection failed");
 }
}
Arduino łączy się z PHPem lecz nie chce nadać dandych z HC-12.
Jak powinien być napisany skrypt by dane były wysyłane do PHP
 
Odpowiedź
  


Wiadomości w tym wątku
problem z kodem - przez mikoh81 - 12-06-2018, 21:06
RE: problem z kodem - przez kaczakat - 12-06-2018, 22:40
RE: problem z kodem - przez mikoh81 - 12-06-2018, 22:48
RE: problem z kodem - przez kaczakat - 13-06-2018, 00:17

Skocz do:


Przeglądający: 1 gości