Need a bid of help...
-
Hi there i'm working on my first project.
got some code working fine, but would like to try to add an BMP180 or 280 into the sketch.
I.m working with the latest version of my sensors. 2.1
.
It would be nice to include a forecast but that a bid to hard for me at this moment.
so far i found a sample of a weather station, ith forecast, but im not shure if i need more sensors like a dht then.
.
Maybe some could give a sample or advice.// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> #include <BH1750.h> #include <Wire.h> unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int SOLAR_SENSE_PIN = A1; // select the input pin for the solar sense point #define CHILD_ID_BATTERY 4 #define CHILD_ID_SOLAR 6 #define CHILD_ID_LIGHT 1 BH1750 lightSensor; int oldBatteryPcnt = 0; MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); MyMessage msgsolar(CHILD_ID_SOLAR, V_VOLTAGE); MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); uint16_t lastlux; //lux void setup(){ // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif { // Send the sketch version information to the gateway and Controller sendSketchInfo("Battery Meter", "2.0"); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); }} void loop() { // get the battery Voltage int sensorValue2 = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValue1 = analogRead(BATTERY_SENSE_PIN); delay(100); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValueS = analogRead(SOLAR_SENSE_PIN); delay(1000); #ifdef MY_DEBUG Serial.print("Battery Voltage2: "); Serial.println(sensorValue2); Serial.print("Battery Voltage1: "); Serial.println(sensorValue1); Serial.print("Battery Voltage: "); Serial.println(sensorValue); Serial.print("Solar Voltage: "); Serial.println(sensorValueS); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 const float vRef = 4.200/ 1.05/ 1023 ; int batteryPcnt = sensorValue / 10; float batteryV = sensorValue * 0.0042598 ; // 0.0038952294568380753114792412093 max 4,2 volt float batteryS = sensorValueS * 0.0102459 ; // 0.0038952294568380753114792412093 max 10 volt #ifdef MY_DEBUG Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); send(msgbatt.set(batteryV ,2)); Serial.print("Solar Voltage: "); Serial.print(batteryS); Serial.println(" V"); send(msgsolar.set(batteryS ,2)); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); if (lux != lastlux) { send(msg.set(lux)); lastlux = lux; } sleep(SLEEP_TIME); }```
-
@Rene046 said in Need a bid of help...:
Hi there i'm working on my first project.
got some code working fine, but would like to try to add an BMP180 or 280 into the sketch.
I.m working with the latest version of my sensors. 2.1
.
It would be nice to include a forecast but that a bid to hard for me at this moment.
so far i found a sample of a weather station, ith forecast, but im not shure if i need more sensors like a dht then.
.
Maybe some could give a sample or advice.// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> #include <BH1750.h> #include <Wire.h> unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int SOLAR_SENSE_PIN = A1; // select the input pin for the solar sense point #define CHILD_ID_BATTERY 4 #define CHILD_ID_SOLAR 6 #define CHILD_ID_LIGHT 1 BH1750 lightSensor; int oldBatteryPcnt = 0; MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); MyMessage msgsolar(CHILD_ID_SOLAR, V_VOLTAGE); MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); uint16_t lastlux; //lux void setup(){ // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif { // Send the sketch version information to the gateway and Controller sendSketchInfo("Battery Meter", "2.0"); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); }} void loop() { // get the battery Voltage int sensorValue2 = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValue1 = analogRead(BATTERY_SENSE_PIN); delay(100); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValueS = analogRead(SOLAR_SENSE_PIN); delay(1000); #ifdef MY_DEBUG Serial.print("Battery Voltage2: "); Serial.println(sensorValue2); Serial.print("Battery Voltage1: "); Serial.println(sensorValue1); Serial.print("Battery Voltage: "); Serial.println(sensorValue); Serial.print("Solar Voltage: "); Serial.println(sensorValueS); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 const float vRef = 4.200/ 1.05/ 1023 ; int batteryPcnt = sensorValue / 10; float batteryV = sensorValue * 0.0042598 ; // 0.0038952294568380753114792412093 max 4,2 volt float batteryS = sensorValueS * 0.0102459 ; // 0.0038952294568380753114792412093 max 10 volt #ifdef MY_DEBUG Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); send(msgbatt.set(batteryV ,2)); Serial.print("Solar Voltage: "); Serial.print(batteryS); Serial.println(" V"); send(msgsolar.set(batteryS ,2)); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); if (lux != lastlux) { send(msg.set(lux)); lastlux = lux; } sleep(SLEEP_TIME); }```
i forget to tell i have an bmp180 and a bme280 available
-
What are the read command for an bme280
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure= bme.readPressure()
?
-
this is what i got s far...
mysensor.readTempC() and bmp.readTemperature(); both not working.
now i got it accepted but my working sketch peaces give problems.// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> #include <BH1750.h> #include <Wire.h> //#include <Adafruit_BME280.h> //#include <SparkFunBME280.h> #include <BME280_MOD-1022.h> unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int SOLAR_SENSE_PIN = A1; // select the input pin for the solar sense point #define CHILD_ID_BATTERY 4 #define CHILD_ID_SOLAR 6 #define CHILD_ID_LIGHT 1 #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 2 #define CHILD_ID_BARO 3 BH1750 lightSensor; int oldBatteryPcnt = 0; MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); MyMessage msgHum(CHILD_ID_HUM,V_HUM); MyMessage msgPres(CHILD_ID_BARO,V_PRESSURE); MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); MyMessage msgsolar(CHILD_ID_SOLAR, V_VOLTAGE); MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); uint16_t lastlux; //lux void setup(){ // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif { // Send the sketch version information to the gateway and Controller sendSketchInfo("Battery Meter", "2.0"); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_BARO, S_BARO); present(CHILD_ID_HUM, S_HUM); }} void loop() { // get the battery Voltage int sensorValue2 = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValue1 = analogRead(BATTERY_SENSE_PIN); delay(100); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(1000); int sensorValueS = analogRead(SOLAR_SENSE_PIN); delay(1000); // Read out the data - must do this before calling the getxxxxx routines BME280.readMeasurements(); // get temperature from BME280 float temperature = BME280.getTemperatureMostAccurate(); // get humidity from BME280 float humidity = BME280.getHumidityMostAccurate(); // get pressure from BME280 float pressure = BME280.getPressureMostAccurate(); } #ifdef MY_DEBUG Serial.print("Battery Voltage2: "); Serial.println(sensorValue2); Serial.print("Battery Voltage1: "); Serial.println(sensorValue1); Serial.print("Battery Voltage: "); Serial.println(sensorValue); Serial.print("Solar Voltage: "); Serial.println(sensorValueS); Serial.print("Buiten Temp: "); Serial.print(temperature); Serial.println(" Celcius"); send(msgTemp.set(temperature, 1)); Serial.print("Vochtigheid: "); Serial.print(humidity); Serial.println(" ?"); send(msgHum.set(humidity, 1)); Serial.print("Buiten Druk: "); Serial.print(pressure); Serial.println(" ?"); send(msgPres.set(pressure, 2)); Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); send(msgbatt.set(batteryV ,2)); Serial.print("Solar Voltage: "); Serial.print(batteryS); Serial.println(" V"); send(msgsolar.set(batteryS ,2)); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 const float vRef = 4.200/ 1.05/ 1023 ; int batteryPcnt = sensorValue / 10; float batteryV = sensorValue * 0.0042598 ; // 0.0038952294568380753114792412093 max 4,2 volt float batteryS = sensorValueS * 0.0102459 ; // 0.0038952294568380753114792412093 max 10 volt if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); if (lux != lastlux) { send(msg.set(lux)); lastlux = lux; } sleep(SLEEP_TIME); }```
-
Take a look at nodemanager, it will simplify your life ️
-
Hi Gohan.
Im still learning .. nodemanager ????
Features
Manage all the aspects of a sleeping cycle by leveraging smart sleep Allow configuring the sleep mode and the sleep duration remotely Allow waking up a sleeping node remotely at the end of a sleeping cycle Allow powering on each connected sensor only while the node is awake to save battery Report battery level periodically and automatically Calculate battery level without requiring an additional pin and the resistors Report battery voltage through a built-in sensor Can report battery level on demand Allow rebooting the board remotely Provide out-of-the-box sensors personalities and automatically execute their main task at each cycle
it looks intresting but i just started...
-
For beginners it's easier, it cuts down code quite a lot
-
Do you have a sample or could you help me starting with the sketch i already have ?
-
@Rene046 said in Need a bid of help...:
Do you have a sample or could you help me starting with the sketch i already have ?
i installed nodemanager i think ...lol
-
This post is deleted!
-
maybe you set the something wrong in the sleep settings, but without seeing your code it's hard to give you an answer
-
Found it i connected the BME280 in the BH1750 line after removing i worked again....
the sketch could not work without Seeing the BH1750.my code is in my first post on top of this topic.
-
Yes, but I wanted to see if you made the modifications to run the nodemanager
-
nope i dont even know where to start....
-