Post by Joshua on Dec 31, 2019 15:37:57 GMT
Happy New Year folks,
Would you please give this script a once over? I've added a change log below and tagged the changes with JA Beta. I've added a couple of sensors to the choose_nodes_MhF9r1_pub.ino and renamed it choose_nodes_MhF9r1_pub_JA_Beta.ino (139.46 KB) The new nodes are publishing; however, the voltage and RSSI are not publishing through the radio. I believe that they are posting via serial, but I can't remember. With your feedback, I'll update the script and test.
Here's the node I'm working with.
Here's the change log
Line 147
#define SI7021 // for temp and hum SI7021
Line 149
#define Bh1750 // Bh1750 ambient light intensity
Line 573
#ifdef SI7021 // SI7021 sensor JA Beta
#include "SparkFun_Si7021_Breakout_Library.h"
#include <Wire.h>
Weather sensor;
#endif //ifdef SI7021
Line 579
#ifdef Bh1750 // Bh1750 sensor JA Beta
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
#endif //end of ifdef Bh1750
Line 602
//HT, DS18, DS18A, DS18B, ULTRASONIC, CURRENT_SENSOR, CURSEN, SI7021 Hum&Temp, Bh1750 //JA Beta
bool send48, send49, send50, send51, send52, send53, send54, send55 , send56 ; //message triggers for Real (decimaled) input from sensors
Line 699
int PirInput = 3; //PIR pin. If also on sleepy, must be PIN3 (attachInterrupt(1)) for interrupt to work, JA Changed to pin 3 from 5 //JA Beta
Line 1310
#ifdef Bh1750 //JA Beta
// Initialize the I2C bus (BH1750 library doesn't do this automatically)
Wire.begin();
lightMeter.begin(BH1750::ONE_TIME_LOW_RES_MODE);
Serial.print(" BH175 LUX");
#endif //ifdef Bh1750
Line 1317
#ifdef SI7021 //JA Beta
Serial.print(" SI7021");
#endif //ifdef SI7021
Line 1923 (No change here. Are these correct? Expecting #ifdef)
case (48): // temperature
if (mes.cmd == 1) send48 = true;
break;
case (49): // humidity
if (mes.cmd == 1) send49 = true;
break;
case (50): // temperature
if (mes.cmd == 1) send50 = true;
break;
Line 1951
#ifdef SI7021
case (54): //temperature JA Beta
if (mes.cmd == 1) send54 = true;
break;
case (55): //humidity
if (mes.cmd == 1) send55 = true;
break;
#endif //ifdef Si7021
#ifdef Bh1750
case (56): //light intensity value JA Beta
if (mes.cmd == 1) send56 = true;
break;
#endif //ifdef Bh1750
Line 2550
#ifdef SI7021
if (send54) { //Temperature JA Beta
mes.devID = 54;
temp = sensor.getTempF();
#ifdef DEBUG
Serial.print(" Temperature : ");
Serial.println(temp);
#endif //ifdef DEBUG
mes.fltVal = temp; //light intensity data to send
send54 = false;
txRadio();
}
//end of if (send54)
if (send55) { //Humidity JA Beta
mes.devID = 55;
hum = sensor.getRH();
#ifdef DEBUG
Serial.print(" Humidity : ");
Serial.println(hum);
#endif //ifdef DEBUG
mes.fltVal = hum; //light intensity data to send
send55 = false;
txRadio();
}
//end of if (send55)
#endif //SI7021
#ifdef Bh1750
if (send56) { //Lux JA Beta
mes.devID = 56;
lux = lightMeter.readLightLevel();
delay(100);
#ifdef DEBUG
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
#endif //ifdef DEBUG
mes.fltVal = lux; //light intensity data to send
send56 = false;
txRadio();
} //end of if (send56)
#endif //ifdef Bh1750
Line 3655
#ifdef SI7021
send54 = true; //send temperature
send55 = true; //send humidity
#endif //ifdef SI7021
#ifdef Bh1750
send56 = true; //send light intensity value
#endif //ifdef Bh1750
Line 3952
//54 SI7021:Temp JA Beta
//55 SI7021:Hum JA Beta
//56 Bh1750:Lux JA Beta
#define SI7021 // for temp and hum SI7021
Line 149
#define Bh1750 // Bh1750 ambient light intensity
Line 573
#ifdef SI7021 // SI7021 sensor JA Beta
#include "SparkFun_Si7021_Breakout_Library.h"
#include <Wire.h>
Weather sensor;
#endif //ifdef SI7021
Line 579
#ifdef Bh1750 // Bh1750 sensor JA Beta
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
#endif //end of ifdef Bh1750
Line 602
//HT, DS18, DS18A, DS18B, ULTRASONIC, CURRENT_SENSOR, CURSEN, SI7021 Hum&Temp, Bh1750 //JA Beta
bool send48, send49, send50, send51, send52, send53, send54, send55 , send56 ; //message triggers for Real (decimaled) input from sensors
Line 699
int PirInput = 3; //PIR pin. If also on sleepy, must be PIN3 (attachInterrupt(1)) for interrupt to work, JA Changed to pin 3 from 5 //JA Beta
Line 1310
#ifdef Bh1750 //JA Beta
// Initialize the I2C bus (BH1750 library doesn't do this automatically)
Wire.begin();
lightMeter.begin(BH1750::ONE_TIME_LOW_RES_MODE);
Serial.print(" BH175 LUX");
#endif //ifdef Bh1750
Line 1317
#ifdef SI7021 //JA Beta
Serial.print(" SI7021");
#endif //ifdef SI7021
Line 1923 (No change here. Are these correct? Expecting #ifdef)
case (48): // temperature
if (mes.cmd == 1) send48 = true;
break;
case (49): // humidity
if (mes.cmd == 1) send49 = true;
break;
case (50): // temperature
if (mes.cmd == 1) send50 = true;
break;
Line 1951
#ifdef SI7021
case (54): //temperature JA Beta
if (mes.cmd == 1) send54 = true;
break;
case (55): //humidity
if (mes.cmd == 1) send55 = true;
break;
#endif //ifdef Si7021
#ifdef Bh1750
case (56): //light intensity value JA Beta
if (mes.cmd == 1) send56 = true;
break;
#endif //ifdef Bh1750
Line 2550
#ifdef SI7021
if (send54) { //Temperature JA Beta
mes.devID = 54;
temp = sensor.getTempF();
#ifdef DEBUG
Serial.print(" Temperature : ");
Serial.println(temp);
#endif //ifdef DEBUG
mes.fltVal = temp; //light intensity data to send
send54 = false;
txRadio();
}
//end of if (send54)
if (send55) { //Humidity JA Beta
mes.devID = 55;
hum = sensor.getRH();
#ifdef DEBUG
Serial.print(" Humidity : ");
Serial.println(hum);
#endif //ifdef DEBUG
mes.fltVal = hum; //light intensity data to send
send55 = false;
txRadio();
}
//end of if (send55)
#endif //SI7021
#ifdef Bh1750
if (send56) { //Lux JA Beta
mes.devID = 56;
lux = lightMeter.readLightLevel();
delay(100);
#ifdef DEBUG
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
#endif //ifdef DEBUG
mes.fltVal = lux; //light intensity data to send
send56 = false;
txRadio();
} //end of if (send56)
#endif //ifdef Bh1750
Line 3655
#ifdef SI7021
send54 = true; //send temperature
send55 = true; //send humidity
#endif //ifdef SI7021
#ifdef Bh1750
send56 = true; //send light intensity value
#endif //ifdef Bh1750
Line 3952
//54 SI7021:Temp JA Beta
//55 SI7021:Hum JA Beta
//56 Bh1750:Lux JA Beta