// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ETHERNET_LIB_CLOUD
#include <Ethernet.h>
#include <SPI.h>
#include <RemoteXY.h>
#include <math.h>
// RemoteXY connection settings
#define REMOTEXY_ETHERNET_MAC "DE:AD:BE:EF:EF:ED"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT xxxx
#define REMOTEXY_CLOUD_TOKEN "xxxx"
#define REMOTEXY_ACCESS_PASSWORD "xxxx"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,2,0,24,0,205,0,8,148,1,
67,5,21,14,20,5,1,29,6,67,
5,21,29,20,5,203,29,6,2,0,
9,80,22,11,2,26,1,24,79,78,
0,79,70,70,0,129,0,5,6,53,
6,36,84,101,109,112,101,114,97,116,
117,114,97,32,116,117,114,32,194,176,
67,0,129,0,2,21,59,6,204,84,
101,109,112,101,114,97,116,117,114,97,
32,114,101,116,117,114,32,194,176,67,
0,129,0,2,71,36,6,17,66,101,
99,32,109,97,103,97,122,105,101,0,
129,0,1,36,60,6,94,84,46,32,
99,97,109,101,114,97,32,99,101,110,
116,114,97,108,97,32,194,176,67,0,
67,5,21,45,20,5,94,27,6,67,
5,21,61,20,5,2,26,6,129,0,
12,52,38,6,17,84,46,32,109,97,
103,97,122,105,101,32,194,176,67,0,
1,2,46,79,12,12,2,35,120,0,
129,0,46,71,12,6,17,84,101,115,
116,0 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t bec; // =1 if switch ON and =0 if OFF
uint8_t test; // =1 if button pressed, else =0
// output variable
char t_tur[6]; // string UTF8 end zero
char t_retur[6]; // string UTF8 end zero
char t_cam[6]; // string UTF8 end zero
char t_mag[6]; // string UTF8 end zero
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
#define PIN_BEC 5
#define pin_rel 6
int sensorPin1 = A0;
int sensorPin2 = A1;
int sensorPin3 = A2;
int sensorPin4 = A3;
double Thermistor(int RawADC)
{double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celcius
//Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}
void setup()
{
RemoteXY_Init ();
pinMode (PIN_BEC, OUTPUT);
pinMode (pin_rel,OUTPUT);
Serial.begin(9600);
}
void loop()
{
RemoteXY_Handler ();
int readVal1 = analogRead(sensorPin1);
int readVal2 = analogRead(sensorPin2);
int readVal3 = analogRead(sensorPin3);
int readVal4 = analogRead(sensorPin4);
double temp1 = Thermistor(readVal1);
double temp2 = Thermistor(readVal2);
double temp3 = Thermistor(readVal3);
double temp4 = Thermistor(readVal4);
dtostrf(temp1, 0, 1, RemoteXY.t_tur);
dtostrf(temp2, 0, 1, RemoteXY.t_retur);
dtostrf(temp3, 0, 1, RemoteXY.t_cam);
dtostrf(temp4, 0, 1, RemoteXY.t_mag);
Serial.println(temp1);
if (temp1 > 92 || temp2 < 0)
{
digitalWrite (pin_rel , LOW);
delay (50);
digitalWrite (pin_rel, HIGH);
delay (4000);
}
digitalWrite(PIN_BEC, (RemoteXY.bec==0)?HIGH:LOW);
digitalWrite(pin_rel, (RemoteXY.test==0)?HIGH:LOW);
delay (150);
}
i forgotten to say that i supply the module with a 5V 1000mA on the usb type B...