that quite likely a good idea... as its outside i could even drop a solar panel on it... as in this situation with 1 read every second (give take) the node wont get a a chance to sleep at all as i would be sending back to the gateway constantly...
Posts made by markjgabb
-
RE: Electric fence tester
-
Electric fence tester
hi all
after advice on an electric fence sensor node for mysensorsso I have a small 5KV Electric fence energizer which sends pulses of 5KV down the line in 1-2 second pulses
I'm trying to work out how to monitor it..
Ideally id love it to be self powered, but I'm tipping that's out of the questions, as the capacitor requirement I think would be huge to stop overloading....so my two options I thought of were either a voltage divider (Research shows this probably wont work)
or a hall effect current sensor, but I've never worked with one of these and am unsure of how this one should go.I know my main issue is going to be protecting to Arduino from the raw voltage as it would fry it in seconds.
has anyone worked on a similar project or able to advise on a good place to start?
-
RE: What did you build today (Pictures) ?
thanks to assistance of some of the people here i now have up and running a front gate controller for my double front gates (Solar powered)
now have a node that monitors the batteries, knows if the gate is open or closed and has a relay for activating the gate
-
RE: Gate controller with Battery Checker
Yeah I'm changing up the circuit die to inaccuracy...
Is a arduino nano 5v powered from usb..... -
RE: Gate controller with Battery Checker
Is anyone able to confirm if the calculations in this image are correct? I would need to multiply the result by 6 to get accurate numbers
I'm just currently stuggling with acuracy on my current design and figure bringing the max reading down would help
It's a 24v battery with solar cut off of 28.4v so it will never go over 30 anyway -
RE: Gate controller with Battery Checker
think i have figured it out
adjusted the math based on another page
Vin = (Pin * 5.0) / 1023;removed the factor of 11 stuff and i think it wasn't necessary?
-
RE: Gate controller with Battery Checker
@mfalkvidd you are correct you can do double and it works
-
RE: Gate controller with Battery Checker
now compiles beautifully...
but am getting weird voltage readings... ive just connected a double set of AA batteires and am getting a reading of 11.8-11.9
im using a 100k and a 10k resistor as per this guide.... obviously i stuffed up something in my math....
this always seems to be my way
source for voltage reader code
https://www.codrey.com/arduino-projects/nano-digital-volt-meter/ -
RE: Gate controller with Battery Checker
@mfalkvidd cheers
ive added that instead but still get the following
call of overloaded 'set(float&)' is ambiguous
-
RE: Gate controller with Battery Checker
final bug
when i try to compile the following code
i Get this error
exit status 1
call of overloaded 'set(double&)' is ambiguous googling tells me that my msg need to be defined better for the purpose but im not sure, as i can see in my void that i have declared it as double, but for some reason it doesnt understant that when i go to send my messagevoid batM() { int Pin; // 0-1023 I/P double Vin; Pin = analogRead(A0); // Probe Input Vin = Pin * (5.0*11 / 1023); // Pin to Vin (Reduction Factor 11) Serial.print(Vin); Serial.println(" VOLT DC ");\ send(power.set(Vin)); }
-
RE: Gate controller with Battery Checker
@Yveaux said in Gate controller with Battery Checker:
wait(15601000ul)
champion that works much better thanks
only one bug left now
-
Gate controller with Battery Checker
hi all
below is my code for a gate controller with attached voltage sensor for measuring the battery supply...
it has a relay and a battery checker and that is allim a little confused to how to change the setup so that the batM loop only runs once every 15 mintues without putitng the sensor to sleep,
i figure i cant put the sensor to sleep as it needs to wait to receive messages from the gateway??
anyone able to advise and let me know if my butchered code can be saved?/** 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 - HenryWhite DESCRIPTION Example sketch showing how to control physical relays. This example will remember relay state after power failure. Optional attachment of motion sensor to control the relays is possible. Notes: -- The Child-IDs of the attached relays range from 1 up to (1-(NUMBER_OF_RELAYS)) -- Make sure to adjust the potentiometer for triggertime on your motion sensor as leftmost as possible, because the countdown will not start until the motion sensor reports back a "0" (no movement) */ //----------------------- Library Configuration --------------------- #define MY_DEBUG // uncomment to enable debug prints to serial monitor #define MY_REPEATER_FEATURE // uncomment to enable repeater functionality for this node // Enable and uncomment attached radio type #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 //#define MY_TRANSPORT_WAIT_READY_MS 1 // uncomment this to enter the loop() and setup()-function even when the node cannot be registered to gw #define NUMBER_OF_RELAYS 1 // Total number of attached relays. Must be equal to total number of elements in array below! const int RELAYS[] = {2}; // digital pins of attached relays const long ON_TIMES[] = {0}; // Specify for each element in MOTION_ACTIVATED_RELAYS, how long the specified relay should be active in seconds. #define RELAY_ON 0 // GPIO value to write to turn on attached relay #define RELAY_OFF 1 // GPIO value to write to turn off attached relay bool ack = 1; // set this to 1 if you want destination node to send ack back to this node #define CHILD_ID_RELAY 1 #define CHILD_ID_VOLTAGE 2 #include <MySensors.h> #include "Wire.h" MyMessage relay_msg; MyMessage power(CHILD_ID_VOLTAGE,V_VOLTAGE); void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Gate button", "1.0"); present(CHILD_ID_RELAY, S_BINARY); present(CHILD_ID_VOLTAGE, S_MULTIMETER); } void loop() { batM(); } void receive(const MyMessage &message) { // Handle incoming relay commands if (message.type == V_STATUS) { // Change relay state if (RELAYS[message.sensor - 1]) { digitalWrite(RELAYS[message.sensor - 1], message.getBool() ? RELAY_ON : RELAY_OFF); // Store state in eeprom saveState(message.sensor - 1, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } } void relay_msg_constructor(int sensor, uint8_t type) { relay_msg.setSensor(sensor); relay_msg.setType(type); } void batM() { int Pin; // 0-1023 I/P double Vin; Pin = analogRead(A0); // Probe Input Vin = Pin * (5.0*11 / 1023); // Pin to Vin (Reduction Factor 11) Serial.print(Vin); Serial.println(" VOLT DC ");\ send(power); }
-
RE: fails to wake with 2 interupts
thanks guys, ill add it to my code tonight and see how it goes
-
fails to wake with 2 interupts
hi all im having issue with the follow code...
i have two devices on pin 2 and 3 on a pro mini but cant seem to get wake working one both...
is anyone able to hint/advise on have gone wrong?/* * 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-2019 Sensnology AB * Full contributor list: https://github.com/mysensors/MySensors/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_RF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #include <SPI.h> #define COMPARE_TEMP 0 #define MAX_ATTACHED_DS18B20 1 #define DOOR_PIN 3 #define ONE_WIRE_BUS 5 // Pin where dallase sensor is connected OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=1; bool receivedConfig = false; bool metric = true; uint32_t SLEEP_TIME = 900000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID_MOTION 1 // Id of the sensor child #define CHILD_ID_TEMP 2 #define CHILD_ID_DOOR 3 // Initialize motion message MyMessage motion(CHILD_ID_MOTION, V_TRIPPED); MyMessage temp(CHILD_ID_TEMP,V_TEMP); MyMessage door(CHILD_ID_DOOR,V_TRIPPED); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 before() { // Startup up the OneWire library sensors.begin(); } void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input pinMode(DOOR_PIN, INPUT); // Activate internal pull-up digitalWrite(DOOR_PIN, HIGH); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Front Hall Motion&temp", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_MOTION, S_MOTION); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_DOOR, S_DOOR); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.print("Montion Sensor State: "); Serial.println(tripped); send(motion.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. bool trippeddoor = digitalRead(DOOR_PIN) == HIGH; Serial.print("Door Sensor State: "); Serial.println(trippeddoor); send(door.set(trippeddoor?"1":"0")); // Send tripped value to gw sensors.requestTemperatures(); Serial.print("Temprature: "); Serial.println(sensors.getTempCByIndex(0)); // query conversion time and sleep until conversion completed // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) wait(500); // Read temperatures and send them to controller // Fetch and round temperature to one decimal float temperature = sensors.getTempCByIndex(0); // Send in the new temperature send(temp.setSensor(1).set(temperature,1)); // Save new temperatures for next compare batM(); delay(500); sleep(3000); sleep(DIGITAL_INPUT_SENSOR,CHANGE,DOOR_PIN,CHANGE,SLEEP_TIME); } 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); batLoop = 0; } else { batLoop++; } }
-
RE: temp sensor not reading at all
God I'm an idiot. Must of picked up the wrong resistor.
10k resistor won't help me much
-
RE: temp sensor not reading at all
ok think i have partially found the issue, when i re did it for a simpler setup, it seems that im measureing temprature of -127 im not even sure what the means, i assume its an error but not sure what its telling me
-
temp sensor not reading at all
hey guys
ive tried to modify two of the built in designs to make them work together, but i think ive stuffed up the dallas temprature probethe temprature is never updated or sent to the controller
anyone able to advise what ive missed?
i only have the one temprature sensor hooked up// Enable debug prints //#define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #define COMPARE_TEMP 1 #define MAX_ATTACHED_DS18B20 16 #define LIGHT_SENSOR_ANALOG_PIN 0 #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; bool receivedConfig = false; bool metric = true; unsigned long SLEEP_TIME = 120000 ; // 120000 Sleep time between reports (in milliseconds) int lastLightLevel; #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 // Enable repeater functionality for this node //#define MY_REPEATER_FEATURE // Initialize motion message MyMessage temp(CHILD_ID_TEMP,V_TEMP); MyMessage light(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 before() { // Startup up the OneWire library sensors.begin(); } void setup() { sensors.setWaitForConversion(false); numSensors = sensors.getDeviceCount(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Lounge Node enviroment", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); present(CHILD_ID_TEMP, S_TEMP); } void loop() { //light sensor int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.print("Light Level:"); Serial.println(lightLevel); if (lightLevel != lastLightLevel) { send(light.set(lightLevel)); lastLightLevel = lightLevel; //temprature sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(temp.setSensor(i).set(temperature,1)); // Save new temperatures for next compare lastTemperature[i]=temperature; } } batM(); // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(SLEEP_TIME); } } 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); batLoop = 0; } else { batLoop++; } }
-
RE: NRF24L01+ and NRF24L01+PA-LNA problems - testing in progress
@wiredfrank 100% agree. Dodgy antennas have been the bane of my existence with mysensors. When needing the long range. DO. NOT. CHEAP. OUT.
-
RE: Simple irrigation controller
hey @Tmaster
are you still using this solution?
have you made any improvements or come across any issues with using it over time? -
RE: Works perfectly untill i introduce sleep
additional note my button is connected between GND and D3 with 470k resistor in the middle
-
Works perfectly untill i introduce sleep
Hi all
thanks for all previous help with this node, im only 1 step away now from getting it to work
the sketch works perfectly untill i introduce the sleep till interupt.....as soon i uncomment the line for sleep the node starts up then goes to sleep and never wakes up again... and advice is appreciated
LOG
__ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.1 16 MCO:BGN:INIT NODE,CP=RNNNA---,REL=255,VER=2.3.1 28 TSM:INIT 28 TSF:WUR:MS=0 34 TSM:INIT:TSP OK 36 TSF:SID:OK,ID=4 38 TSM:FPAR 75 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 110 TSF:MSG:READ,1-1-4,s=255,c=3,t=8,pt=1,l=1,sg=0:1 116 TSF:MSG:FPAR OK,ID=1,D=2 2084 TSM:FPAR:OK 2084 TSM:ID 2086 TSM:ID:OK 2088 TSM:UPL 2093 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2127 TSF:MSG:READ,0-1-4,s=255,c=3,t=25,pt=1,l=1,sg=0:2 2134 TSF:MSG:PONG RECV,HP=2 2138 TSM:UPL:OK 2138 TSM:READY:ID=4,PAR=1,DIS=2 2144 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 2170 TSF:MSG:READ,0-1-4,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 2201 TSF:MSG:SEND,4-4-1-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1 2226 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:1 2260 TSF:MSG:READ,0-1-4,s=255,c=3,t=6,pt=0,l=1,sg=0:M 2299 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Lounge Multi 2326 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:3.0 2435 TSF:MSG:SEND,4-4-1-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK: 2443 MCO:REG:REQ 2449 TSF:MSG:SEND,4-4-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 2478 TSF:MSG:READ,0-1-4,s=255,c=3,t=27,pt=1,l=1,sg=0:1 2484 MCO:PIM:NODE REG=1 2486 MCO:BGN:STP 2488 MCO:BGN:INIT OK,TSP=1 2496 TSF:MSG:SEND,4-4-1-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0 2504 MCO:SLP:MS=0,SMS=0,I1=3,M1=1,I2=255,M2=255 2508 TSF:TDI:TSL
Code:
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <Bounce2.h> #define CHILD_ID 1 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch Bounce debouncer = Bounce(); int oldValue=-1; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_LIGHT); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); } void presentation() { // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. sendSketchInfo("Lounge Multi", "3.0"); wait(100); present(CHILD_ID, S_LIGHT); } // Check if digital input has changed and send in new value void loop() { debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value send(msg.set(value==HIGH ? 1 : 0)); oldValue = value; } // batM(); sleep(BUTTON_PIN, CHANGE, 0); } 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); batLoop = 0; } else { batLoop++; } }
-
RE: example of using sleep
@Yveaux
Cheers that's perfect.... unfortunately my FTDI programmer broke last night so now i have to wait for a new one to arrive so that i can do some more work on it -
RE: example of using sleep
hey @Yveaux
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <Bounce2.h> #define CHILD_ID 1 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch Bounce debouncer = Bounce(); int oldValue=-1; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_LIGHT); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); } void presentation() { // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. sendSketchInfo("Lounge Multi", "3.0"); wait(100); present(CHILD_ID, S_LIGHT); } // Check if digital input has changed and send in new value void loop() { debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value send(msg.set(value==HIGH ? 1 : 0)); oldValue = value; } batM(); sleep(int BUTTON_PIN, int CHANGE, unsigned long ms=0); } 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); batLoop = 0; } else { batLoop++; } }
-
example of using sleep
Hi all
I know this has probably been addressed before but i cant seem to find any examples of eactly how sleep should be used in this situation
my snippet is as below
sleep(int BUTTON_PIN, int CHANGE, unsigned long ms=0);
im guessing i have my syntax wrong, but cant find any good examples
i keep getting the following error
expected primary-expression before 'int'
basicly i just want the node to sleep forever untill the button is pressed... i know ive got something wrong, but i cant find any examples in the forum that use this verity of sleep
-
RE: only wake on interupt..
@zboblamont
haha ok so i went right back to the begining of what you said and got it working now (code below)cut back all unneccicary steps and really locked down what was going on... i can always add back battery part later
however now when it comes back online after 5 minutes for heart beat it keep sending a switch command to domoticz...
im guessing this is due to the issue where the state is being reported differently after it going to sleep as soon as action is performed....
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child #include <MySensors.h> unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds) // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { sendSketchInfo("Lounge Multi", "3.0"); wait(100); present(CHILD_ID, S_DOOR); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR); //Software debounce..... //wait(25); //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR); //if (tripped == tripped1){} //send(msg.set(tripped?"1":"0"),true); // Send tripped value to gw if (tripped == HIGH){ send(msg.set(tripped = 1),true); } else if (tripped == LOW){ send(msg.set(tripped = 0),true); } // Sleep until interrupt on motion sensor. Send update every ten minutes. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }
-
RE: only wake on interupt..
yeah i possibly havent been ecactly clear on that
Scenario is that when i walk into a room i dont always want to ask google to turn on or off all the lights in the room.
so i plan on having wall mounted momentary switches, which their sole purpose is to if the lights are on, turn them off and if they are off turn them on....so i had planned to use a momentary switch so that no one in the house became focused on if they were off or on, but just push them to get the opposite of current state
In domoticz i was going to use a push on button with a dzvents script so that any time the push on on button became on it would toggle the opposite of whatever the state of lights in the room in...
obviously a bit more logic is needed in case some lights are on and others off....
As per advice i have shortened off the times for delays and have taken out the serial prints on the battery monitor
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child #include <MySensors.h> unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds) //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 //========================= // Initialize motion message MyMessage msg(CHILD_ID, V_LIGHT); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input analogReference(INTERNAL); } void presentation() { sendSketchInfo("Lounge multi button", "1.1"); wait(100); present(CHILD_ID, S_LIGHT, "Lounge Light Switch", true); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR); //Software debounce..... //wait(25); //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR); //if (tripped == tripped1){} //send(msg.set(tripped?"1":"0"),true); // Send tripped value to gw if (tripped == HIGH){ send(msg.set(tripped = 1),true); wait(100); send(msg.set(tripped = 0),true); } batM(); // Sleep until interrupt on motion sensor. Send update every ten minutes. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); } void batM() //The battery calculations { delay(5); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(5); // 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); batLoop = 0; } else { batLoop++; } }
-
RE: only wake on interupt..
ok stuck now...
it works once...
it wakes up each time and send the command
but in domoticz im using a push on button with a off delay.....
domoticz is ignoring the sensor after the first on, because the sensor isnt available anymore to receive the command....do i possibly need the sensor to send an on command, wait a moment then send its own off command again?
-
RE: only wake on interupt..
Perfect. Tha is for that works great... Interesting thought though with how sensitive it is...
I was actually just waving my hand near it. Possibly 2-3 inches away from the wires....
Could be used as something like a plate you slap with your hand
-
RE: only wake on interupt..
ok so yeah it does work....but i think its too sensitive
i used d2 in the end for the board im using
but the node seems to trigger every time i even wave my hand near it....
Literally, node is currently setup with two wires you have to touch together to make the switch. when i wave my hand over it it activates
im guesing i need to put a resister in place to decrease the sensitivity? currently its just a wire between 3.3 on a pro mini and the d2 wirelog parse is below
133795 MCO:SLP:WUP=0 133797 TSF:TRI:TSB 133804 TSF:MSG:READ,0-0-4,s=1,c=1,t=2,pt=1,l=1,sg=0:1 133810 TSF:MSG:ACK 133816 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0 __ __ ____ | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ |___/ 2.3.1 16 MCO:BGN:INIT NODE,CP=RNNNA---,REL=255,VER=2.3.1 28 TSM:INIT 28 TSF:WUR:MS=0 34 TSM:INIT:TSP OK 36 TSF:SID:OK,ID=4 38 TSM:FPAR 75 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 1064 TSF:MSG:READ,0-0-4,s=255,c=3,t=8,pt=1,l=1,sg=0:0 1071 TSF:MSG:FPAR OK,ID=0,D=1 1120 TSF:MSG:READ,1-1-4,s=255,c=3,t=8,pt=1,l=1,sg=0:1 2084 TSM:FPAR:OK 2084 TSM:ID 2086 TSM:ID:OK 2088 TSM:UPL 2093 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2103 TSF:MSG:READ,0-0-4,s=255,c=3,t=25,pt=1,l=1,sg=0:1 2109 TSF:MSG:PONG RECV,HP=1 2113 TSM:UPL:OK 2115 TSM:READY:ID=4,PAR=0,DIS=1 2129 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 2138 TSF:MSG:READ,0-0-4,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 2164 TSF:MSG:SEND,4-4-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1 2174 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 2189 TSF:MSG:READ,0-0-4,s=255,c=3,t=6,pt=0,l=1,sg=0:M 2238 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=NACK:Lounge multi button 2285 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=1,st=NACK:1.1 2439 !TSF:MSG:SEND,4-4-0-0,s=1,c=0,t=3,pt=0,l=19,sg=0,ft=2,st=NACK:Lounge Light Switch 2447 MCO:REG:REQ 2469 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=3,st=OK:2 2478 TSF:MSG:READ,0-0-4,s=255,c=3,t=27,pt=1,l=1,sg=0:1 2484 MCO:PIM:NODE REG=1 2486 MCO:BGN:STP 2488 MCO:BGN:INIT OK,TSP=1 2496 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1 Battery percent: 100 % 3504 MCO:SLP:MS=298000,SMS=0,I1=0,M1=1,I2=255,M2=255 3510 TSF:TDI:TSL 3512 MCO:SLP:WUP=0 3514 TSF:TRI:TSB 3520 TSF:MSG:READ,0-0-4,s=1,c=1,t=2,pt=1,l=1,sg=0:1 3526 TSF:MSG:ACK 3563 !TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=NACK:0 Battery percent: 121 % 4573 MCO:SLP:MS=298000,SMS=0,I1=0,M1=1,I2=255,M2=255 4579 TSF:TDI:TSL 4581 MCO:SLP:WUP=0 4583 TSF:TRI:TSB 4612 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=1,st=OK:1 Battery percent: 121 % 5621 MCO:SLP:MS=298000,SMS=0,I1=0,M1=1,I2=255,M2=255 5627 TSF:TDI:TSL 5629 MCO:SLP:WUP=0 5632 TSF:TRI:TSB 5638 TSF:MSG:READ,0-0-4,s=1,c=1,t=2,pt=1,l=1,sg=0:1 5644 TSF:MSG:ACK 5662 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1 Battery percent: 121 % Battery Average (Send): 100 % 6678 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:100 6684 MCO:SLP:MS=298000,SMS=0,I1=0,M1=1,I2=255,M2=255 6690 TSF:TDI:TSL
-
RE: only wake on interupt..
ok thanks for that
so i have modifed as the following....
by the look of the alteration,
i can just put a momentary switch in place between vcc and D3 with a resistor in line and be done with it?
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child #include <MySensors.h> unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds) //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 //========================= // Initialize motion message MyMessage msg(CHILD_ID, V_LIGHT); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input analogReference(INTERNAL); } void presentation() { sendSketchInfo("Lounge multi button", "1.0"); wait(100); present(CHILD_ID, S_LIGHT, "Lounge Light Switch", true); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR); //Software debounce..... //wait(25); //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR); //if (tripped == tripped1){} //send(msg.set(tripped?"1":"0"),true); // Send tripped value to gw if (tripped == HIGH){ send(msg.set(tripped = 0),true); } else if (tripped == LOW){ send(msg.set(tripped = 1),true); } batM(); // Sleep until interrupt on motion sensor. Send update every ten minutes. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); } 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); batLoop = 0; } else { batLoop++; } }
-
only wake on interupt..
Been a while
getting back into the swing of things finally after a few year hiatus ive started building up my nodes again..
so something simple to get me back in the swing..
Im building a sensor that is literally just a momentary button
should only wake on interrupt....
but i cant for the life of me work out/remember how to get it working in practice.
sensor will be built on easy newbie PCB/** * 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. * ******************************* * * DESCRIPTION * * Simple binary switch example * Connect button or door/window reed switch between * digitial I/O pin 3 (BUTTON_PIN below) and GND. * http://www.mysensors.org/build/binary */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <Bounce2.h> #define CHILD_ID 3 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch unsigned long SLEEP_TIME = 120000; Bounce debouncer = Bounce(); int oldValue=-1; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_LIGHT); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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() { // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); analogReference(INTERNAL); // For battery sensing delay(500); // Allow time for radio if power used as reset } void presentation() { // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(CHILD_ID, S_LIGHT); } // Check if digital input has changed and send in new value void loop() { debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value send(msg.set(value==HIGH ? 1 : 0)); oldValue = value; } 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); batLoop = 0; } else { batLoop++; } }
Long Term goal is to create using a 3D printers a cover for my existing light switches to put over the top as a toggle so if lights are on turn them off if they are off turn them on, but to have it in a case that is easy to remove incase i have issues, and can get back to the untouched orgiginal light switches underneath
-
RE: 💬 Easy/Newbie PCB for MySensors
@mfalkvidd ahhhhh That answers my question perfectly....i was just dumping it into notepad ++ ill try that first thing in the morning.
-
RE: 💬 Easy/Newbie PCB for MySensors
@mfalkvidd yeh i guess so, not quite what i was after the orignal in that version had some good pictures and such of what went where on the board....do doubt i can work it out from an old dead one i have lying around, was just hoping for a nice visual guide to get me back into it.
-
RE: 💬 Easy/Newbie PCB for MySensors
Does anyone know where we can find the write ups for old revisions? i have a bunch of Rev9 boards that, now that i have restarted these projects after a year break i cant remember the write ups for them....
-
RE: 💬 Easy/Newbie PCB for MySensors
on the subject of batteries i have to say im really impressed with the setup of these boards....
ive got a DHT and lux resistor measuring every 10 minutes, and i cant even remember how long ago i last changed the batteries...i think its about 3-4 months now....nothing special, just aldi batteries (australian cheap shopping chain)last check they are still 65%
-
RE: 💬 Easy/Newbie PCB for MySensors
@dbemowsk cheers mate, thats awesome...now i can blitz out some room based designs
-
RE: 💬 Easy/Newbie PCB for MySensors
@dbemowsk cheers for that...yeah i have a tonn of old 5v bricks lying around from old nokia chargers, so was just going to try use some of them up without having to buy anythiing else, as i have all of it on hand.... i have some LE33a's which should take care of any step down issues i think?
-
RE: 💬 Easy/Newbie PCB for MySensors
ahhh thats cool... so use regulated instead and it will pull down the voltage for antenna over that side
...and the board can handle the voltage anyway so it should be fine.... -
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84 interesting question...or maybe stupid question not sure...
i have a tonn of 3v pro mini's but im thinking of mains powering some for motion sensors.... would i set it up as battery, and then just use a voltage regulator on where the step up usually would be? or is there a better way to handle it?
-
RE: loungeroom sketch transport failure
@sundberg84 solved the light sensitivity level by swapping the 10k for a 100k...
makes it more acurate in lighter enviroments, but less so in dark enviromentsbut by my theory after its a little dim im counting it as dark all the way to full dark for lighting purposes anyway
cheers for all your help....
-
RE: loungeroom sketch transport failure
just a single photoresistor,
i just wasnt sure if there was a way to reverse map the numbers so that if it says 1 it sends 99 -
RE: loungeroom sketch transport failure
photo resistor is now working...domoticz is showing varied amounts of reading though the night and morning....
but its back to front....its reads 90ish in the middle of the night and this morning fluxuated between 50-10 and is now sitting at 30 with an empty house......did i math backwards? or is this expected behaviour due to the way the resistance works?
in domoticz would i just use low values as my brightness
-
RE: loungeroom sketch transport failure
ok raw lux is 15
good point...ive used a 47k resistor instead of a 470k, ill change that in the morning
Raw Lux: 15
send Lux: 0obviously a sensor error, ive moved the photo resistor into diffrent light like 4 times, and no change in reading
-
RE: loungeroom sketch transport failure
7778 MCO:SLP:WUP=-1 9306 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:20.0 T: 20.00 9316 TSF:MSG:SEND,3-3-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:18.0 H: 18.00 0 Battery percent: -89 % 10326 MCO:SLP:MS=120000,SMS=0,I1=255,M1=255,I2=255,M2=255 10332 MCO:SLP:TPD
this is my current log....
so temp and hum is wrking...but my lux level keeps coming back 0 i think thats what its saying....can i insert more logging on that one to see how its doing the math?
-
RE: loungeroom sketch transport failure
its battery powered, i have the jumpers, i just got registration on node....but not all sensors are sending data....
@sundberg84 would it be possible for you to review the below code....have i missed something?
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 4 #include <SPI.h> #include <MySensors.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define HUMIDITY_SENSOR_DIGITAL_PIN 6 #define LIGHT_SENSOR_ANALOG_PIN A1 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "loungeroom living sensor #1" // Change to a fancy name you like #define SKETCH_VERSION "1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; int LightLevel = 0; int lastLightLevel; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } 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; 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); } int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.println(lightLevel); if (lightLevel != lastLightLevel) { send(LightMsg.set(lightLevel)); lastLightLevel = lightLevel; } 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); batLoop = 0; } else { batLoop++; } }
-
RE: loungeroom sketch transport failure
god i need new glasses...back to fornt capacitor on the antenna module....
ok thanks guys...that parts resolved, now just gotta go though no parent found part....other devices in the same location works, just not this one...time to start swapping capacitors
-
loungeroom sketch transport failure
hi all
using
mysensors 2.1.1get the following log
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 4 TSM:INIT 4 TSF:WUR:MS=0 10 !TSM:INIT:TSP FAIL 14 TSM:FAIL:CNT=1 14 TSM:FAIL:PDT 10018 TSM:FAIL:RE-INIT 10020 TSM:INIT 10027 !TSM:INIT:TSP FAIL 10031 TSM:FAIL:CNT=2 10033 TSM:FAIL:PDT
transport failure...not really sure what that is, and posts show it being many different things
this is my codei know i must have something wrong, but i cant work it out.... any help is appreciated
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 4 #include <SPI.h> #include <MySensors.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define HUMIDITY_SENSOR_DIGITAL_PIN 6 #define LIGHT_SENSOR_ANALOG_PIN A1 unsigned long SLEEP_TIME = 120000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "loungeroom living sensor #1" // Change to a fancy name you like #define SKETCH_VERSION "1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; int LightLevel = 0; int lastLightLevel; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } 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; 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); } int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.println(lightLevel); if (lightLevel != lastLightLevel) { send(LightMsg.set(lightLevel)); lastLightLevel = lightLevel; } 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); batLoop = 0; } else { batLoop++; } }
-
RE: 💬 Temperature Sensor
appologies for the badly worded questions...the code in its example format....
am i reading it correctly that it presents sensors based on the variable for number of temp sensors? -
RE: 💬 Temperature Sensor
really silly question.....so does create multiple sensors? so i would have temp1 temp2 or does it combine the value of both for an averaged temprature?
the way i read it it would present mutiple sensors i think? -
RE: 💬 Easy/Newbie PCB for MySensors
same hear...i ordered from itead...i had to upload the gerbers myself....
-
RE: first battery powered DHT lux
@sundberg84 nah just prrof of build at the moment...ill fix them with my proper node ID's when it's build time....waiting on step up's at the moment..... they seem to take a while when you find them cheaper
-
RE: first battery powered DHT lux
@sundberg84 champion and here is completed sketch which compiles without errors
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 14 #define MY_PARENT_NODE_ID 100 #include <SPI.h> #include <MySensors.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 #define LIGHT_SENSOR_ANALOG_PIN A1 unsigned long SLEEP_TIME = 120000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "loungeroom living sensor #1" // Change to a fancy name you like #define SKETCH_VERSION "1" // Your version DHT dht; float lastTemp; float lastHum; boolean metric = true; int LightLevel = 0; int lastLightLevel; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 = getConfig().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_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); } 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; 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); } int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.println(lightLevel); if (lightLevel != lastLightLevel) { send(LightMsg.set(lightLevel)); lastLightLevel = lightLevel; } 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); batLoop = 0; } else { batLoop++; } }
-
RE: first battery powered DHT lux
@sundberg84 copied a dht library from another computer i used last time i did mysensors work...now ive got that base sketch working....now to add the photo resistor
-
RE: first battery powered DHT lux
dht sensor library by adafruit installed version 1.3.0
-
RE: first battery powered DHT lux
i did install DHT library...but mine seems to be diffrent, if i manually include it i get dht_U.h
-
RE: first battery powered DHT lux
i copied your github one directly....
but when i try to verify i get the following error
exit status 1
no matching function for call to 'DHT::DHT()' -
first battery powered DHT lux
hi guys so im trying to build my first sensor from scratch, its using the easyPCB @sundberg84 (CHEERS)!
im having issues combining it all for the DHT
i keep getting dht was not declared
so its a battery sensor with a DHT 22 and a photo resistor for lux
here is my code
anyone with advice would be greatly appreciated
// Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 3 #include <SPI.h> #include <MySensors.h> #include <DHT.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define HUMIDITY_SENSOR_DIGITAL_PIN 3 #define LIGHT_SENSOR_ANALOG_PIN A1 unsigned long SLEEP_TIME = 600000; // Sleep time between reads (in milliseconds) #define SKETCH_NAME "loungeroom living sensor #1" // Change to a fancy name you like #define SKETCH_VERSION "1" // Your version float lastTemp; float lastHum; boolean metric = true; int LightLevel = 0; int lastLightLevel; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //========================= // 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.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // 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 = getConfig().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_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_LIGHTLEVEL, S_LIGHT_LEVEL); } 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; } send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temprature); // 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); } int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; Serial.println(lightLevel); if (lightLevel != lastLightLevel) { send(LightMsg.set(lightLevel)); lastLightLevel = lightLevel; } 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); batLoop = 0; } else { batLoop++; } }
-
australia LED downlights dimming
hi everyone
im trying to work out how/if what i want to do is possiblei have a heap of 12v LED downlights on 240v transformers in my roof
usually a group of 2-6 per switch....
i would like to know if the trailing edge dimmers can be used in this scenario -
RE: Are folks here happy with Domoticz?
@sundberg84 i dont know about you, but i use imperihome as a front end over the top of domoticz with mydomoathome.....that way you get the strong base of domoticz, but i more user friendly and customisable front end
-
RE: Battery status does not show in Domoticz
fair enough...i havent done battery sensors before...i was just looking at the API earlier where it pointed out sending in that range so thought it might be in that sort of area obviously domoticz is smart enough to realize its been passed the percentage anyway
-
RE: Battery status does not show in Domoticz
@edsteve according to domoticz api data battery is measured in a rang of 0-225? wouldnt percentage send cause issueS?
-
sensorize a vertical blind
hi guys i was looking around recently and found this for vertical lift blinds which seems quite thoughrough and well thought out.....
does anyone else think it should be possible to sensorize it?
http://www.instructables.com/id/Programmable-Automatic-Blind-Opener/
am not asking for anyone to rewrite into a sensor but more just wondering if it would be a worthwhile task to re write into a sensor...seems to be perfect for my needs....a very common blind type in australia
-
RE: Multiple Relays + Motion sketch, fully customizable, optional timer, manual override
confirmed, im now running this is my office, works perfectly every time
i have it set to a motion sensor that covers most of the room...
one relay controls the lights...the other controls my soldering iron perfect work -
RE: Multiple Relays + Motion sketch, fully customizable, optional timer, manual override
awesome work...this sketch is brilliant....
what happens if you retrigger motion before timer runs out?
will it always handle a restart of the timer correctly? -
RE: motion sensor and 2 relay code
ill double check it tonight, but im almost positive i have the pins right....
it was working untill i removed the for part of the loop -
RE: (SOLVED) complete reset for registration and adding
this solution has worked perfectly
thanks guys for all your advice...domoticz definatly cant un ignore anyway that i can find either -
RE: motion sensor and 2 relay code
i have attempted both
the motion sensor now turns on and off on demand by waving my hand in front of it perfectlybut the relay doesnt respond at all....
the node receives the following message
212874 TSF:MSG:READ,0-0-1,s=1,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:1, New status: 1so i know the node receives it, but it doesnt seem to do anything with the message
this is current code
/** 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 - HenryWhite DESCRIPTION Example sketch showing how to control physical relays. This example will remember relay state after power failure. Optional attachment of motion sensor to control the relays is possible. Note: The Child-IDs of the attached relays range from 1 up to (1-(NUMBER_OF_RELAYS)) */ //----------------------- Library Configuration --------------------- #define MY_DEBUG // uncomment to enable debug prints to serial monitor //#define MY_REPEATER_FEATURE // uncomment to enable repeater functionality for this node #define MY_NODE_ID 1 // uncomment to define static node ID // Enable and uncomment attached radio type #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_TRANSPORT_WAIT_READY_MS 1 // uncomment this to enter the loop() and setup()-function even when the node cannot be registered to gw //----------------------- Relay Configuration ----------------------- const int RELAYS[] = {5}; // digital pins of attached relays #define NUMBER_OF_RELAYS 1 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay //----------------------- Motion Sensor Configuration --------------- #define MOTION // un-comment to enable motion sensing #define MOTION_PIN 3 // The digital input pin of the motion sensor const int MOTION_RELAY_PINS[] = {5}; // The digital input pins of the relays, which should be triggered through motion #define NUMBER_OF_MOTION_RELAYS 0 // Total number of relays, which should be triggered through motion #define MOTION_CHILD_ID 0 // Set the child id of the motion sensor //----------------------- DO NOT CHANGE ----------------------------- #include <MySensors.h> MyMessage msg(MOTION_CHILD_ID, V_TRIPPED); // Initialize motion message bool lastTripped = 0; void before() { int i; for (int sensor = 1, i = 0; sensor <= NUMBER_OF_RELAYS; sensor++, i++) { // set relay pins to output mode pinMode(RELAYS[i], OUTPUT); // Restore relay to last known state (using eeprom storage) digitalWrite(RELAYS[i], loadState(sensor) ? RELAY_ON : RELAY_OFF); } // set motion pin to output mode, if MOTION is defined #ifdef MOTION pinMode(MOTION_PIN, INPUT); #endif } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Office Switches", "2.0"); // Register all sensors to gw (they will be created as child devices) for (int sensor = 1; sensor <= NUMBER_OF_RELAYS; sensor++) { present(sensor, S_BINARY); } #ifdef MOTION present(MOTION_CHILD_ID, S_MOTION); #endif } void loop() { #ifdef MOTION // Read digital motion value bool tripped = digitalRead(MOTION_PIN) == HIGH; if (lastTripped != tripped) { Serial.print("New Motion State: "); Serial.println(tripped); // Send tripped value to gw send(msg.set(tripped ? "1" : "0")); lastTripped = tripped; } #endif } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type == V_STATUS) { // Change relay state digitalWrite(RELAYS[message.sensor - 1], message.getBool() ? RELAY_ON : RELAY_OFF); // Store state in eeprom saveState(message.sensor - 1, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
-
RE: motion sensor and 2 relay code
ok im really new at this coding ide stuff...what if i want none of the relays triggered by the motion sensor
i would prefer to link each component back to domoticz by itself, and let it dictate what happens each part seperately...then i can change it easier if i want to leverage other things later -
RE: (SOLVED) complete reset for registration and adding
ahhh that makes so much sense now.....
perfect, ill do that tonight... i really should remember to save my sensor files properly
-
RE: (SOLVED) complete reset for registration and adding
that might be the best way....
as once it has presented to domoticz it doesnt reconize it as a new device again
so clearing eepron may cause it to re present correctly -
(SOLVED) complete reset for registration and adding
hi guys
i have a issue with my mysensors gateway
i had a node in that was giving me trouble
so i rebuilt the code and changed the number of relays on it, and added it in and watched it register on domoticz
but after changing it a 3rd time i got really confused on which node it was, so deleted both out of domoticz.
now neither of them appear and im not sure how to get them to re register....so i planned to now that i have played around a little and gotten to understand a bit more, just resetting mysensors gateway fully so that i can re register all devices and have them reconnect correctly...
is this possible?
-
motion sensor and 2 relay code
hi all
im running mysensors 2.0 with the following code on a node/** * 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 print #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define RELAY_1 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define RELAY_2 5 // Arduino Digital I/O pin number for first relay #define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay #define CHILD_ID 1 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor and officelights", "1.2"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"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); } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_STATUS) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
its a mix of copies of different examples but i think i stuffed it up
i dont see any communication from domoticz when i switch my relays -
RE: devices a long time away from controller.....
@mfalkvidd
thanks for that....judging by his operation of the device it shouldnt matter how long its away..seems to be only thing he did was use a static ID, as im guessing it might change if its away for long enough....seems pretty simple as its a send only device.....
only thing that i can think of that i may want feedback for is to light up buttons when they are available....not sure if im going to do these as powered by car...or if they should be battery powered...im guessing if battery powered lit up buttons is a bad idea
-
devices a long time away from controller.....
ok so this is possibly answered elsewhere, and i did look but couldnt find exactly what i was looking for
im thinking of garage remote for the car...
can i create a node that does nothing but sleep unless one of 3 buttons on it is pushed?
im thinking of easy to use car remotes for my garage....
but im concerned about its mapping ability if the device is away form the controller for a couple of days to a weeki was orginally going to make one of these that automattically detected approach of car, but it became too much of a risk
do the devices have lease life times? where they may change there ID without warning...
i will be working with domoticz, and another mysensors node for the actual door operation
-
RE: [Closed][Unresolved]gateway DHCP Fail
worked around the issue but making it a serial gateway instead as long as my nas is happy i dont mind how it plugs in....
-
RE: [Closed][Unresolved]gateway DHCP Fail
ok i can safely ignore my own comment about the mac address....a) no there are no other devices
b.) the model number printed is not the mac address...
there is no mac printed anywhere on he board so im not sure how to create one...
but unless im horribly mistaken that shouldnt affect the DHCP assign of IP address at this stage...i have attached a better coipy of the picture where you can see my pin locations
-
RE: [Closed][Unresolved]gateway DHCP Fail
hey guys board pic is below....im guessing now looking at it that the mar address for the board dshould be the HR number printed on it?
im aware of the static desirability, i will also have a reservation for it later on...only using DHCP now to try and figure out why its not hitting the network properly...
once this part is done ill be ready to go....
im unable to tell if my made up mac is valid...havent dealt in MAC's before -
[Closed][Unresolved]gateway DHCP Fail
gateway DHCP
i have a feeling im probably missing something really strait forward
i get the following messageDHCP FAILURE...0;255;3;0;9;Transport driver init fail
now i think debug is already turned on and this is what the above message is.
im using the rmf chip....but im unable to tell which ethernet shield im using, im assuming its the w5100, and im using that sketch at this point....unsure of what steps to take after this
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached //#define MY_RADIO_NRF24 #define MY_RADIO_RFM69 // Enable gateway ethernet module type #define MY_GATEWAY_W5100 // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4 // Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus. #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif // Enable to UDP //#define MY_USE_UDP //#define MY_IP_ADDRESS 10,0,0,200 // If this is disabled, DHCP is used to retrieve address // Renewal period if using DHCP //#define MY_IP_RENEWAL_INTERVAL 60000 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. #define MY_CONTROLLER_IP_ADDRESS 10, 0, 0, 1 // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. #define MY_MAC_ADDRESS 0x00, 0x00, 0xDE, 0xAD, 0xBE, 0x01 // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 // Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED #include <SPI.h> #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensors.h> void setup() { } void loop() { }
-
RE: intergrating with existing project car starter
@hek looks good...thanks for that ill investigate over the next week getting it running
-
intergrating with existing project car starter
hi everyone
so i have a project for a nfc car starter ive just recently completed....
i was wondering about integrating it into a node so that i could prestart and warm up my car in the mornings....however ive never dreamed of mysensors before that last few months and prebuilding my own seems a little out of my league....
anyone have any advice on how i could integrate?
thanks in advance to anyone who can give me even a hint
this is running on an arduino nanoint accessories = 2; //accessory int CarOn = 3; //power int Starter = 4; //ignition int indicatorPin1 = 5; int indicatorPin2 = 6; int indicatorPin3 = 7; int indicatorPin4 = 8; int handbrakePin1 = 9; int carRunState = 0; int handbrakeState = 0; #include <Wire.h> #include <PN532_I2C.h> #include <PN532.h> PN532_I2C pn532i2c(Wire); PN532 nfc(pn532i2c); void setup(void) { pinMode(accessories, OUTPUT); pinMode(CarOn, OUTPUT); pinMode(Starter, OUTPUT); pinMode(indicatorPin1, OUTPUT); pinMode(indicatorPin2, OUTPUT); pinMode(indicatorPin3, OUTPUT); pinMode(indicatorPin4, OUTPUT); pinMode(handbrakePin1, INPUT); Serial.begin(115200); Serial.println("Hello! I'm a Car!"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print(versiondata); Serial.print("PN53x key scanner board not online"); while (1); // halt } // Got ok data, report state Serial.print("Reader Online1, "); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); // configure board to read NFC tags nfc.SAMConfig(); Serial.println("Waiting for a valid key"); } void loop(void) { String ringUid; boolean success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) // Wait for an ISO14443A type cards (NFC Ring, Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (NFC Ring or Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { // Display some basic information about the card // Serial.print(" UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes"); Serial.print(" UID Value: "); for (uint8_t i = 0; i < uidLength; i++) { Serial.print(".."); Serial.print(uid[i], HEX); ringUid += String(uid[i], HEX); } Serial.println(ringUid + "\n"); if (ringUid == "42cbfd26f3f81" || ringUid == "4b4c22993c81" || ringUid == "4323222993c81" || ringUid == "4a2cd26f3f80"){ Serial.println("Key accepted!"); } if ((ringUid == "42cbfd26f3f81" || ringUid == "4b4c22993c81" || ringUid == "4323222993c81" || ringUid == "4a2cd26f3f80") && (carRunState == 0)){ Serial.println("PERMISSION GRANTED, SYSTEMS ON"); digitalWrite(accessories, HIGH); // sets latching relay trigger on for ignition mode in car to allow start digitalWrite(indicatorPin2, HIGH); //show state, second LED //delay(100); // waits briefly digitalWrite(CarOn, HIGH); // removes latching relay trigger delay(1500); carRunState = 1; } else if ((ringUid == "42cbfd26f3f81" || ringUid == "4b4c22993c81" || ringUid == "4323222993c81" || ringUid == "4a2cd26f3f80") && (carRunState == 1)){ // if (handbrakeState = 0){if handbrake is on then safe to crank car, if not then skip this mode entirely { Serial.println("ENGINE CRANKING"); delay(100); digitalWrite(Starter, HIGH); // triggers output for engine starting digitalWrite(indicatorPin3, HIGH); //show state, third LED delay(1000); // waits for a second digitalWrite(Starter, LOW); // removes triggered output delay (1000); Serial.println("ENGINE CRANKING COMPLETE"); } carRunState = 2; } else if ((ringUid == "42cbfd26f3f81" || ringUid == "4b4c22993c81" || ringUid == "4323222993c81" || ringUid == "4a2cd26f3f80") && (carRunState == 2)){ { digitalWrite(indicatorPin3, LOW); //turn off 3rd LED // waits for a second Serial.println("ENGINE SHUTDOWN"); //delay(200); // waits briefly digitalWrite(CarOn, LOW); //reset relay digitalWrite(accessories, LOW); delay(3000); carRunState = 0; digitalWrite(indicatorPin1, LOW); //LED1 off } } } }
-
RE: noob with issues building
that is extremely awesome....
thanks for the time to answer my questions....back to waiting for many ebay parcels...lol -
RE: noob with issues building
currently after alot of stuffing around ive now got it building without any errors....
but i was just suprised the for an ethernet gateway that there was no setup or loopi get what you mean about light only receiving so it not needing much work
i would of though gateway to he more complex
-
noob with issues building
hi guys...
feeling like im quite a stupid person here as ive looked though the forum but cant find alot on my issues
ive tried resolving it but im sure i must be missing somethingim trying to build the gateway at the moment just to prove i can get it up and running and so i can make sure my domoticz server can see it and run with it
but i cant get it to build
first i tried the codebender version but it told me lots of librarys are missing...so then i installed the librarys from the github site onto my local IDE but it still says librarys are missing even though i can see them
(yes i did install mysensors under manager)so then i downloaded the github master brance and imported that...
i can get the to build if i use the inbuild example...
but i notice there is nothing under setup or loop which im sure there is supposed to be?
am i just being stupid and missing something?
thank you in advance to anyone who can point me in the right direction