o and i forget to ask if this product is a better option .
Posts made by Rene046
-
RE: š¬ Soil Moisture Sensor
-
RE: š¬ Soil Moisture Sensor
how did you wire you normal fork sensor, i get different reading when using a voltage divider if i switch the polarization.
i used this to connect it.
http://www.electronicwings.com/sensors-modules/soil-moisture-sensor
using pin digital 6 and 7 as alternating power, and pin A0 to readAnd how do other people protect there capacitive sensor electronics from water .. rain
-
Get date from Domoticz into Node
Hi there,
How can i take the data from a dimmer position out of Domoticz from my node, so i can use it to control a Mosfet.
I tried without luck..
request( Dimvalue, V_DIMMER );but think its not that simple...
kind regards Rene
-
RE: Analog to digital how ?
All working fine sometimes the pir reaction could be a bid faster, and sometimes i get a false reading think i'll have to put the pir signal lines to the ground with an resistor.
Any advice is welcome, to make thing faster, and less complex.
else use this with fun......#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG #include <Wire.h> // Wire library t.b.v. IĀ²C #include <MySensors.h> byte GPIOA = 0x12; // GPIOA adres in 16-bit mode, is directe aansturing 1e groep van 8 I/O poorten. byte GPIOB = 0x13; // GPIOA adres in 16-bit mode, is directe aansturing 1e groep van 8 I/O poorten. boolean sensorBovenActive; // Status of Pir motion sensor 2. boolean sensorOnderActive; // Status of Pir motion sensor 1. boolean sensorKelderActive; // Status of Pir motion sensor 0. int PIR0new; // Pir motion sensor 0 updated value "Kelder". int PIR0old; // Pir motion sensor 0 old value "Kelder". int PIR1new; // Pir motion sensor 1 updated value "sensorOnderActive". int PIR1old; // Pir motion sensor 1 old value "sensorOnderActive". int PIR2new; // Pir motion sensor 2 updated value. "sensorBovenActive" int PIR2old; // Pir motion sensor 2 old value. sensorBovenActive" int StairDelay = 250; // Delay for stairs int StairOn = 30000; // Delay to keep stair light on #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation(){ // Send the sketch version information to the gateway and Controller sendSketchInfo("Trap Controller", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor Kelder"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor Trap Onder"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor Trap Boven"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { Wire.begin(); // wake up I2C bus // set I/O pins to outputs Wire.beginTransmission(0x20); // Start adress of mcp23017 Wire.write(0x00); // IODIRA register Wire.write(0x00); // set all of port A to outputs Wire.endTransmission(); Wire.beginTransmission(0x20); Wire.write(0x01); // IODIRB register Wire.write(0x00); // set all of port B to outputs Wire.endTransmission(); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effneerop(); effopneer(); effKelder(); } void Pir0lezen() { int PIR0new = analogRead(A0); if (PIR0new >=900) { sensorKelderActive = true; // Send status to Domoticz send (msgPIR00.set(sensorKelderActive?"1":"0")); Serial.println("PIR0new----"); Serial.println(PIR0new); PIR0old = PIR0new; sensorKelderActive = false; send (msgPIR00.set(sensorKelderActive)); }} void Pir1lezen() { int PIR1new = analogRead(A1); if (PIR1new != PIR1old && PIR1new >=710) { sensorOnderActive = true ; sensorBovenActive = false ; // Send status to Domoticz send (msgPIR01.set(sensorOnderActive?"1":"0")); Serial.println("PIR1----"); Serial.println(PIR1new); PIR1old = PIR1new; }} void Pir2lezen() { int PIR2new = analogRead(A2); if (PIR2new != PIR2old && PIR2new >=710) { sensorBovenActive = true ; sensorOnderActive = false ; // Send status to Domoticz send (msgPIR02.set(sensorBovenActive?"1":"0")); Serial.println("PIR2----"); Serial.println(PIR2new); PIR2old = PIR2new; }} void effopneer() { if (sensorOnderActive==true && sensorBovenActive==false){ Serial.println("PIR1--aan"); sensorOnderActive = false ; setLEDA(B01111111); // Tree 1 delay(StairDelay); setLEDA(B00111111); // Tree 2 delay(StairDelay); setLEDA(B00011111); // Tree 3 delay(StairDelay); setLEDA(B00001111); // Tree 4 delay(StairDelay); setLEDA(B00000111); // Tree 5 delay(StairDelay); setLEDA(B00000011); // Tree 6 delay(StairDelay); setLEDA(B00000001); // Tree 7 delay(StairDelay); setLEDA(B00000000); // Tree 8 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDB(B00111111); // Tree 10 delay(StairDelay); setLEDB(B00011111); // Tree 11 delay(StairDelay); setLEDB(B00001111); // Tree 12 delay(StairDelay); setLEDB(B00000111); // Tree 13 delay(StairDelay); setLEDB(B00000011); // Tree 14 send (msgPIR01.set(sensorOnderActive)); // switch off before delay delay(StairOn); setLEDA(B11111111); // all off setLEDB(B11111111); // all off Serial.println("PIR1--uit"); }} void effneerop() { if (sensorOnderActive==false && sensorBovenActive==true){ Serial.println("PIR2--aan"); sensorBovenActive = false ; setLEDB(B11111011); // Tree 14 delay(StairDelay); setLEDB(B11110011); // Tree 13 delay(StairDelay); setLEDB(B11100011); // Tree 12 delay(StairDelay); setLEDB(B11000011); // Tree 11 delay(StairDelay); setLEDB(B10000111); // Tree 10 delay(StairDelay); setLEDB(B00000011); // Tree 9 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDA(B11111100); // Tree 7 delay(StairDelay); setLEDA(B11111000); // Tree 6 delay(StairDelay); setLEDA(B11110000); // Tree 5 delay(StairDelay); setLEDA(B11100000); // Tree 4 delay(StairDelay); setLEDA(B11000000); // Tree 3 delay(StairDelay); setLEDA(B10000000); // Tree 2 delay(StairDelay); setLEDA(B00000000); // Tree 1 send (msgPIR02.set(sensorBovenActive)); delay(StairOn); setLEDA(B11111111); // all off setLEDB(B11111111); // all off Serial.println("PIR2--uit"); }} void effKelder() { } void setLEDA(byte value) { Wire.beginTransmission(0x20); Wire.write(GPIOA); // gpioa Wire.write(byte(value)); // set LEDs volgens waarde 'value' Wire.endTransmission(); } void setLEDB(byte value) { Wire.beginTransmission(0x20); Wire.write(GPIOB); // gpiob Wire.write(byte(value)); // set LEDs volgens waarde 'value' Wire.endTransmission(); } void bonuseff() { setLEDB(B11111011); // Tree 14 delay(StairDelay); setLEDB(B11110111); // Tree 13 delay(StairDelay); setLEDB(B11101111); // Tree 12 delay(StairDelay); setLEDB(B11011111); // Tree 11 delay(StairDelay); setLEDB(B10111111); // Tree 10 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDA(B11111101); // Tree 7 delay(StairDelay); ; setLEDA(B11111011); // Tree 6 delay(StairDelay); ; setLEDA(B11110111); // Tree 5 delay(StairDelay); setLEDA(B11101111); // Tree 4 delay(StairDelay); setLEDA(B11011111); // Tree 3 delay(StairDelay); setLEDB(B10111110); // Tree 2 delay(StairDelay); setLEDB(B01111111); // Tree 1 delay(StairDelay); setLEDA(B10111111); // Tree 2 delay(StairDelay); setLEDA(B11011111); // Tree 3 delay(StairDelay); setLEDA(B11101111); // Tree 4 delay(StairDelay); setLEDA(B11110111); // Tree 5 delay(StairDelay); setLEDA(B11111011); // Tree 6 delay(StairDelay); setLEDA(B11111101); // Tree 7 delay(StairDelay); setLEDA(B11111110); // Tree 8 delay(StairDelay); setLEDB(B01111111); // Tree 9 delay(StairDelay); setLEDB(B10111111); // Tree 10 delay(StairDelay); setLEDB(B11011111); // Tree 11 delay(StairDelay); setLEDB(B11101111); // Tree 12 delay(StairDelay); setLEDB(B11110111); // Tree 13 delay(StairDelay); setLEDB(B11111011); // Tree 14 }```
-
RE: Analog to digital how ?
Thx
I already got it running after a long night ...lol
here is what i have sofar...
#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG //#include <SPI.h> #include <MySensors.h> boolean sensorUpperActive; // boolean sensorBottomActive; int sensorBottomActive; int PIR1new; int PIR1old; int PIR2new; int PIR2old; boolean PIR00; #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor 0"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor 1"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor 2"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: // Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effopneer(); effneerop(); Tegelijk(); // delay(1000); // delay in between reads for stability } void Pir0lezen() { int PIR0 = analogRead(A0); if (analogRead(A0) >=700) { Serial.println("PIR0----"); Serial.println(PIR0); PIR00 = true; }} void Pir1lezen() { int PIR1new = analogRead(A1); if (PIR1new != PIR1old && PIR1new >=700) { sensorBottomActive = true ; send (msgPIR01.set(sensorBottomActive?"1":"0")); // Send status to Domoticz Serial.println("PIR1----"); Serial.println(PIR1new); PIR1old = PIR1new; }} void Pir2lezen() { int PIR2new = analogRead(A2); if (PIR2new != PIR2old && PIR2new >=700) { sensorUpperActive = true ; send (msgPIR02.set(sensorUpperActive?"1":"0")); // Send status to Domoticz Serial.println("PIR2----"); Serial.println(PIR2new); PIR2old = PIR2new; } } void effopneer() { if (sensorBottomActive==true && sensorUpperActive==false){ // do something digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorBottomActive = false ; send (msgPIR01.set(sensorBottomActive)); Serial.println("PIR1--uit"); } } void effneerop() { if (sensorBottomActive==false && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; send (msgPIR02.set(sensorUpperActive)); Serial.println("PIR2--uit"); } } void Tegelijk() { if (sensorBottomActive==true && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(5000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; sensorBottomActive = false ; send (msgPIR01.set(sensorUpperActive)); send (msgPIR01.set(sensorBottomActive)); Serial.println("PIR1&2--uit"); } }
-
RE: Analog to digital how ?
#define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define MY_DEBUG //#include <SPI.h> #include <MySensors.h> boolean sensorUpperActive; boolean sensorBottomActive; boolean PIR00; #define MY_NODE_ID 30 #define CHILD_ID_PIR00 31 // Id of the sensor child #define CHILD_ID_PIR01 32 // Id of the sensor child #define CHILD_ID_PIR02 33 // Id of the sensor child void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "4.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR00, S_MOTION, "PIR Sensor 0"); present(CHILD_ID_PIR01, S_MOTION, "PIR Sensor 1"); present(CHILD_ID_PIR02, S_MOTION, "PIR Sensor 2"); } // Initialize motion message MyMessage msgPIR00(CHILD_ID_PIR00, V_TRIPPED); MyMessage msgPIR01(CHILD_ID_PIR01, V_TRIPPED); MyMessage msgPIR02(CHILD_ID_PIR02, V_TRIPPED); // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: // Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); } // the loop routine runs over and over again forever: void loop() { Pir0lezen(); Pir1lezen(); Pir2lezen(); effopneer(); effneerop(); Tegelijk(); // delay(1000); // delay in between reads for stability } void Pir0lezen() { int PIR0 = analogRead(A0); if (analogRead(A0) >=700) { Serial.println("PIR0----"); Serial.println(PIR0); PIR00 = true; // Send status to Domoticz }} void Pir1lezen() { int PIR1 = analogRead(A1); if (analogRead(A1) >=700) { sensorBottomActive = true; // Send status to Domoticz Serial.println("PIR1----"); Serial.println(PIR1); }} void Pir2lezen() { int PIR2 = analogRead(A2); if (analogRead(A2) >=700) { sensorUpperActive = true; // Send status to Domoticz Serial.println("PIR2----"); Serial.println(PIR2); }} void effopneer() { if (sensorBottomActive==true && sensorUpperActive==false){ // do something digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorBottomActive = false ; Serial.println("PIR1--uit"); } } void effneerop() { if (sensorBottomActive==false && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; Serial.println("PIR2--uit"); } } void Tegelijk() { if (sensorBottomActive==true && sensorUpperActive==true){ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(5000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW sensorUpperActive = false ; sensorBottomActive = false ; Serial.println("PIR1&2--uit"); } }
-
Analog to digital how ?
Hi there,
I would like to know what and where i have to look for.
I reading with my nano 328 port A0, A1, A2 voltage from "3" motion senors
and get a specific value >700
if one of those ports gets above this 700
I would like to send this true mysensors as an normal motion sensor normal true trigger
but im not using any interrupt
How do i send this ?if (analogRead(A0) >=700)
{
send(msgmotion0.set(tripped0?"1":"0"));and for the others.
send(msgmotion0.set(tripped0?"1":"0"));
send(msgmotion1.set(tripped1?"1":"0"));
send(msgmotion3.set(tripped3?"1":"0")); -
RE: Double Pir sensors
thx.
Aha i missed those
sketch is accepted, waiting for second pir sensor to test in real time.
thx again learned something new again...
Starting to have fun with Mysensors ...For other users who like to try.
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug prints // #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #define MY_NODE_ID 9 unsigned long SLEEP_TIME = 5000 ; // 120000 Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR1 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define DIGITAL_INPUT_SENSOR2 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // Id of the sensor child // Enable repeater functionality for this node #define MY_REPEATER_FEATURE // Initialize motion message MyMessage msg1(CHILD_ID_PIR1, V_TRIPPED); MyMessage msg2(CHILD_ID_PIR2, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR1, INPUT); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSOR2, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg1.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg2.set(tripped2?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR1), CHANGE, (DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME); }
-
RE: Double Pir sensors
thx for helping with last problem
only problem left is with why
MyMessage msg(CHILD_ID_PIR2, V_TRIPPED);
is not accepted./** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug prints // #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #define MY_NODE_ID 9 unsigned long SLEEP_TIME = 5000 ; // 120000 Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR1 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define DIGITAL_INPUT_SENSOR2 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // Id of the sensor child // Enable repeater functionality for this node #define MY_REPEATER_FEATURE // Initialize motion message MyMessage msg(CHILD_ID_PIR1, V_TRIPPED); MyMessage msg(CHILD_ID_PIR2, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR1, INPUT); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSOR2, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg.set(tripped2?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR1), CHANGE, (DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME); }
-
Double Pir sensors
Hi there i could use some help, i tried to expand the mysensors motion sketch but i would like to use 2 pir sensors.
I changed the sketch and get a strange message;
#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))^
exit status 1
redefinition of 'MyMessage msg'i thought nr 2 and 3 are with interrupt.
Than i think i'll have to change:
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);Well maybe someone have some time to help me.
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug prints // #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #define MY_NODE_ID 9 unsigned long SLEEP_TIME = 5000 ; // 120000 Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR1 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define DIGITAL_INPUT_SENSOR2 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID_PIR1 21 // Id of the sensor child #define CHILD_ID_PIR2 22 // Id of the sensor child // Enable repeater functionality for this node #define MY_REPEATER_FEATURE // Initialize motion message MyMessage msg(CHILD_ID_PIR1, V_TRIPPED); MyMessage msg(CHILD_ID_PIR2, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR1, INPUT); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSOR2, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PIR Sensor", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_PIR1, S_MOTION); present(CHILD_ID_PIR2, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR1) == HIGH; bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw Serial.println(tripped2); send(msg.set(tripped2?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }
-
RE: Create relay free potential free switch.
Thanks Gohan,
Will the repeater function keep working...... ? more like an interrupt when something is seen ?
-
RE: Create relay free potential free switch.
So far 1 relay works perfect adding a second one will be a bid harder because the sketch samples i found use more than 2 i would like to know how to add just a second one.
also in this sketch in need to find out hoe to remove the button function.
Adding the temperature sensor seems for me very hard, because i would like to call it every 5 minutes without interrupting the repeater. (No Sleep can be used).
if i know how to call every 5 minutes the temperature, i think i'll be able to add the also the adc code.I someone could point me to some code sample i would be very happy...
-
RE: Create relay free potential free switch.
will give it a try.
this is the sketch i want to implement this in:
It will be a repeater node,
I would like to have 2 Relays on pins D3,D4
And a temperature sensor on D5 (DS1820)
Eventually an voltage sense pin A3/* * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * http://www.mysensors.org/build/relay */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_RF24_PA_LEVEL RF24_PA_MAX // Enabled repeater feature for this node #define MY_REPEATER_FEATURE #define MY_NODE_ID 1 #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define RELAY_PIN1 3 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 7 // dont need this one remove #define CHILD_ID 1 #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); bool state = false; bool initialValueSent = false; MyMessage msg(CHILD_ID, V_STATUS); void setup() { // Setup the button //pinMode(BUTTON_PIN, INPUT_PULLUP); // After setting up the button, setup debouncer //debouncer.attach(BUTTON_PIN); //debouncer.interval(10); // Make sure relays are off when starting up digitalWrite(RELAY_PIN1, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN1, OUTPUT); // Set relay to last known state (using eeprom storage) state = loadState(CHILD_ID); digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF); } void presentation() { // Startup initialize MySensors library. Set callback for incoming messages. sendSketchInfo("Lamp", "1.0"); present(CHILD_ID, S_BINARY); } void loop() { if (!initialValueSent) { Serial.println("Sending initial value"); send(msg.set(state?RELAY_ON:RELAY_OFF)); Serial.println("Requesting initial value from controller"); request(CHILD_ID, V_STATUS); wait(2000, C_SET, V_STATUS); } if (debouncer.update()) { if (debouncer.read()==LOW) { state = !state; send(msg.set(state?RELAY_ON:RELAY_OFF), true); // Send new state and request ack back } } } void receive(const MyMessage &message) { if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_STATUS) { if (!initialValueSent) { Serial.println("Receiving initial value from controller"); initialValueSent = true; } // Change relay state state = (bool)message.getInt(); digitalWrite(RELAY_PIN1, state?RELAY_ON:RELAY_OFF); send(msg.set(state?RELAY_ON:RELAY_OFF)); // Store state in eeprom saveState(CHILD_ID, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getInt()); } }```
-
RE: Create relay free potential free switch.
Ok i explain.
i have and Gardena Watering computer, here i want to connect a controller on battery to
All this controller has to do via Mysensors is open or close a an switch (the 2 wires of this switch go inside the gardena computer that is looking for an 10k resistance to stop watering the plants, and an open switch 0 ohm to water the plants.Some distance further i have an other node that's measuring soil moisture,
I have this now running by using normal relays, but using 2 of them (2 garden computers ) they use allot of battery power while watering so i was hoping there are some more better options.
-
RE: Create relay free potential free switch.
because i dont want the water lock stay open after power lost.
-
Create relay free potential free switch.
Hi there,
i need some help with an idea i need...
I looking far a way to control a potential free contact to control an water lock, but without using a relay. if my water lock sees 10K on its connection it keeps it closed so no watering, if it sees 0 ohm it will have permission to water. my plants
.
i was thinking to use an opto coupler but those i now need a voltage going tru on the output... or am i wrong.or maybe some kind of hal sensor with internal coil controlled by an arduino
-
RE: š¬ Relay
I just tried this sketch, works on latest version, but i cant seen any relais in Domoticz, only see the node relais, did i miss something
-
RE: š¬ Temperature Sensor
i dont know how but i got it now running perfect, and cleaned up a bid.
for if anyone could use ....// 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 <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 3 on the Arduino #define ONE_WIRE_BUS 3 // 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); // arrays to hold device address DeviceAddress insideThermometer; unsigned long SLEEP_TIME = 30000; // 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_TEMP1 2 BH1750 lightSensor; float TempC = 50.5; int oldBatteryPcnt = 0; MyMessage msgTempC(CHILD_ID_TEMP1,V_TEMP); 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(void) { // 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); sensors.begin(); // start reading sensor // search for devices on the bus and assign based on an index. ideally, if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) //sensors.setResolution(insideThermometer, 9); } void loop(void) { // 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 float TempC = sensors.getTempC(insideThermometer); #ifdef MY_DEBUG Serial.print("DS1820 Temperature: "); Serial.print(TempC); Serial.println(" C"); send(msgTempC.set(TempC ,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 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); }
-
RE: š¬ Temperature Sensor
here is my serial result.
45651 MCO:SLP:WUP=-1
Requesting temperatures...DONE
Temp 17.87 Temp F: 64.18
Battery Voltage2: 931
Battery Voltage1: 926
Battery Voltage: 927
Solar Voltage: 393
DS1820 Temperature: 50.50 C
49545 TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:50.50
Battery Voltage: 3.95 V
49557 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.95
Solar Voltage: 4.03 V
49569 TSF:MSG:SEND,2-2-0-0,s=6,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:4.03
Battery percent: 92 %
1
49577 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
49584 MCO:SLP:TPD -
RE: š¬ Temperature Sensor
so far my result.
had to use float TempC = 50.5 at the start
but in my serial i get the right temperature,
but using it in the loop gives me still wrong number 50.5 so gets not updated.// 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 <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 3 on the Arduino #define ONE_WIRE_BUS 3 // 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); // arrays to hold device address DeviceAddress insideThermometer; unsigned long SLEEP_TIME = 30000; // 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_TEMP1 2 BH1750 lightSensor; float TempC = 50.5; int oldBatteryPcnt = 0; MyMessage msgTemp(CHILD_ID_TEMP1,V_TEMP); 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(void) { // 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); //Serial.begin(9600); // start serial port Serial.print("Locating devices..."); // locate devices on the bus sensors.begin(); // start reading sensor Serial.print("Found "); Serial.print(sensors.getDeviceCount(), DEC); Serial.println(" devices."); Serial.print("Parasite power is: "); // report parasite power requirements if (sensors.isParasitePowerMode()) Serial.println("ON"); else Serial.println("OFF"); // assign address manually. the addresses below will beed to be changed // to valid device addresses on your bus. device address can be retrieved // by using either oneWire.search(deviceAddress) or individually via // sensors.getAddress(deviceAddress, index) //insideThermometer = { 0x10, 0x9C, 0x04, 0x26, 0x01, 0x08, 0x0, 0x8C }; // Method 1: // search for devices on the bus and assign based on an index. ideally, // you would do this to initially discover addresses on the bus and then // use those addresses and manually assign them (see above) once you know // the devices on your bus (and assuming they don't change). if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); // method 2: search() // search() looks for the next device. Returns 1 if a new address has been // returned. A zero might mean that the bus is shorted, there are no devices, // or you have already retrieved all of them. It might be a good idea to // check the CRC to make sure you didn't get garbage. The order is // deterministic. You will always get the same devices in the same order // // Must be called before search() //oneWire.reset_search(); // assigns the first address found to insideThermometer //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); // show the addresses we found on the bus Serial.print("Device 0 Address: "); printAddress(insideThermometer); Serial.println(); // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) sensors.setResolution(insideThermometer, 9); Serial.print("Device 0 Resolution: "); Serial.print(sensors.getResolution(insideThermometer), DEC); Serial.println(); } // function to print the temperature for a device void printTemperature(DeviceAddress deviceAddress) { // method 1 - slower //Serial.print("Temp C: "); //Serial.print(sensors.getTempC(deviceAddress)); //Serial.print(" Temp F: "); //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit // method 2 - faster float TempC = sensors.getTempC(deviceAddress); Serial.print("Temp C: "); Serial.print(TempC); Serial.print(" Temp F: "); Serial.println(DallasTemperature::toFahrenheit(TempC)); // Converts tempC to Fahrenheit } void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); // It responds almost immediately. Let's print out the data printTemperature(insideThermometer); // Use a simple function to print out the data { // 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("DS1820 Temperature: "); Serial.print(TempC); Serial.println(" C"); send(msgTemp.set(TempC ,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 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); }} // function to print a device address void printAddress(DeviceAddress deviceAddress) { for (uint8_t i = 0; i < 8; i++) { if (deviceAddress[i] < 16) Serial.print("0"); Serial.print(deviceAddress[i], HEX); } }
-
RE: š¬ Temperature Sensor
hi
Then i would have placed this in the loop>
The error i get then is :'TempC' was not declared in this scope#ifdef MY_DEBUG Serial.print("DS1820 Temperature: "); Serial.print(tempC); Serial.println(" C"); send(msgTemp.set(tempC ,2)); Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); send(msgbatt.set(batteryV ,2));```
-
RE: š¬ Temperature Sensor
forgot the sketch
// 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 <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 3 on the Arduino #define ONE_WIRE_BUS 3 // 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); // arrays to hold device address DeviceAddress insideThermometer; unsigned long SLEEP_TIME = 180000; // 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_TEMP1 2 BH1750 lightSensor; int oldBatteryPcnt = 0; MyMessage msgTemp(CHILD_ID_TEMP1,V_TEMP); 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(void) { // 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); //Serial.begin(9600); // start serial port Serial.print("Locating devices..."); // locate devices on the bus sensors.begin(); // start reading sensor Serial.print("Found "); Serial.print(sensors.getDeviceCount(), DEC); Serial.println(" devices."); Serial.print("Parasite power is: "); // report parasite power requirements if (sensors.isParasitePowerMode()) Serial.println("ON"); else Serial.println("OFF"); // assign address manually. the addresses below will beed to be changed // to valid device addresses on your bus. device address can be retrieved // by using either oneWire.search(deviceAddress) or individually via // sensors.getAddress(deviceAddress, index) //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; // Method 1: // search for devices on the bus and assign based on an index. ideally, // you would do this to initially discover addresses on the bus and then // use those addresses and manually assign them (see above) once you know // the devices on your bus (and assuming they don't change). if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); // method 2: search() // search() looks for the next device. Returns 1 if a new address has been // returned. A zero might mean that the bus is shorted, there are no devices, // or you have already retrieved all of them. It might be a good idea to // check the CRC to make sure you didn't get garbage. The order is // deterministic. You will always get the same devices in the same order // // Must be called before search() //oneWire.reset_search(); // assigns the first address found to insideThermometer //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer"); // show the addresses we found on the bus Serial.print("Device 0 Address: "); printAddress(insideThermometer); Serial.println(); // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions) sensors.setResolution(insideThermometer, 9); Serial.print("Device 0 Resolution: "); Serial.print(sensors.getResolution(insideThermometer), DEC); Serial.println(); } // function to print the temperature for a device void printTemperature(DeviceAddress deviceAddress) { // method 1 - slower //Serial.print("Temp C: "); //Serial.print(sensors.getTempC(deviceAddress)); //Serial.print(" Temp F: "); //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit // method 2 - faster float tempC = sensors.getTempC(deviceAddress); Serial.print("Temp C: "); Serial.print(tempC); Serial.print(" Temp F: "); Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit } void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); // It responds almost immediately. Let's print out the data printTemperature(insideThermometer); // Use a simple function to print out the data { // 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); }} // function to print a device address void printAddress(DeviceAddress deviceAddress) { for (uint8_t i = 0; i < 8; i++) { if (deviceAddress[i] < 16) Serial.print("0"); Serial.print(deviceAddress[i], HEX); } }
-
RE: š¬ Temperature Sensor
I sofar got the sketch running and giving good data on serial and into domoticz
i only could use some help with how to sent my Temperature in Celsius to domoticz to
i tried to use:
send(msgTemp.set(insideThermometer ,2));
and
send(msgTemp.set(tempC,2));both without luck, the first did transmit some data but wrong numbers
second did nothing think because with this i done i does not know what address the DS1820 is on.Im learning every day something new....
Maybe someone could help,
-
RE: š¬ Temperature Sensor
could you explain how to solve this ?
I'm no pro, and wanted to use 1 single DS1820 in a sketch and also got same message about :
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());Mysensors is hard hard nut to learn, specially because of a lot of changes in the newer version 2.1.0 ...(and im still learning to work with arduino software , i keep running often against old sketches i like to try as sample to use them in other sketches , (my way of learning) but than they dont work with latest version. because something changed.
but i love the mysensors functions.p.s sorry for my bad english....
-
RE: Need a bid of help...
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.
-
RE: Need a bid of help...
@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
-
RE: Need a bid of help...
Do you have a sample or could you help me starting with the sketch i already have ?
-
RE: Need a bid of help...
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...
-
RE: Need a bid of help...
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); }```
-
RE: Need a bid of help...
What are the read command for an bme280
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure= bme.readPressure()
? -
RE: Need a bid of help...
@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
-
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); }```
-
RE: reporting battery to domoticZ
Im feeding the 5v pin with 5.14 volt coming from the dc-dc output not the vin
-
RE: reporting battery to domoticZ
Hi Awi i will build someday if i got it working this project on a pro-mini,.
im not measuring the voltage on the dc-dc booster but on the battery side feeding the converter.
I need this booster because i also feeding my DHT with 5 volt and in future other sensors.BH1750, BMP180, Soil moisture sensor
and im charging my battery in the future with an 6 volt solar panel.
So to see this is working during day time i should be able to read the charging voltage of 4.2 volt and during the night the voltage of battery dropping -
RE: reporting battery to domoticZ
Last reading from multimeter battery voltage 4.204 volt now i measure A0 1,104 > gnd
-
RE: reporting battery to domoticZ
vref: 4.20 V sensorValue: 949 bit 219143 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.89 Battery voltage: 3.89 V 219151 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:48 Battery percent: 48 % 219158 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 219164 MCO:SLP:TPD 219166 MCO:SLP:WUP=-1 221699 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:35.2 H: 35.20 vref: 4.20 V sensorValue: 951 bit 222708 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.90 Battery voltage: 3.90 V 222717 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:50 Battery percent: 50 % 222724 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 222731 MCO:SLP:TPD 222733 MCO:SLP:WUP=-1 225242 TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:20.6 T: 20.60 225251 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:34.5 H: 34.50 vref: 4.20 V sensorValue: 955 bit 226260 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.92 Battery voltage: 3.92 V 226269 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:52 Battery percent: 52 % 226276 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 226282 MCO:SLP:TPD
-
RE: reporting battery to domoticZ
@Rene046 said in reporting battery to domoticZ:
What can i do to get a more stable reading now the voltage goes from 3.80 to 4.20 while feeding with an 4.20 volt
It seems like when the nano starts reading the voltage drops a bid.
-
RE: reporting battery to domoticZ
What can i do to get a more stable reading now the voltage goes from 3.80 to 4.20 while feeding with an 4.20 volt
-
RE: reporting battery to domoticZ
Hi im using at this moment what i had.
270k-100k giving me 1.07 volt at 4.2 batterySo i stay save , but ok reading is not giving my wanted 4.2 volt but around 3.92 volt
My nano is feeded by an dc -dc boost converter giving me 5 volt from this 4.2 battery.
@AWI
Sorry im still a noob in this, just understood how to make a voltage diver using 3:1 divider
.
Could you please give me a simple example how do this calculation. -
RE: reporting battery to domoticZ
Thanks that looks way better.
I just changed
const float vRef = 4.2/ 1.1 ;
into
const float vRef = 4.2/ 1.07 ;
because this is what i measure with my multimeter with 4.2 volt battery and measuring my voltage divider i have 1.07 volt
.
Giving me strange results something must be bad ..... my multimeter ?? it should be closer to 4.2 ? i guessBattery voltage: 3.92 V 14842 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:53 Battery percent: 53 % 14850 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 14856 MCO:SLP:TPD 14858 MCO:SLP:WUP=-1 17367 TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:19.4 T: 19.40 17376 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:48.5 H: 48.50 17885 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.92 Battery voltage: 3.92 V 17893 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:53 Battery percent: 53 % 17900 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 17906 MCO:SLP:TPD```
-
RE: reporting battery to domoticZ
@Rene046 said in reporting battery to domoticZ:
my serial monitor is now making a bit more cense voltage is about 0,10 volt off
but maybe i do something wrong with calculation.
percentage is still something wrong withim feeding with 3.60 volts at that moment.
-
RE: reporting battery to domoticZ
my serial monitor is now making a bit more cense voltage is about 0,10 volt off
but maybe i do something wrong with calculation.
percentage is still something wrong withby the way i'm not shure with the low voltage of an 16850 lipo at 3.6 volt ...
20412 MCO:SLP:WUP=-1 22921 TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:17.8 T: 17.80 22929 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:35.4 H: 35.40 23939 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.53 Battery voltage: 3.53 V Battery percent: -10 % 23946 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 23954 MCO:SLP:TPD 23955 MCO:SLP:WUP=-1 26465 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:36.1 H: 36.10 27473 TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:3.52 Battery voltage: 3.52 V Battery percent: -12 % 27481 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 27489 MCO:SLP:TPD
and here the latest sketch
// 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 <DHT.h> // Enable debug prints #define MY_DEBUG #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 #define CHILD_ID_BATTERY 4 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "Temp_Hum_Batt" // Change to a fancy name you like #define SKETCH_VERSION "2.1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); //========================= // BATTERY VOLTAGE DIVIDER SETUP // 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 #define VBAT_PER_BITS 0.0041055718475073313782991202346 // 4.20/1023 volt #define VMIN 3.6 // Vmin = 3.6 lipo empty #define VMAX 4.2 // Vmax = 4.2 volt lipo full int batteryPcnt = 0; // Calc value for battery % int batLoop = 0; // Loop to help calc average int batArray[3]; // Array to store value for average calc. int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //========================= void setup() { analogReference(INTERNAL); // For battery sensing delay(500); // Allow time for radio if power used as reset dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); metric = getControllerConfig().isMetric; } void presentation() { // Send the Sketch Version Information to the Gateway // Send the Sketch Version Information to the Gateway sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_BATTERY, S_MULTIMETER); present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void loop() { delay(500); // Allow time for radio if power used as reset delay(dht.getMinimumSamplingPeriod()); // Fetch temperatures from DHT sensor float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } // Fetch humidity from DHT sensor float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } batM(); sleep(SLEEP_TIME); //sleep a bit } void batM() //The battery calculations { delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; send(msgbatt.set(Vbat ,2)); Serial.print("Battery voltage: "); Serial.print(Vbat); Serial.println(" V"); int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); // Add it to array so we get an average of 3 (3x20min) batArray[batLoop] = batteryPcnt; if (batLoop > 2) { batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]); batteryPcnt = batteryPcnt / 3; if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %"); sendBatteryLevel(batteryPcnt); batLoop = 0; } else { batLoop++; } }
-
RE: reporting battery to domoticZ
Hi Awi
Thanks that you want to help,
Im powering it by a lipo battery 1 cell using an dc-dc boost converter to get 5 volts
i would like to see what this lipo is doing during a day. this lipo will be charged by an solar panel 6 volt 300ma still waiting for that panel.You are absolutely right with my voltage divider it's at 1.9 volt while lipo is at 4.2 volt
I'm not a hero in elektronics , just starting to play with it. so to start i should make an voltage divider that gives me aprox 1,1 volt max at 4,2 volt.
I changed the voltages divider now from 270k-100k
giving me 1.07 volt at 4.2 volt lipoi'm totally open for any other design you could give, i just used some code from others that was excepted by demoticz.
If you like you could send me an sample how you would do it or change my sketch ..
today i also received my BMP180 and BH1750 i want to include in the future.. -
RE: reporting battery to domoticZ
I still cant get it to work, No voltage reading or logging.
I there nobody trying to build a equal sensor.maybe someone who could rework my sketch. or having a working sketch where i could delete some sensors from.
kind regards and greetings from the Netherlands.
-
RE: reporting battery to domoticZ
And it seems like instead of real voltage i seen percentage in the log
-
RE: reporting battery to domoticZ
And my serial monitor is going wild .lol
.41815 MCO:SLP:WUP=-1 Battery percent: 95 % Battery Average (Send): -12 % 45359 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=NACK:244 45403 !TSF:MSG:SEND,2-2-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=1,st=NACK:-12.00 45410 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 45415 MCO:SLP:TPD 45417 MCO:SLP:WUP=-1 47962 !TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=2,st=NACK:20.0 T: 20.00 48007 !TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=3,st=NACK:49.6 H: 49.60 Battery percent: -49 % 49014 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 49020 MCO:SLP:TPD 49022 MCO:SLP:WUP=-1 51567 !TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=4,st=NACK:49.2 H: 49.20 Battery percent: -26 % 52575 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 52582 MCO:SLP:TPD
-
RE: reporting battery to domoticZ
thx i got a voltage log only giving me now -44.000 volt and 212 prct at battery level while measuring 3.7 volt battery and voltage on A0 1.3 volts
.// 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 <DHT.h> // Enable debug prints #define MY_DEBUG #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 #define CHILD_ID_BATTERY 4 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "Temp_Hum_Batt" // Change to a fancy name you like #define SKETCH_VERSION "2.1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); //========================= // BATTERY VOLTAGE DIVIDER SETUP // 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 #define VBAT_PER_BITS 0.0041055718475073313782991202346 // 4.20/1023 volt #define VMIN 3.6 // Vmin = 3.6 lipo empty #define VMAX 4.2 // Vmax = 4.2 volt lipo full int batteryPcnt = 0; // Calc value for battery % int batLoop = 0; // Loop to help calc average int batArray[3]; // Array to store value for average calc. int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //========================= void setup() { analogReference(INTERNAL); // For battery sensing delay(500); // Allow time for radio if power used as reset dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); metric = getControllerConfig().isMetric; } void presentation() { // Send the Sketch Version Information to the Gateway // Send the Sketch Version Information to the Gateway sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_BATTERY, S_MULTIMETER); present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void loop() { delay(500); // Allow time for radio if power used as reset delay(dht.getMinimumSamplingPeriod()); // Fetch temperatures from DHT sensor float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } // Fetch humidity from DHT sensor float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } batM(); sleep(SLEEP_TIME); //sleep a bit } void batM() //The battery calculations { delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); // Add it to array so we get an average of 3 (3x20min) batArray[batLoop] = batteryPcnt; if (batLoop > 2) { batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]); batteryPcnt = batteryPcnt / 3; if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %"); sendBatteryLevel(batteryPcnt); send(msgbatt.set(batteryPcnt ,2)); batLoop = 0; } else { batLoop++; } }```
-
RE: reporting battery to domoticZ
O i forget to tell im running the latest gateway from Mysensor.
-
RE: reporting battery to domoticZ
@ fhenryco
Cant get it to work, if you have time could help with my sketch.
// 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 <DHT.h> // Enable debug prints #define MY_DEBUG #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 #define CHILD_ID_BATTERY 4 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "Temp_Hum_Batt" // Change to a fancy name you like #define SKETCH_VERSION "2.1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgbatt(CHILD_ID_BATTERY, V_VOLTAGE); //MyMessage msgbatt(CHILD_ID_BATTERY, V_TEXT); //========================= // BATTERY VOLTAGE DIVIDER SETUP // 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 #define VBAT_PER_BITS 0.0041055718475073313782991202346 #define VMIN 3.6 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 4.2 // Vmax = (2xAA bat)=3.0V (892v) int batteryPcnt = 0; // Calc value for battery % int batLoop = 0; // Loop to help calc average int batArray[3]; // Array to store value for average calc. int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //========================= void setup() { analogReference(INTERNAL); // For battery sensing delay(500); // Allow time for radio if power used as reset dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); metric = getControllerConfig().isMetric; } void presentation() { // Send the Sketch Version Information to the Gateway // Send the Sketch Version Information to the Gateway sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_BATTERY, S_INFO); //present(CHILD_ID_BATTERY, S_CUSTOM); present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); } void loop() { delay(500); // Allow time for radio if power used as reset delay(dht.getMinimumSamplingPeriod()); // Fetch temperatures from DHT sensor float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } // Fetch humidity from DHT sensor float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } batM(); sleep(SLEEP_TIME); //sleep a bit } void batM() //The battery calculations { delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); // Add it to array so we get an average of 3 (3x20min) batArray[batLoop] = batteryPcnt; if (batLoop > 2) { batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]); batteryPcnt = batteryPcnt / 3; if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %"); sendBatteryLevel(batteryPcnt); msgbatt.set(batteryPcnt ,1); batLoop = 0; } else { batLoop++; } }``` My sketch is not working 100% my voltage is not precise, giving me even 221 in percentage while lipo is at this moment 3.7 volt (simulated with a variable power supply) im running it on a nano on 1 lipo cell and a dc dc powerup to 5 volt measuring the lipo voltage with a divider 1M/470K . Hope to add a soil moisture sensor and baro sensor in future. p.s. any one with some better idea sketch its ver welcome. im just started to experiment with Mysensor
-
RE: reporting battery to domoticZ
i would like to ask something to ,
Now i have the battery level showing up in Domoticz what can i do to log the voltage in volts, should i add something inside the sketch or something in domoticz..
-
RE: š¬ Soil Moisture Sensor
Dous this sketch belong to this sensor ? pin 6,7 and a1 or a0 are not connected.....
-
RE: Could use a bid help to get started
Thanks Mikael,
could i find those new commands somewhere
-
RE: Could use a bid help to get started
can i ask another question....
Im trying to add a battery sense pin to the sketch. they use gw. commands, are those also changed in the new version ?they are not recognized....
They serail monitor shows me the voltage but how do i send it as and child to domoticz.
-
RE: Could use a bid help to get started
ok,
At least i can now experiment with other sensors for my weather station project.
i now all electronics are working, i saved this sketch and commented those changes.
Again thank you for getting me started. -
RE: Could use a bid help to get started
thanks it works... i love you ..lol
why do they change basic commands.... this make it hard to use.......
Like this command and why make from mysensor.h mysensors.h.
i also looked inside domoticz and i got data
thank you very very much
-
RE: Could use a bid help to get started
ok now im left with this
H:\WINDOW~1\Temp\arduino_modified_sketch_225110\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()': DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope metric = getConfig().isMetric; ^ exit status 1 'getConfig' was not declared in this scope
-
RE: Could use a bid help to get started
ok done that, opened the sketch sample for dht.
compile and i get :H:\WINDOW~1\Temp\arduino_modified_sketch_660970\DhtTemperatureAndHumiditySensor.ino: In function 'void presentation()': DhtTemperatureAndHumiditySensor:85: error: 'getConfig' was not declared in this scope metric = getConfig().isMetric; ^ Multiple libraries were found for "DHT.h" Used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT Not used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT-sensor-library-master exit status 1 'getConfig' was not declared in this scope
-
RE: Could use a bid help to get started
should i unzip those inside the mysensor map or arduino ?
-
RE: Could use a bid help to get started
All those samples seems to work and compile perfect,
But there is no sample with an DHT sensor temp. and hum included. or do i overlook ?
-
RE: Could use a bid help to get started
jes i installed it like in your link.
Seems my sketch is then from an older version. because it uses Mysensor.h
I also tried changing it to mysensors.h but then allot of things go wrong while compilingMaybe you could point me to a DHT sketch thats up-to-date ? for mysensor version 2.1.1
i installed.Im totally new with mysensor, and now you told me i understand that lots of sketches on internet are old and dont work anymore.
Where can i find info about changes ?i now am trying the sketch of this person
https://forum.mysensors.org/topic/3774/multiple-dht22-in-one-sensor-for-greenhouse-newbee-question/5but he also seems to use old version, i see again mysensor.h instead of mysensors.h
hope for an answer....
-
RE: Could use a bid help to get started
Hi,
What i see also often is that Mysensor.h is used in a lot of sketches
and cant be found by Arduino's ide.WARNING: Spurious .mystools folder in 'MySensors' library
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino:2:22: fatal error: MySensor.h: No such file or directoryi am afraid i have done something verry wrong that nothing seems to be working here.
Installed arduino ide many times removed library's many time's but still no sketch with Mysensor works here.
Please please help
-
RE: Could use a bid help to get started
this is the sketch :
/**- The MySensors Arduino library handles the wireless radio link and protocol
- between your home built sensors/actuators and HA controller of choice.
- The sensors forms a self healing radio network with optional repeaters. Each
- repeater and gateway builds a routing tables in EEPROM which keeps track of the
- network topology allowing messages to be routed to nodes.
- Created by Henrik Ekblad henrik.ekblad@mysensors.org
- Copyright (C) 2013-2015 Sensnology AB
- Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
- Documentation: http://www.mysensors.org
- Support Forum: http://forum.mysensors.org
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
- REVISION HISTORY
- Version 1.0: Henrik EKblad
- Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz)
- DESCRIPTION
- This sketch provides an example of how to implement a humidity/temperature
- sensor using a DHT11/DHT-22.
- For more information, please visit:
- http://www.mysensors.org/build/humidity
*/
// Enable debug prints
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>// Set this to the pin you connected the DHT's data pin to
#define DHT_DATA_PIN 2// Set this offset if the sensor has a permanent small offset to the real temperatures
#define SENSOR_TEMP_OFFSET 0// Sleep time between sensor updates (in milliseconds)
// Must be >1000ms for DHT22 and >2000ms for DHT11
static const uint64_t UPDATE_INTERVAL = 60000;// Force sending an update of the temperature after n sensor reads, so a controller showing the
// timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
// the value didn't change since;
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
static const uint8_t FORCE_UPDATE_N_READS = 10;#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("TemperatureAndHumidity", "1.1");// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);metric = getConfig().isMetric;
}void setup()
{
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
}
// Sleep for the time of the minimum sampling period to give the sensor time to power up
// (otherwise, timeout errors might occure for the first reading)
sleep(dht.getMinimumSamplingPeriod());
}void loop()
{
// Force reading sensor, so it works also after sleep()
dht.readSensor(true);// Get temperature from DHT library
float temperature = dht.getTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT!");
} else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
// Only send temperature if it changed since the last measurement or if we didn't send an update for n times
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
// Reset no updates counter
nNoUpdatesTemp = 0;
temperature += SENSOR_TEMP_OFFSET;
send(msgTemp.set(temperature, 1));#ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif
} else {
// Increase no update counter if the temperature stayed the same
nNoUpdatesTemp++;
}// Get humidity from DHT library
float humidity = dht.getHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
// Only send humidity if it changed since the last measurement or if we didn't send an update for n times
lastHum = humidity;
// Reset no updates counter
nNoUpdatesHum = 0;
send(msgHum.set(humidity, 1));#ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif
} else {
// Increase no update counter if the humidity stayed the same
nNoUpdatesHum++;
}// Sleep for a while to save energy
sleep(UPDATE_INTERVAL);
} -
RE: Could use a bid help to get started
Thx for you fast answer,
i installed you links library, seems i had to overwrite because i already had those,during compiling i get....
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Rene\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Rene\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10801 -build-path H:\WINDOW~1\Temp\arduino_build_113476 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Rene\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Rene\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10801 -build-path H:\WINDOW~1\Temp\arduino_build_113476 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library" "H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library\DHT.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "H:\WINDOW~1\Temp\arduino_build_113476\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "H:\WINDOW~1\Temp\arduino_build_113476\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0" "-IH:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library" "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp" -o "H:\WINDOW~1\Temp\arduino_build_113476\sketch\DHT22-1.ino.cpp.o"
DHT22-1:73: error: no matching function for call to 'DHT::DHT()'DHT dht;
^
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino:73:5: note: candidates are:
In file included from H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino:44:0:
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:40:4: note: DHT::DHT(uint8_t, uint8_t, uint8_t)
DHT(uint8_t pin, uint8_t type, uint8_t count=6); ^
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:40:4: note: candidate expects 3 arguments, 0 provided
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:38:7: note: constexpr DHT::DHT(const DHT&)
class DHT {
^
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:38:7: note: candidate expects 1 argument, 0 provided
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:38:7: note: constexpr DHT::DHT(DHT&&)
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library/DHT.h:38:7: note: candidate expects 1 argument, 0 provided
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino: In function 'void setup()':
DHT22-1:91: error: 'class DHT' has no member named 'setup'
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
^
DHT22-1:92: error: 'class DHT' has no member named 'getMinimumSamplingPeriod'
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
^
DHT22-1:97: error: 'class DHT' has no member named 'getMinimumSamplingPeriod'
sleep(dht.getMinimumSamplingPeriod());
^
H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\DHT22-1\DHT22-1.ino: In function 'void loop()':
DHT22-1:104: error: 'class DHT' has no member named 'readSensor'
dht.readSensor(true);
^
DHT22-1:107: error: 'class DHT' has no member named 'getTemperature'
float temperature = dht.getTemperature();
^
DHT22-1:114: error: 'class DHT' has no member named 'toFahrenheit'
temperature = dht.toFahrenheit(temperature); ^
DHT22-1:131: error: 'class DHT' has no member named 'getHumidity'
float humidity = dht.getHumidity();
^
Multiple libraries were found for "DHT.h"
Used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library
Not used: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT-sensor-library-master
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library MySensors-2.0.0 at version 2.0.0 in folder: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\MySensors-2.0.0
Using library DHT_sensor_library at version 1.2.3 in folder: H:\WINDOWS GEBRUIKERS\MIJN_DOCUMENTEN\Arduino\libraries\DHT_sensor_library
exit status 1
no matching function for call to 'DHT::DHT()' -
Could use a bid help to get started
Hi there,
Today i started with MySensor,
I installed Domoticz on an arduino.
I made MySensor gateway that runs on Domoticz Gateway Version: 2.1.0
then i took a nano and installed a DHT11 took a sample code and i can read in serial monitor the temperature.
I i am trying by using many sample codes for sending the dht11 data to domoticz
but almost with all sample codes i get messages
about :exit status 1
no matching function for call to 'DHT::DHT()'or that the code is not for the nano.
Is there one simple working sample so i can test if i can sent a bid of data into domoticz.
im getting crazy because simple code can be written into my nano but stuff related to my sensor ... i get all kinds of problems..
Sorry for my bad english im a Dutch guy.
Kind Regards Rene.
p.s. i hope once to get a weather station running with more sensors, but would be glad to get 1 thing working