Skip to content

Commit 2ba4513

Browse files
committed
rf24 to rf24 PA/LNA version
1 parent 9cc58ab commit 2ba4513

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

_02-mqtt-sw-temperature/_02-mqtt-sw-temperature.ino

+19-21
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ extern "C" {
3131
#define DEBUG_PRINT 0
3232

3333
// ****************
34+
time_t getNtpTime();
3435
void callback(char* intopic, byte* inpayload, unsigned int length);
3536
String macToStr(const uint8_t* mac);
36-
time_t getNtpTime();
3737
void run_lightcmd();
3838
void changelight();
3939
void sendmqttMsg(char* topictosend, String payload);
@@ -42,7 +42,6 @@ void getdalastemp();
4242
void getdht22temp();
4343
void sendNTPpacket(IPAddress & address);
4444

45-
4645
// ****************
4746
const char* ssid = WIFI_SSID;
4847
const char* password = WIFI_PASSWORD;
@@ -132,9 +131,10 @@ int pirSent ;
132131
int oldpirValue ;
133132

134133
/*
135-
volatile int relaystatus = LOW;
136-
volatile int oldrelaystatus = LOW;
134+
volatile int relaystatus = LOW;
135+
volatile int oldrelaystatus = LOW;
137136
*/
137+
138138
volatile int relaystatus = LOW;
139139
int oldrelaystatus = LOW;
140140

@@ -369,7 +369,6 @@ void setup()
369369
// Hostname defaults to esp8266-[ChipID]
370370
ArduinoOTA.setHostname("esp-swtemp");
371371

372-
373372
// No authentication by default
374373
ArduinoOTA.setPassword(otapassword);
375374

@@ -384,12 +383,12 @@ void setup()
384383
});
385384
ArduinoOTA.onError([](ota_error_t error) {
386385
//ESP.restart();
387-
if (error == OTA_AUTH_ERROR) abort();
388-
else if (error == OTA_BEGIN_ERROR) abort();
389-
else if (error == OTA_CONNECT_ERROR) abort();
390-
else if (error == OTA_RECEIVE_ERROR) abort();
391-
else if (error == OTA_END_ERROR) abort();
392-
386+
if (error == OTA_AUTH_ERROR) abort();
387+
else if (error == OTA_BEGIN_ERROR) abort();
388+
else if (error == OTA_CONNECT_ERROR) abort();
389+
else if (error == OTA_RECEIVE_ERROR) abort();
390+
else if (error == OTA_END_ERROR) abort();
391+
393392
});
394393

395394
ArduinoOTA.begin();
@@ -544,7 +543,6 @@ void loop()
544543
Serial.println(sensor_data.devid);
545544
}
546545

547-
548546
String radiopayload = "{\"_salt\":";
549547
radiopayload += sensor_data._salt;
550548
radiopayload += ",\"volt\":";
@@ -557,7 +555,7 @@ void loop()
557555
radiopayload += sensor_data.devid;
558556
radiopayload += "}";
559557

560-
if ( (sensor_data.devid > 0) && (sensor_data.devid < 255) )
558+
if ( (sensor_data.devid > 0) && (sensor_data.devid < 255) )
561559
{
562560
String newRadiotopic = radiotopic;
563561
newRadiotopic += "/";
@@ -595,7 +593,6 @@ void runTimerDoLightOff()
595593

596594
void changelight()
597595
{
598-
599596
if (DEBUG_PRINT) {
600597
Serial.print(" => ");
601598
Serial.print("checking relay status changelight --> ");
@@ -682,29 +679,30 @@ void sendmqttMsg(char* topictosend, String payload)
682679

683680
void run_lightcmd()
684681
{
685-
int topbuttonstatus = ! digitalRead(TOPBUTTONPIN);
682+
//int topbuttonstatus = ! digitalRead(TOPBUTTONPIN);
686683
if ( relayIsReady == HIGH ) {
687-
relaystatus = topbuttonstatus ;
684+
//relaystatus = topbuttonstatus ;
685+
relaystatus = !relaystatus;
688686
}
689687
if (DEBUG_PRINT && ( relayIsReady == HIGH )) {
690-
Serial.print("run_lightcmd => topbuttonstatus => ");
691-
Serial.print(topbuttonstatus);
688+
//Serial.print("run_lightcmd => topbuttonstatus => ");
689+
//Serial.print(topbuttonstatus);
692690
Serial.print(" => relaystatus => ");
693691
Serial.println(relaystatus);
694692
}
695693
}
696694

697695
// pin 16 can't be used for Interrupts
698696
/*
699-
void motion_detection()
700-
{
697+
void motion_detection()
698+
{
701699
if (DEBUG_PRINT) {
702700
Serial.println("motion_detection called");
703701
}
704702
//pirValue =
705703
pirValue = digitalRead(pir);
706704
pirSent = HIGH ;
707-
}
705+
}
708706
*/
709707

710708
String macToStr(const uint8_t* mac)

0 commit comments

Comments
 (0)