Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Daten {
- String strTemp;
- String strLuftfeuchte;
- String strLuftguete;
- String strDruck;
- String strZeit;
- } dat;
- void daten_eingang(){
- if (client.available()) {
- char c = client.read();
- //Serial.print(c);
- }
- if (!(client.connected())) {
- //Serial.println();
- //Serial.println("disconnecting.");
- client.stop();
- }
- }
- void sende_request(void){
- //Serial.println("connecting...");
- if (client.connect(serverIP, 80)){
- //Serial.println("connected..");
- //Serial.println(client.remoteIP());
- client.println(getErsterTeil + "pAuthServer=" + pAuthServer + "&temperatur=" + dat.strTemp + "&Luftfeuchtigkeit=" + dat.strLuftfeuchte + "&Luftguete=" + dat.strLuftguete + "&luftdruck=" + dat.strDruck + "&zeitstempel=" + dat.strZeit + getLetzterTeil);
- client.println(adrHost);
- client.println();
- delay(1000);
- while(client.available()){
- daten_eingang();
- }
- zaehler = 0;
- }
- else {
- if(zaehler<5){
- zaehler++;
- delay(500);
- sende_request();
- }
- zaehler = 0;
- //Serial.println("connection failed");
- }
- }
- void ladeTemp(int32_t temperatur){
- //sprintf(buf, "%3d.%02d\337",(int8_t)(temperatur / 100)-3, (uint8_t)(temperatur % 100)); // Temp in decidegrees
- //dat.strTemp = buf;
- dat.strTemp = String(temperatur);
- }
- void ladeLuftfeuchte(int32_t feuchte){
- //sprintf(buf, "%3d.%03d", (int8_t)(feuchte / 1000),(uint16_t)(feuchte % 1000)); // Humidity milli-pct
- //dat.strLuftfeuchte = buf;
- dat.strLuftfeuchte = String(feuchte);
- }
- void ladeLuftguete(int32_t guete){
- //sprintf(buf, "%4d.%02d\n", (int16_t)(guete / 100), (uint8_t)(guete % 100)); // Resistance milliohms
- //dat.strLuftguete = buf;
- dat.strLuftguete = String(guete);
- }
- void ladeDruck(int32_t druck){
- //sprintf(buf, "%7d.%02d", (int16_t)(druck / 100),(uint8_t)(druck % 100)); // Pressure Pascals
- //dat.strDruck = buf;
- dat.strDruck = String(druck);
- }
- void ladeZeit(void){
- dat.strZeit = String(myTZ.toUTC(now()));
- }
- void setGETTemp(void){
- }
- void makeHTMLrequest(void){
- ladeTemp(temp);
- ladeLuftfeuchte(humidity);
- ladeLuftguete(gas);
- ladeDruck(pressure);
- ladeZeit();
- sende_request();
- }
Add Comment
Please, Sign In to add comment