// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,0,0,44,0,80,0,8,13,0,
67,4,9,11,20,5,134,26,11,67,
4,38,11,20,5,134,26,11,67,4,
66,11,20,5,134,26,11,67,4,64,
44,20,5,134,26,11,129,0,10,22,
18,6,17,73,110,110,101,45,32,32,
32,32,32,32,32,32,32,75,121,108,
97,114,45,32,32,32,32,32,32,85,
116,101,116,101,109,112,0 };
// this structure defines all the variables of your control interface
struct {
// output variable
char INtemp[11]; // string UTF8 end zero
char Coolant[11]; // string UTF8 end zero
char OUTtemp[11]; // string UTF8 end zero
char Voltage[11]; // string UTF8 end zero
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
// END RemoteXY include //
double temp = 24;
void setup()
{
RemoteXY_Init ();
}
void loop()
{
RemoteXY_Handler ();
if(currentSek-rXYtime >= 4) { //uppdaterar rXY värderna vart 4dje sek.
// value, ? , decimals, rXY label tillagt manuellt
dtostrf(ITemp, 0, 0, RemoteXY.INtemp);
dtostrf(CTemp, 0, 0, RemoteXY.Coolant);
dtostrf(OTemp, 0, 0, RemoteXY.OUTtemp);
dtostrf(battVolt, 0, 1, RemoteXY.Voltage);
rXYtime = currentSek; }
//----------- batteri voltage
battVolt = analogRead(battPin); // 1024 = 5 volt = ca.15 volt
//battVolt = 967 ; // test
battVolt = (5*battVolt)/1024 ; // konverterar analoga värdet till volt 0-5 volt
battVolt = ((33+68)/33 *battVolt)*10 ; // kontverterar 5 till 12 volt (analog in)
battVolt = battVolt/10 ;
}
Inga kommentarer:
Skicka en kommentar