SYSTEM_MODE(MANUAL);

TCPServer server = TCPServer(23);
TCPClient client;
UDP udp;

// Loop vars
unsigned long last_temp_time = 0;
unsigned long last_temp_request_time = 0;
bool requesting_temp = false;
unsigned long last_send_time = 0;
float temp;
String buffer;

DS18B20 ds18b20 = DS18B20(D6);

double Setpoint=152, Input, Output;
int Kp=2, Ki=5, Kd=1;

PID Pid1(&Input, &Output, &Setpoint, Kp, Ki, Kd, PID_DIRECT);

String hostIP = "192.168.1.106";

void ipArrayFromString(byte ipArray[], String ipString) {
  int dot1 = ipString.indexOf('.');
  ipArray[0] = ipString.substring(0, dot1).toInt();
  int dot2 = ipString.indexOf('.', dot1 + 1);
  ipArray[1] = ipString.substring(dot1 + 1, dot2).toInt();
  dot1 = ipString.indexOf('.', dot2 + 1);
  ipArray[2] = ipString.substring(dot2 + 1, dot1).toInt();
Пример #2
0
#include "application.h"
#include "PietteTech_DHT.h"
#include "DS18B20.h"

#define DHTTYPE  DHT11             // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN   3         	    // Digital pin for communications
#define DHT_SAMPLE_INTERVAL   4000  // Sample Air Temp every 4 seconds

DS18B20 ds18b20 = DS18B20(D2);

void dht_wrapper();
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

bool firstPass = true;
char szInfo[75];
char status[64];
byte dsAddr;
float pubTemp;
double celsius;
double fahrenheit;
float airtemp = 0;
float airhumidity = 0;
unsigned long metric_Publish_Rate = 30000;
unsigned long metricNextPublishTime = 35000;
unsigned long tempNextSampleTime = 30000;
unsigned long temp_Sample_Rate = 10000;
unsigned long dsNextSampleTime = 20000;
unsigned long ds_Sample_Rate = 2000;
unsigned long syncDHTNextSampleTime = 10000;
unsigned long syncDHT_Sample_Rate = 10000;
unsigned long wireSearchTime = 20000;