Topic: too much delay on communication DS18B20 and some help
hi there,
i'm trying to use this to read a temperature from a sensor DS18B20 and write it on the app (which i already did) and also to control 3 or 4 relays (i have the pro app)
what is happening is that everytime i press the button on the app it takes like 5 or more seconds to change the state of the digital output
check my code:
/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,3,0,11,0,133,0,8,13,1,
67,4,38,36,20,5,2,26,11,129,
0,48,36,18,6,16,194,186,99,0,
2,0,3,30,22,11,2,26,31,31,
79,78,0,79,70,70,0,129,0,5,
23,18,6,17,80,111,119,101,114,0,
129,0,28,49,18,6,17,69,115,112,
114,101,115,115,111,0,129,0,30,67,
34,6,17,67,111,102,102,101,101,32,
77,117,103,0,129,0,40,24,15,6,
17,84,101,109,112,0,2,0,3,47,
22,11,2,26,31,31,79,78,0,79,
70,70,0,2,0,3,63,22,11,2,
26,31,31,79,78,0,79,70,70,0 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t power; // =1 if switch ON and =0 if OFF
uint8_t button_1; // =1 if switch ON and =0 if OFF
uint8_t button_2; // =1 if switch ON and =0 if OFF
// output variable
char text_1[11]; // string UTF8 end zero
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_POWER 3
#define PIN_BUTTON_1 4
#define PIN_BUTTON_2 5
void setup(void)
{ RemoteXY_Init ();
pinMode (PIN_POWER, OUTPUT);
pinMode (PIN_BUTTON_1, OUTPUT);
pinMode (PIN_BUTTON_2, OUTPUT);
// start serial port
Serial.begin(115200);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
sensors.setResolution (0, 10); //in here it ends the temperature reading/writing
}
void loop(void)
{ RemoteXY_Handler ();
if (RemoteXY.button_1==1) {
digitalWrite(4, LOW);
delay(16000);
digitalWrite(4, HIGH);
}
else{
digitalWrite(4, HIGH);
}
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
RemoteXY_Handler ();
sensors.requestTemperatures ();
float t1 = sensors.getTempCByIndex (0);
dtostrf (t1, 0, 1, RemoteXY.text_1);
delay (1000); //in here it ends the temperature reading/writing
}
I'm not a programmer so i have some difficulties with the code and i search and read and test a lot
i also want this
when i press button_1 and button_2 the output goes from HIGH to LOW for 16 seconds and then to HIGH again and stays like that till i press the buttons again, any help??
thanks a lot