@carlscic Sorry for the delay. I didn't get a notification of your reply due to some issues caused by the Google outage. Looks like you're almost there. Try playing around with the delays. You might need to adjust the separatorDelay delay times (or maybe remove that call completely). They it just comes down to iterating though the code to make sure you're getting the correct sequence of highs and lows. Playing back your results and recording them in Audacity is a great way to see your results.
Posts made by petewill
-
RE: Controlling Blinds.com RF Dooya Motors with Arduino and Vera
-
RE: Controlling Blinds.com RF Dooya Motors with Arduino and Vera
@carlscic Sorry, I'm not clear on what you're looking to do. Have you compared the original Audacity recording to the signals you are sending from the Arduino? You should be able to compare them and make the necessary adjustments to the code so the two recordings are identical.
-
RE: Controlling Blinds.com RF Dooya Motors with Arduino and Vera
@ssuckow I can't see the image but when I did this I started in small steps. Your first goal is to send a successful signal without all the MySensors code. I just created a standalone program with all my code in the setup so when it ran it would send a raise, stop or lower signal. Once you do that you can integrate it with MySensors much easier. It sounds like you have mostly done this based on your description above but I'm not sure. Also, are you sure the hardware is wired correctly? Is the 433Mhz device is getting enough power to send the signal to the blinds?
-
RE: USB gateway Arduino Mega: HA doesn't see switches and relays
@jan-kocon I actually submitted a fix for the echo/ack that is now in the most recent version of Home Assistant. So, as long as you are on the most current version the default sketches should work now.
-
RE: Just found a pair of "old" NRF51822-04 ... any good?
@ghiglie Check out these links if you haven't used NRF5 before. They should help you get started.
https://forum.mysensors.org/topic/9266/guide-nrf5-nrf51-nrf52-for-beginners
https://www.openhardware.io/view/376/MySensors-NRF5-PlatformI found the ST-LINK programmer to be easier to work with (using Windows) that the J-LINK
-
RE: USB gateway Arduino Mega: HA doesn't see switches and relays
@Jan-Kocon I found the issue. Home Assistant doesn't request an Ack response for some reason. Here is a comparison of my current home automation controller (Vera) and Home Assistant. The top line is Vera (requesting an Ack response) and the bottom line is Home Assistant.
https://www.mysensors.org/build/parser?log=19%3B0%3B1%3B1%3B2%3B1 19%3B0%3B1%3B0%3B2%3B0 -
RE: USB gateway Arduino Mega: HA doesn't see switches and relays
@Jan-Kocon I am experiencing the same thing with my devices (where the status doesn't stick but the relay stays on). I haven't had time to dig into it yet but I suspect this ultimately needs to be fixed in the Home Assistant integration. The example code on the Home Assistant site sends back the status after the relay has been updated. The MySensors RelayActuator sketch does not send back the status this way.
It seems to me there are two workarounds for this.
- Set the "optimistic" setting in the home assistant configuration.yaml file to True
- Send the state back to Home Assistant after the relay has been changed. See these lines of code for in the example:
// Change relay state state = (bool)message.getInt(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); send(msg.set(state?RELAY_ON:RELAY_OFF));```
-
RE: USB gateway Arduino Mega: HA doesn't see switches and relays
@Jan-Kocon I would recommend starting with the relay example sketch that is in the presentation section of this site: https://www.home-assistant.io/components/mysensors/#presentation
Once you have that working you can start integrating your existing sketch in to that one.
One thing I notice with your existing sketch is you have a sensor type of "S_LIGHT" which doesn't exist. You need S_BINARY (https://www.mysensors.org/download/serial_api_20).
You also need to send the initial value in the loop function like this: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); }```
-
RE: USB gateway Arduino Mega: HA doesn't see switches and relays
@jan-kocon I am just learning Home Assistant myself so I'm no expert. One thing it looks like your relay code is missing is to send an initial relay value in the loop function of your code when the node first starts (which is required by Home Assistant). Here is the link for more info: https://www.home-assistant.io/components/mysensors/#presentation
-
RE: What did you build today (Pictures) ?
@berkseo nice! What did you use for the capacitive sensor? MPR121?
-
RE: Vera edge?
@lange60 you need a gateway that the Vera connects to. I use the Ethernet gateway with NRF radios. So, Vera connects via IP/Ethernet and the gateway connects to the sensors wirelessly via NRF radios. Most of my devices (including the gateway) use Arduino Pro Minis.
-
RE: RooDe - A "reliable" PeopleCounter
@Kai-Bepperling I have been wanting to make something like this for years. I keep getting sidetracked so I have never completed anything. I am excited to try this method at some point. I have a few rooms where this would work much better than the motion sensors I have now. Thank you for posting this.
-
RE: Radio does not send properly when battery-powered
Maybe you need to update the bootloader and/or fuses? Maybe it has a brownout setting of 4.3V?
-
RE: How To: Automate Devices with Existing Buttons
@vladimir Yes, you could probably use an optocoupler to read the LEDs without taking too much power from them.
-
RE: How To: Automate Devices with Existing Buttons
@vladimir I have very little time these days so I won't be able to help in detail but if you want to use my method you will need to open your kettle and see what type of buttons they are. They will be connected to ground or power. When you know that you can choose the correct mosfet and start testing. Take a look at my wiring diagram to see what I've done.
-
RE: Controlling Blinds.com RF Dooya Motors with Arduino and Vera
@mortenvinding cool! I looked at a couple of code "sniffers" when I did this but none of them worked. Good to hear progress has been made on that. Should save quite a bit of time.
-
RE: 💬 Insulated Whole House Fan
@lis610 Awesome! Congratulations and great job for not giving up. That was a lot to tackle for a first project! Nice enclosure to house everything. Looks way cleaner than mine
-
RE: 💬 Insulated Whole House Fan
@lis610 It should work at 8MHz. Have you double checked the wiring? Did you try with the default sketch in the DHT library? What are the debug messages saying?
-
RE: 💬 Insulated Whole House Fan
@lis610 Great news! I echo what @hard-shovel said. I try to supply my 5v sensors with 5v power from a regulator (with the appropriate capacitors) instead of my Arduino.
-
RE: 💬 Insulated Whole House Fan
@hard-shovel Thanks for the help.
@lis610 You are picking a very advanced project to start with. If you have the time I'd suggest an easier project like a motion sensor to get started. If you want to keep going I'd suggest doing some additional reading/watching on how this all works. Not trying to be critical but rather save you frustration.
I'm not running UI7 on my Vera so I haven't tested but it should automatically create your device as long as you are including it when first starting the node. For me I press the "Start" button then power up my node (the fan in this case).
However, if you don't have good communication it may not add correctly.
-
RE: 💬 Insulated Whole House Fan
@lis610 if it can't communicate with the gateway and controller the node will never get to the loop which could be why the display isn't working. The SPI include used to be required for MySensors.
-
RE: 💬 Insulated Whole House Fan
@lis610 sorry, I'm not a place where I can look in depth. It looks like your code isn't communicating with the gateway though. Did you try the line of code above? The device should work with the push button even if it can't communicate with the gateway (with that code).
-
RE: 💬 Insulated Whole House Fan
@lis610 It looks like it's having issues communicating with your gateway. Here is a link to the log parser. You can use this in the future to check out your logs.
Also, did you comment/uncomment the proper defines as noted above and in the code comments?
Try adding this line before #include <MySensors.h>
#define MY_TRANSPORT_WAIT_READY_MS 4000 //This will allow the sensor to function if it can't find the gateway when it first starts up
-
RE: 💬 Insulated Whole House Fan
@lis610 is #define TFT_DISPLAY_ON uncommented? Also, you will at least need the radio attached so the MySensors code can fully load (you can also setup defines to proceed without connecting to gateway but I don't remember them off the top of my head). I don't remember if there are any other dependencies since it as been so long since I built this.
-
RE: 💬 Insulated Whole House Fan
@lis610 Strange. It disappeared. I added it again and just downloaded it so you should be good. Sorry for all the issues!
-
RE: 💬 Insulated Whole House Fan
@lis610 yes, I uploaded it to the page in the link at the top of this page.
-
RE: 💬 Insulated Whole House Fan
@lis610 Sorry about that. I just fixed the code on the build page. Hopefully that will get you up and running
-
RE: 💬 Insulated Whole House Fan
@lis610 Sorry for the delay. Work has been very busy. I have attached the libraries I'm using. I was able to get it to compile when I just tested. https://drive.google.com/file/d/1wauxHRf5pyqLnBGsfCP8UPJQR1wNdkoF/view?usp=sharing
Let me know if you have issues with this.
-
RE: Uploading to Pro Mini fails with FTDI
@ben999 Sorry for the delay. Work has been crazy lately. I see there are plenty of answers above and I echo them. I try not to upload with two power sources connected. If everything is 5v you are probably safe but I see you're using batteries and I'd not risk it just to be safe. I have used two power sources in the past but I have since changed my ways. I can't remember what stopped me but I believe I was getting strange results. I don't think I ever fried any hardware but why risk it...?
If you are still having this issue have you tried with another Pro Mini and different code? Is anything coming out of the serial monitor or is it just blank?
-
RE: Uploading to Pro Mini fails with FTDI
@ben999 I think I understand what you're asking. If so, I do it frequently with my projects. What I do is just unplug the VCC DuPont cable from the FTDI adapter. Here is a picture of what I mean.
-
How To: Automate Devices with Existing Buttons
I recently decided to see if I could automate my oven so I could turn it on/off and set the temperature remotely. The oven is electric and has a massive plug going into the wall (I think it's a 30A, 220V but I never checked). I figured the only way I would be comfortable doing this was to "press" the momentary push buttons in the existing circuitry. I did not want to add existing relays or anything of that nature. I thought it would be easy figure out how to "press" existing buttons with an Arduino but it was surprisingly difficult (for me at least) to find any info on the subject. So, I decided to make a how to video in case anyone else wants to attempt a similar project.
The video is more generic and covers how to simulate a button press with an Arduino instead of a step by step guide on how to automate an oven. It's not specifically related to MySensors but hopefully it will be useful to someone out there who was like me looking to automate a device with pre-existing buttons.
Video
"Press" Buttons with Arduino (How to hack and automate your existing device buttons) – 14:46
— Pete BWiring
Here is a wiring diagram for each type of switch: ground side and voltage side.
MOSFETs
I used the Alpha & Omega AO3401A (P-Channel) and AO3400 (N-Channel) MOSFETs for this project. They are very cheap. I got 100pcs of each type for around $3 total. Here is an example of where they can be found (but you may want to do some searching for the best price):
https://www.aliexpress.com/item/Free-shipping-20pcs-SMD-mosfet-transistor-SOT-23-AO3401/32359403044.html?spm=a2g0s.9042311.0.0.ej97EOBasic Demo Code
#include <Bounce2.h> #define GND_GATE_PIN 3 #define VCC_GATE_PIN 5 #define GND_DETECT_PIN 4 #define VCC_DETECT_PIN 8 #define BUTTON_PRESS_DELAY 100 //The amount of delay used for a button press //Track button presses uint8_t gndValuePrev = 1; uint8_t vccValuePrev = 0; //LED button on/off tracking uint8_t gndLedOn = 0; uint8_t vccLedOn = 0; unsigned long gndMillis; unsigned long vccMillis; // Instantiate a Bounce object Bounce gndDebouncer = Bounce(); Bounce vccDebouncer = Bounce(); void setup() { Serial.begin(115200); //Setup the pins pinMode(GND_GATE_PIN, OUTPUT); pinMode(VCC_GATE_PIN, OUTPUT); pinMode(GND_DETECT_PIN, INPUT_PULLUP); pinMode(VCC_DETECT_PIN, INPUT); //Start with all outputs (buttons) not enabled (pressed) digitalWrite(GND_GATE_PIN, 0); digitalWrite(VCC_GATE_PIN, 1); // After setting up the buttons, setup debouncers gndDebouncer.attach(GND_DETECT_PIN); gndDebouncer.interval(50); vccDebouncer.attach(VCC_DETECT_PIN); vccDebouncer.interval(50); } void loop() { unsigned long currentMillis = millis(); //Get the current millis (used for timers) // Update the debouncers gndDebouncer.update(); vccDebouncer.update(); // Get the update value uint8_t gndValue = gndDebouncer.read(); uint8_t vccValue = vccDebouncer.read(); if (gndValue != gndValuePrev) { if (gndValue == 0) { Serial.println(F("Ground Button Pressed")); if (gndLedOn == 0) { //Don't echo the button push if it was turned on by the Arduino gndMillis = currentMillis + 1000; gndLedOn = 1; } } gndValuePrev = gndValue; } if (vccValue != vccValuePrev) { if (vccValue == 1) { Serial.println(F("VCC Button Pressed")); if (vccLedOn == 0) { //Don't echo the button push if it was turned on by the Arduino vccMillis = currentMillis + 1000; vccLedOn = 1; } } vccValuePrev = vccValue; } //Turn on led 1 second after button pressed if (gndLedOn == 1 && currentMillis > gndMillis) { nChannelPress(GND_GATE_PIN); gndLedOn = 0; } if (vccLedOn == 1 && currentMillis > vccMillis) { pChannelPress(VCC_GATE_PIN); vccLedOn = 0; } } void pChannelPress(uint8_t buttonPinName) { //Simulate a button press digitalWrite(buttonPinName, 0); //Ground to enable delay(BUTTON_PRESS_DELAY); digitalWrite(buttonPinName, 1); //VCC to disable delay(BUTTON_PRESS_DELAY); } void nChannelPress(uint8_t buttonPinName) { //Simulate a button press digitalWrite(buttonPinName, 1); //VCC to disable delay(BUTTON_PRESS_DELAY); digitalWrite(buttonPinName, 0); //Ground to enable delay(BUTTON_PRESS_DELAY); }
In case you're interested, here is the code for my oven project as well as some pictures.
Oven Code
/* This will control physical buttons on a device. In my case, an oven. It will also read button presses and send the status back to the controller. I used 4.7k resistors on the P-Channel MOSFET gate pins to hold them high (off) in case there are issues with the Arduino. These can be omitted if you don't care if your switch floats (which you probably do). I used larger resistors (somewhere around 20-30k) to detect a button press. These are connected to the drain side of the button/MOSFET Uses the bounce2 library to debounce the buttons */ #define SKETCH_NAME "Oven Control" #define SKETCH_VERSION "1.0" // Enable debug prints to serial monitor //#define MY_DEBUG //MySensors debug messages //#define LOCAL_DEBUG //Code specific debug messages // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_RF24_PA_LEVEL RF24_PA_HIGH //Options: RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX #define MY_RF24_CHANNEL 76 //#define MY_NODE_ID 1 //Manually set the node ID here. Comment out to auto assign #include <MySensors.h> #include <Bounce2.h> #ifndef BAUD_RATE #define BAUD_RATE 115200 #endif #ifdef LOCAL_DEBUG #define dbg(...) Serial.print(__VA_ARGS__) #define dbgln(...) Serial.println(__VA_ARGS__) #else #define dbg(x) #define dbgln(x) #endif #define DWELL_TIME 50 //value used in all wait calls (in milliseconds) this allows for radio to come back to power after a transmission, ideally 0 #define CHILD_ID_OVEN 0 #define CANCEL_PIN 3 #define BAKE_PIN 4 #define UP_PIN 5 #define DOWN_PIN 6 #define OVEN_OFF_PIN 7 //GPIO Pin for detecting when the physical "off" button is pressed at the oven #define OVEN_ON_PIN 8 //GPIO Pin for detecting when the physical "on" button is pressed at the oven #define BUTTON_ON 0 // GPIO value to write for simulating a button press (0 for P-Channel MOSFET) #define BUTTON_OFF 1 // GPIO value to write for simulating a button not pressed (1 for P-Channel MOSFET) #define PRESSED 1 //The value that is received when the physical butons are pressed (1 for P-Channel MOSFET) #define HEAT_LOW_LIMIT 170 //The lowest temp the heat can be set to #define HEAT_HIGH_LIMIT 550 //The highest temp the heat can be set to #define OVEN_ON_TEMP 350 //The default temp that the oven is set to when first turned on #define DELAY_OVEN_CHANGE 5000 //The amount of time to wait for additional commands from gateway before applying previous commands (give time for user to fine tune temperature) #define BUTTON_PRESS_DELAY 100 //The amount of delay used for a button press #define TEMP_INCREMENT 5 //Degrees to increment with each button press MyMessage msgHeatMode(CHILD_ID_OVEN, V_HVAC_FLOW_STATE); MyMessage msgHeatSetpoint(CHILD_ID_OVEN, V_HVAC_SETPOINT_HEAT); uint16_t heatSetPoint = HEAT_LOW_LIMIT; //The current oven heat set point. Default is HEAT_LOW_LIMIT if no value is received from gateway. //uint16_t heatSetPointPrev = HEAT_LOW_LIMIT; //The previous oven heat set point. Default is HEAT_LOW_LIMIT if no value is received from gateway. uint8_t ovenStatus = 0; //The current status of the oven 1 = on, 0 = off uint8_t ovenStatusPrev = 0; //The previous status of the oven 1 = on, 0 = off uint8_t ovenStateCommand = 2; //used to track oven on/off commands from controller uint8_t receivedCommand = 0; //Used to get config states from controller at start up unsigned long commandDelayMillis; //Used to track delay time before the received commands are applied unsigned long sendDelayMillis; //Wait to update the controller with on/off status until the automation is done // Instantiate a Bounce object Bounce onDebouncer = Bounce(); Bounce offDebouncer = Bounce(); void before() { #ifdef LOCAL_DEBUG Serial.begin(BAUD_RATE); #endif } void presentation() { // 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_OVEN, S_HEATER); wait(DWELL_TIME); //metric = getConfig().isMetric; //This has been removed as it will default to metric if connection to the gateway is not established (bad for imperial users) //wait(DWELL_TIME); } void setup() { //Setup the pins pinMode(CANCEL_PIN, OUTPUT); pinMode(BAKE_PIN, OUTPUT); pinMode(UP_PIN, OUTPUT); pinMode(DOWN_PIN, OUTPUT); pinMode(OVEN_ON_PIN, INPUT); pinMode(OVEN_OFF_PIN, INPUT); //Start with all outputs (buttons) not enabled (pressed) digitalWrite(CANCEL_PIN, BUTTON_OFF); digitalWrite(BAKE_PIN, BUTTON_OFF); digitalWrite(UP_PIN, BUTTON_OFF); digitalWrite(DOWN_PIN, BUTTON_OFF); // After setting up the buttons, setup debouncers onDebouncer.attach(OVEN_ON_PIN); onDebouncer.interval(1); offDebouncer.attach(OVEN_OFF_PIN); offDebouncer.interval(5); uint8_t reqCounter = 0; while (receivedCommand == 0) { dbgln("Requesting heat setpoint"); request(CHILD_ID_OVEN, V_HVAC_SETPOINT_HEAT); //Request state from gateway wait(500); reqCounter++; if (reqCounter > 5) { dbgln("Failed to get heat setpoint!"); break; } } wait(5000); //Wait for 10 seconds to give time for commands to be received (so the oven doesn't turn on when the microcontroller starts) receivedCommand = 0; } void loop() { unsigned long currentMillis = millis(); //Get the current millis (used for timers) // Update the debouncers onDebouncer.update(); offDebouncer.update(); // Get the update value uint8_t onValue = onDebouncer.read(); uint8_t offValue = offDebouncer.read(); if (onValue == 1) { ovenStatus = 1; sendDelayMillis = currentMillis; dbgln(F("On Pressed")); } if (offValue == 1) { ovenStatus = 0; sendDelayMillis = currentMillis; dbgln(F("Off Pressed")); } if (ovenStatus != ovenStatusPrev && currentMillis - sendDelayMillis > 1000) { //Send new ovenStatus to gateway send(msgHeatMode.set(ovenStatus == 1 ? "HeatOn" : "Off")); dbgln(ovenStatus); ovenStatusPrev = ovenStatus; } if (receivedCommand) { //Received a command to turn on/off the oven if (ovenStateCommand == 0) { //Turn off the oven right away (no delay necessary) buttonPress(CANCEL_PIN); receivedCommand = 0; ovenStateCommand = 2; //Set to some number other than 1 or 0 to allow oven to be adjusted when the heatSetPoint changed ovenStatus = 0; } else { //We need to turn on and/or change the temp but we want to wait for all the commands to come in first (DELAY_OVEN_CHANGE time) if (currentMillis - DELAY_OVEN_CHANGE > commandDelayMillis) { if (ovenStateCommand == 1 || ovenStatus == 1) { //The oven is either on or should be on. Since we are not keeping track of the temperature //we need to turn the oven off then back on to ensure we get the correct temp buttonPress(CANCEL_PIN); //Now, turn it on and adjust the temp to the correct setting buttonPress(BAKE_PIN); wait(BUTTON_PRESS_DELAY * 2); //wait for the oven to turn on before adjusting temp buttonPress(UP_PIN); //Oven starts at 0 so we need to press a button to start at OVEN_ON_TEMP wait(BUTTON_PRESS_DELAY * 2); uint16_t tempChange = OVEN_ON_TEMP; if (heatSetPoint < OVEN_ON_TEMP) { //The temp should be adjusted lower (also rounding to nearest TEMP_INCREMENT) while (tempChange > heatSetPoint + (TEMP_INCREMENT / 2)) { buttonPress(DOWN_PIN); wait(BUTTON_PRESS_DELAY); dbg(F("Lowered temp to: ")); dbgln(tempChange); tempChange -= TEMP_INCREMENT; } } else { //The temp should be adjusted lower (also rounding to nearest TEMP_INCREMENT) while (tempChange < heatSetPoint - (TEMP_INCREMENT / 2)) { buttonPress(UP_PIN); wait(BUTTON_PRESS_DELAY * 2); dbg(F("Raised temp to: ")); dbgln(tempChange); tempChange += TEMP_INCREMENT; } } send(msgHeatSetpoint.set(tempChange)); //Send value to gateway ovenStatus = 1; } receivedCommand = 0; ovenStateCommand = 2; //Set to some number other than 1 or 0 to allow oven to be adjusted when the heatSetPoint changed } } } } void receive(const MyMessage &message) { dbg(F("msg data: ")); dbgln(String(message.data)); if (message.isAck()) { dbgln(F("Ack from gateway")); } if (message.type == V_HVAC_FLOW_STATE && !message.isAck()) { //find the mode if (String(message.data) == "Off") { ovenStateCommand = 0; } else if (String(message.data) == "HeatOn") { ovenStateCommand = 1; } else { dbgln(F("Invalid state received")); } dbg(F("Oven state: ")); dbgln(ovenStateCommand); commandDelayMillis = millis(); receivedCommand = 1; } if (message.type == V_HVAC_SETPOINT_HEAT && !message.isAck()) { uint16_t value = atoi(message.data); if (value < HEAT_LOW_LIMIT) { heatSetPoint = HEAT_LOW_LIMIT; } else if (value > HEAT_HIGH_LIMIT) { heatSetPoint = HEAT_HIGH_LIMIT; } else { heatSetPoint = value; } dbg(F("Heat setpoint: ")); dbgln(heatSetPoint); commandDelayMillis = millis(); receivedCommand = 1; } } void buttonPress(uint8_t buttonPinName) { //Simulate a button press digitalWrite(buttonPinName, BUTTON_ON); wait(BUTTON_PRESS_DELAY); digitalWrite(buttonPinName, BUTTON_OFF); wait(BUTTON_PRESS_DELAY); }
-
RE: What did you build today (Pictures) ?
@nca78 thanks! I'll check that out.
-
RE: What did you build today (Pictures) ?
@NeverDie The wires are there in case I need to upload a new bootloader. This sensor one of the first ones I have done where the Arduino isn't easily removable and I wanted to try to make it a little easier in case I had to change it.
I used an original Prusa I3 MK2 to do the printing. This is in ABS (because I didn't have any white PLA) so the print is a little rougher than if it was done with PLA.@dbemowsk Thanks! No, my son didn't help with the case design (yet). It was from a previous project that I slightly modified. My son is 6 so he doesn't really have the attention span to do too much yet. I'm hoping that doing little parts of a project will be fun for him and eventually turn into full projects.
@mfalkvidd & @sundberg84 Thanks. I guess I need to rig something up if he is going to be helping me more often...
@gohan No, it's not battery powered. I didn't want to have to deal with changing batteries and there is a power outlet right near the location he wanted it. Here is the 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 - PeteWill */ #define SKETCH_NAME "Controller" #define SKETCH_VERSION "1.0" //Child (sensor) name that will be sent to gateway #define CONTROLLER_CHILD_NAME "Room Control" // Enable debug prints to serial monitor #define MY_DEBUG //MySensors debug messages #define LOCAL_DEBUG //Code specific debug messages // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_RF24_PA_LEVEL RF24_PA_HIGH //Options: RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX #define MY_RF24_CHANNEL 76 #define MY_NODE_ID 1 //Manually set the node ID here. Comment out to auto assign #include <MySensors.h> #include <Bounce2.h> #define SCENE_CHILD_ID 0 #define BAUD_RATE 57600 #ifdef LOCAL_DEBUG #define dbg(...) Serial.print(__VA_ARGS__) #define dbgln(...) Serial.println(__VA_ARGS__) #else #define dbg(x) #define dbgln(x) #endif //Button Pins -- Arduino Digital I/O pin button is connected to #define BLIND_UP_PIN 5 #define BLIND_STOP_PIN 4 #define BLIND_DOWN_PIN 3 #define LIGHT_ON_PIN 8 #define LIGHT_OFF_PIN 7 #define EXTRA_BUTTON_PIN 6 #define LED_PIN A0 //Pin for the LED transistor #define FLASH_TIME 300 //Amount of time to flash the LED (in milliseconds) #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) uint8_t ledOn = 0; uint32_t ledMillis; //Used for tracking the LED flash time //The sceneNum array corresponds with the buttonPins array so if a button pin is read, it will send the scene number to the gateway int sceneNum[] = {0, 1, 2, 3, 4, 5}; uint8_t buttonPins[] = { BLIND_UP_PIN, BLIND_STOP_PIN, BLIND_DOWN_PIN, LIGHT_ON_PIN, LIGHT_OFF_PIN, EXTRA_BUTTON_PIN }; //Debouncer is used for the buttons. Need to have the same number as the total buttons. Bounce debouncer[] = { Bounce(), Bounce(), Bounce(), Bounce(), Bounce(), Bounce() }; //used to keep track of previous values contact sensor values uint8_t buttonPrev[] = {1, 1, 1, 1, 1, 1}; MyMessage scene(SCENE_CHILD_ID, V_SCENE_ON); void before() { #ifdef LOCAL_DEBUG Serial.begin(BAUD_RATE); #endif } void presentation() { // 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(SCENE_CHILD_ID, S_SCENE_CONTROLLER, CONTROLLER_CHILD_NAME); } void setup() { //Set up Pins for (int i = 0; i < ARRAY_SIZE(buttonPins); i++) { // Setup the pins pinMode(buttonPins[i], INPUT_PULLUP); // After setting up the button, setup debouncer debouncer[i].attach(buttonPins[i]); debouncer[i].interval(100); dbg(F("Set up contact Pin: ")); dbgln(buttonPins[i]); } pinMode(LED_PIN, OUTPUT); } void loop() { uint32_t currentMillis = millis(); for (int i = 0; i < ARRAY_SIZE(buttonPins); i++) { debouncer[i].update(); // Get the update value uint8_t value = debouncer[i].read(); if (value != buttonPrev[i]) { dbg(F("Value is for sensor #")); dbg(buttonPins[i]); dbg(F(" is ")); dbgln(value); if (value == 0) { //Button is pressed send scene value send(scene.set(sceneNum[i])); ledOn = 1; ledMillis = currentMillis; } buttonPrev[i] = value; } } if (ledOn) { digitalWrite(LED_PIN, HIGH); if (currentMillis - ledMillis > FLASH_TIME) { ledOn = 0; digitalWrite(LED_PIN, LOW); } } }
-
RE: What did you build today (Pictures) ?
My son and I finally finished his first MySensors project- a remote control for his room. He wasn't too interested but you have to start somewhere right...?
Question for you all... what are you doing (if anything) to vent the fumes from soldering? I haven't really been worried about it in the past but it makes me nervous with my son doing it with me.
Anyway, here are the pictures.
-
RE: Distributed Power vs Centralized Nodes
If you are putting lighting in your house that will replace normal lighting (not accent/supplemental lighting) I highly recommend that you design it so it functions if there is 110/220 going to the switch. If it relies on another power supply to switch it on/off you can have safety issues if your whole house power supply goes out. That being said I have nodes all over my house that are powered from one power supply. These nodes are not critical to my house's function and it really doesn't matter if everything stops working (although it would be inconvenient).
-
RE: $8 Lamp (Outlet) "Smart Plug" Module
@jeremushka I haven't done it on the smart outlet but I did do it on my "Whole House Fan" project. You can check out the code from that if you're interested. Here is a link to the video if you wanted to check that out: https://youtu.be/KVsUe7sOCPo
Also, just make sure you check out the specs on the acs712 and don't pass through more current than is safe. I don't remember the specs off the top of my head but I knew my whole house fan was safe because of what it would be drawing -
RE: MYSBootloader 1.3 pre-release & MYSController 1.0.0beta
@itbeyond I responded in the other thread.
-
RE: Firmware does not load MYSController & MYSBootloaderV13pre
@itbeyond I ran into issues with multiple connections to my Ethernet gateway. My current config is to route my Vera through MYSController. If I do that I'm able to upload new firmware without any issues. Also, check the distance/reception of the sensor. I had one with poor reception that either didn't upload or took 20 minutes. When I changed the radio antenna config it worked in about a minute.
-
RE: MYSBootloader 1.3 pre-release & MYSController 1.0.0beta
@itbeyond Have you opened up your firewall so the Vera can communicate with the computer running MYSController?
Here is how I have MYSContoller configured...
First, connect MYSController to your existing gateway (if you are using Ethernet
you only want one device to connect so don't have your Vera connected at the same time)
Once you do that you need to choose a port in the settings:
Then you press Connect (to connect to the actual Ethernet or Serial gateway).
Once connected turn on GW Mode (mine is grayed out because I'm not at home connected to my gateway):
In your Vera you would obviously want to connect to the IP address of the computer running MYSController
-
RE: 💬 Bed Occupancy Sensor
@Inso Unless there is another use for a PIR that I'm not aware of, a PIR will detect motion and when I'm sleeping I'm not doing much moving. With this sensor it knows when I'm in bed so the lights don't turn on and the blinds don't go up. Hopefully that makes sense.
-
RE: How to add a serial device to use in node-red
@tbowmo Ah, ok. That makes sense. My USB20 was created by the MySensors Raspberry Pi Gateway so that's where the disconnect is here. Sorry for clogging up this thread...
-
RE: How to add a serial device to use in node-red
@tbowmo Thanks! I just had a chance to go through this. I ran the command and looks like root has access?
pi@rpi:~ $ lrwxrwxrwx 1 root root 10 Nov 8 21:07 /dev/ttyUSB020 -> /dev/pts/1
Also it appears that my user that I think is running node-red (still called pi) already has access to the dialout group?
pi@rpi:~ $ awk -F':' '/dialout/{print $4}' /etc/group pi
-
RE: How to add a serial device to use in node-red
@hiddenuser I know this is really late but I just ran into this problem and thought I'd post the solution in case any other people run into it. Thanks go to @mfalkvidd for providing the solution. You need to add this line:
sudo chmod 666 /dev/ttyUSB020
to /etc/rc.local
Here is a link on how to do that (and for more info): https://www.raspberrypi.org/documentation/linux/usage/rc-local.md
-
RE: 💬 Building a Raspberry Pi Gateway
@gohan Thanks! I seem to have the serial stuff working well (but haven't yet put it into production) so I think I'll go that way for now. I definitely need to look into mqtt at some point though.
-
RE: 💬 Building a Raspberry Pi Gateway
@gohan Sorry, I did not see your reply earlier. I tried an ethernet gateway in node-red a while ago and could never get it to work with Vera. There was some port conflicts or something. I have never played with mqtt. I need to learn it at some point but I am hoping to finish this project so I can move on to some others. Do you think I will gain significant advantages by using that over a serial/usb gateway?
-
RE: 💬 Building a Raspberry Pi Gateway
@mfalkvidd Thanks. I thought about doing something like that but I wasn't sure that was the best process or if something should be modified during the install. I'll give it a shot this way though. Thanks again.
-
RE: 💬 Building a Raspberry Pi Gateway
I am new to Linux and hopefully have an easy question...
I have followed the build instructions and everything seems to be working well so far. One issue I'm having is getting node-red to see the usb port (/dev/ttyUSB020). I did some searching online and found that if I run the following command node-red will see the port and things start working.sudo chmod 666 /dev/ttyUSB020
The problem is that each time I reboot the Pi the command needs to be run again. Does anyone have any ideas on how I can resolve this so I don't need to run the command each time the system is booted? Thanks in advance.
-
RE: 💬 Bed Occupancy Sensor
@Nicolas-M. Yeah, they are definitely cheap. I can't remember why I wanted to do one. I guess because it was working and there was less to do.
One thing I would change is I wouldn't use the copper tape any more. I have found that it gets damaged (cracked/separated) rather easily. I have actually switched to a stranded copper wire (18ga I think) that I have removed from the housing and spread out flat. I make sure it's overlapping itself in somewhat of crisscross pattern. That way if one of the wires breaks it still will make connection with other wires. Hopefully that makes sense. -
RE: 💬 Bed Occupancy Sensor
@Nicolas-M. I never tried it. I looked into it but didn't use it because I wanted to use the same device to monitor both sides of the bed. I have wondered this on occasion as well. It would be worth looking into if you decide to build one.
-
RE: How To - Doorbell Automation Hack
@Mister_ik You're not missing anything. It wasn't designed to do what you're describing. That is an interesting idea that I never thought of though! It shouldn't be too hard to implement if you wanted to try. I'm not sure which device types are available in Domoticz but I would think you would want to use some sort of momentary button press (rather than an on/off switch) in Domoticz. You could then send that to the sensor and when it receives the command it could trigger the relay. Have a look at the relay actuator code if you haven't done this before. https://github.com/mysensors/MySensors/blob/development/examples/RelayActuator/RelayActuator.ino#L82
-
RE: 💬 Rain Gauge
@itbeyond Like @mfalkvidd pointed out eeprom writes are done to multiple locations so it actually gets 120 hours before the same eeprom location is used. So, 120 X 100,000 is over 1,000 years (if my math is right). That should be enough
The good thing about using eeprom is that you won't loose any data if your gateway is down or the communication is lost for some reason.
I think you are correct debugging other areas like the DHT. Also, is there a chance your arduino got wet? That could also cause issues.
-
RE: Relay on when starting up
@archiijs can you post a picture of the wiring? My relays have two ways to connect- one keeps the circuit closed and the other open. Also, you mentioned you come home and the lights are on. Can you give more details about that?
-
RE: Why I quit using MySensors for actuators
I realize this thread is getting old but I'm behind in my reading...
I just wanted to say that I have been using actuators (irrigation, lighting, motors, etc) for years and I have had nearly flawless results (at least as good as my z-wave stuff, if not better). I don't want to start any arguments but just wanted to let everyone know that it is possible to use MySensors for actuators in case you haven't tried it. I'm actually pretty surprised that people seem to be having issues with actuators as mine have been working well.
I did find that modifying the NRF antennas as well as using repeaters has helped in some of the devices that are far away from my gateway.
Hopefully this doesn't come across the wrong way, just wanted to give some encouragement to not give up -
RE: Controlling Blinds.com RF Dooya Motors with Arduino and Vera
@かいと The pattern for the control may have changed...? Because you have a recording of the remote I would try to record what you are sending with your transmitter and compare the waveform of the two devices. They should be identical. That is how I ended up figuring out the exact timing needed for my motors.
-
RE: $8 Lamp (Outlet) "Smart Plug" Module
@dseveriano Yes, the red board is the relay board which will control your 220V power.
I haven't done much with current detecting but the module I was playing with was the ACS712. I found that even when no power was running through it there was still a few watts reported. Maybe that's a simple fix but I never really looked into it. -
RE: $8 Lamp (Outlet) "Smart Plug" Module
@dseveriano Sorry, I'm not sure what you're asking. What board are you referring to?
-
RE: $8 Lamp (Outlet) "Smart Plug" Module
@dseveriano as always you need to be very careful when using these voltages. That being said, this should work without any other hardware except for a phone charger rated for 220 (which I believe most are). The relay I used was rated for 10A 250VAC. I wouldn't go as high as 10A though.
-
RE: 💬 Rain Gauge
@itbeyond said in Rain Gauge:
I needed this on my irrigation controller also - same problem with a 10cm cable to a push button.
Interesting. I haven't experienced this behavior with any of my devices yet. I do power most of my sensors with my whole house power supply though so I guess that would explain it.
I will update the rain gauge page and also add this info to the troubleshooting section. Thanks for your help with this!
If anyone needs a visual of what @itbeyond described above here is the wiring diagram.
-
RE: 💬 Rain Gauge
@itbeyond I don't know if it's the best but I use Fritzing to do my diagrams. It is very easy to learn and easy for new people to understand.
@user2684 I am powering my with a good power supply and I believe it's on the vcc pin (not using the ftdi adapter). Maybe you want to try that?
@flopp based on what others are saying here I suggest you try changing the power supply as well. Also, are you powering the radio from the arduino or from the power source? If you don't have one already I would add a 100uF capacitor on the radio.
-
RE: Extending range of regular nRF24L01+
@Tmaster said in Extending range of regular nRF24L01+:
cover the module with aluminium foil ,and leave antenna outside aluminium
This is very good advice if using the PA version. One of my PA radios was so bad it was actually took down my z-wave network network (yes, z-wave is 900MHz). After wrapping with aluminium foil (and grounding that) it works beautifully.
-
RE: 💬 Rain Gauge
@flopp What other types of nodes is this happening on? I'd definitely suggest updating to the latest version of the Beta code if you're having interrupt issues.
-
RE: 💬 Rain Gauge
@flopp & @user2684 Hmm. Strange. Mine has been running for around 2 years and I have never noticed this behavior. I live in an area where we get lots of nice weather so I'm sure I would have noticed it if it were happening to me. I know that's not helpful for you but hopefully we can get this fixed...
I don't have any great ideas on how to fix this but you may want to try updating to the latest MySensors bata library. There were some updates recently that fixed some interrupt issues.
Also, since this was not happening indoors is it possible that there is something else causing this issue like wind or heat?
Lastly, did you make any changes to the code or wiring for your sensors? -
RE: Video How To: Battery Powered Chair Occupancy (Contact) Sensor
@Jic In addition to the great suggestions above also try to disconnect all the sensors and measure again. I had two bad radios that were using way too much power. Bad clones I guess.
-
RE: Video How To: Battery Powered Chair Occupancy (Contact) Sensor
@Nca78 Wow, cool.
I never got readings down to 2uA. Maybe my multimeter isn't very good or something else...?The main reason I regularly report the battery is to provide a heartbeat as well as reset the sensor if for some reason it could not communicate with the gateway the first time.Edit: I just re-read your post. I now see that you were saying I could save those additional uA by not using the sleep. That is a good idea. I'm still a little torn on the idea because I like the assurance of the heartbeat. I'll have to think about it. Thanks for sharing though!
-
RE: Video How To: Battery Powered Chair Occupancy (Contact) Sensor
@pgregg88 said in Video How To: Battery Powered Chair Occupancy (Contact) Sensor:
I experimented with the following, but my knowledge of 2.2 and interrupt challenges is limited. My attempt was to reduce the sensor state checks from 3 to 1, but I failed at that. I assume it might be better to change the approach, but didn't want to start hacking your code goodness with my lack of 2.2 knowledge.
If you're using this for contact or motion sensors I would remove most of my code as it's not needed. For the motion sensor code it can be really simple as you don't even need a debounce. Check out the motion sensor sketch in the MySensors library. Really all you need is a digitalRead then send that value.
For the contact sensors I would just use a wait(20); and then read the sensor again to make sure it's still the same value (or you could use the debounce library). You can also check out the code in the binary sleep sensor and pull from that https://github.com/mysensors/MySensors/blob/development/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino#L94 -
RE: Video How To: Battery Powered Chair Occupancy (Contact) Sensor
@Samuel235 thanks
I love MySensors and have so much help over the years from everyone. I try to help when/where I can. I may not be the best at coding but I do know how to make videos (well, better than I code at least ). -
Video How To: Battery Powered Chair Occupancy (Contact) Sensor
I finally got around to making my first battery powered sensor (after 3+ years ) and I thought I'd make a video on how I did it. I'm amazed how easy it was and I'm not sure why I didn't do this sooner… I am using the sensor to monitor my dining room chairs so I can better automate the lights in that room (check out the video for more details).
If my calculations are correct (and it's entirely possible they aren't) this sensor should run for about 3 years on 2 AA Alkaline batteries. Here is my math if anyone is interested (or wants to correct it). NOTE: I had an issue with one of my radios where it was using a couple if mA when sleeping so make sure you check your setup before finalizing the device so your batteries don't drain in a couple of weeks. You should be getting about 6uA when your Pro Mini is sleeping.
Usage when sleeping =
- 5.8uA (0.0058mA) when contact sensor is open/disconnected
- 10uA when contact sensor is closed/connected with a 1M external pullup resistor
- 100uA when contact sensor is closed/connected with internal pullup resistor
Usage when transmitting =
- 16mA with the NRF radio set to LOW
I'm estimating a total of 10 transmissions per meal (5 times sitting/getting up). Just for good measure I'll say there will be 4 meals a day which would equal 40 transmissions per day. The sensor is also sending a battery level every 4 hours which would give an additional 6 transmissions. So that would give a total of 46 transmissions per day. So, 40/24=1.6667 transmissions per hour with it sleeping the rest of the time.
Here is the equation to get the average mA:
Iavg = (mA x time awake) + (mA x time asleep) / ( 1 hour)
Iavg = (16mA x (1.67 x 2 seconds per transmission) + (.006mA x (1 hour - awake time)) / (7200sec)
Iavg = (16x3.34) + (.006x7196.66) / 7200 = 53.446 mA per hour
Iavg = 53.446 mA per hourBattery Life = Battery Capacity in Milli amps per hour / Load Current in Mill amps * 0.70
From http://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-battery-lifeAlkaline batteries should get around 985 days (32 months). AA alkaline batteries typically have a capacity rating of over 2,500 mAh (each).
Ok, enough of that. Let's get on with the building…
Build Video
$4 Battery Powered Chair Occupancy (Contact) Sensor using Arduino and MySensors – 17:53
— Pete BWiring Diagram
Parts Needed (BOM)
3.3v Arduino Pro Mini
NRF24L01+ Radio
1M Ohm Resistor
Battery holder (eBay) or Battery holder (3D print)
Contact Sensor:- Reed sensor
or - Copper tape
- Metal flashing (local home goods store)
Links/Credits
Arduino_VCC Library link - https://github.com/Yveaux/Arduino_Vcc
Gert Sanders Bootloader's - https://www.openhardware.io/view/33/Various-bootloader-files-based-on-Optiboot-62
MySensors Battery Build Page - https://www.mysensors.org/build/batteryCode
NOTE: Minimum MySensors Library build of 2.2 is recommended for this sensor/** 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. ******************************* NOTE Please use MySensors version 2.2.0 or higher to avoid issues with interrupts and sleep DESCRIPTION Low power/battery operated contact switch - Send heartbeat (battery & sensor status) every 4 hours - Send contact switch status after performing 3 checks to make sure it's not someone shifting in the chair - Uses approximately 5.8uA when sleeping VIDEO To watch a video on how to make this sensor go here: https://youtu.be/uz3nBkRKSkk */ #define SKETCH_NAME "Chair Sensor" #define SKETCH_VERSION "1.0" // 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_LOW //Options: RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX #define MY_RF24_CHANNEL 76 #define MY_NODE_ID 1 //Manually set the node ID here. Comment out to auto assign #define MY_TRANSPORT_WAIT_READY_MS 3000 //This will allow the device to function without draining the battery if it can't find the gateway when it first starts up #define MY_BAUD_RATE 9600 //Serial monitor will need to be set to 9600 Baud #include <MySensors.h> #include <Vcc.h> #define CONTACT_CHILD_ID 0 #define CONTACT_PIN 3 // Arduino Digital I/O pin for button/reed switch #define CONTACT_CHILD_NAME "Chair Sensor 1" //The name of this specific child device will be sent to the controller #define DEBOUNCE_DELAY 1200 //DO NOT SET BELOW 1000! Amount of time to sleep between reading the contact sensor (used for debouncing) #define BATTERY_DELAY 14400000 //(4 hours) Amount of time in milliseconds to sleep between battery messages (as long as no interrupts occur) //#define BATTERY_DELAY 60000 uint8_t oldContactVal = 2; //Used to track last contact value sent. Starting out of bounds value to force an update when the sensor is first powered on uint8_t contactVal[2]; //Used for storing contact debounce values uint8_t contactTracker = 0; //Used as a sort of debounce to stop frequent updates when shifting in chair int8_t wakeVal = 0; //Used to determine if wake was from timer or interrupt const float VccMin = 1.9; // Minimum expected Vcc level, in Volts. (NRF can only go to 1.9V) const float VccMax = 3.3; // Maximum expected Vcc level, in Volts. const float VccCorrection = 1.0 / 1.0; // Measured Vcc by multimeter divided by reported Vcc Vcc vcc(VccCorrection); MyMessage msgContact(CONTACT_CHILD_ID, V_TRIPPED); void presentation() { // Present sketch name & version sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); // 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(CONTACT_CHILD_ID, S_MOTION, CONTACT_CHILD_NAME); } void setup() { //Set unused pins low to save a little power (http://gammon.com.au/forum/?id=11497) for (uint8_t i = 4; i <= 8; i++) { pinMode (i, INPUT); digitalWrite (i, LOW); } // Setup the button and activate internal pullup resistor //pinMode(CONTACT_PIN, INPUT_PULLUP); //(Uses 100uA in sleep) pinMode(CONTACT_PIN, INPUT); //Use this with an external pullup resistor (uses 10uA in sleep) float p = vcc.Read_Perc(VccMin, VccMax); #ifdef MY_DEBUG Serial.print("Batt Level: "); Serial.println(p); #endif sendBatteryLevel((uint8_t)p); //Send battery level to gateway } void loop() { //Read the value returned by sleep. If it was a timer send battery info otherwise if (wakeVal < 0) { //Woke by timer, send battery level and current state of contact sensor float p = vcc.Read_Perc(VccMin, VccMax); #ifdef MY_DEBUG float v = vcc.Read_Volts(); //Only using this for debugging so we don't need it taking up resources normally Serial.println("Woke by timer."); Serial.print("VCC = "); Serial.print(v); Serial.println(" Volts"); Serial.print("VCC = "); Serial.print(p); Serial.println(" %"); #endif sendBatteryLevel((uint8_t)p); //Send battery level to gateway send(msgContact.set(oldContactVal ? 0 : 1)); //Send current sensor value wakeVal = sleep(digitalPinToInterrupt(CONTACT_PIN), CHANGE, BATTERY_DELAY); //Go back to sleep } else { //Woke by interrupt, send contact value if (contactTracker < 2) { contactVal[contactTracker] = digitalRead(CONTACT_PIN); #ifdef MY_DEBUG Serial.print("contactVal: "); Serial.println(contactVal[contactTracker]); Serial.print("contactTracker: "); Serial.println(contactTracker); Serial.println("Sleeping"); #endif contactTracker++; //increment contact tracker sleep(DEBOUNCE_DELAY); //sleep until next read //wait(DEBOUNCE_DELAY); } else { contactTracker = 0; //Reset contact tracker uint8_t readValue = digitalRead(CONTACT_PIN); #ifdef MY_DEBUG Serial.print("contactVal: "); Serial.println(readValue); #endif if (readValue == contactVal[0] && readValue == contactVal[1]) { //All values are the same, send an update #ifdef MY_DEBUG Serial.println("Values the same"); #endif if (oldContactVal != readValue) { #ifdef MY_DEBUG Serial.println("Contact changed. Sending to gateway"); #endif send(msgContact.set(readValue == LOW ? 1 : 0)); oldContactVal = readValue; } } wakeVal = sleep(digitalPinToInterrupt(CONTACT_PIN), CHANGE, BATTERY_DELAY); //Go back to sleep } } }
-
RE: My sensors 2.1.1
Wow, a lot has changed since that video. I probably should just remake it. YouTube is getting rid of annotations soon so that wouldn't really work that well.
Now I just need to find some time to remake the video...
-
RE: My sensors 2.1.1
Sorry for the delayed reply. I missed this thread. I am happy to add more info I'm just not sure what is the best way to do that is. First off, @livinlowe which video were you watching? I'll watch it again and see if there is anything I can do to make it more clear. It may require making an updated video...
-
RE: Low Voltage Whole House Power Supply
@JonnyDev13 said in Low Voltage Whole House Power Supply:
So do you basically have one ethernet cable going to each room
Sort of. I actually have access to almost all of my rooms from the attic so I run the individual stands of cat5 to the sensors that are spliced in to the "main" cat5 line to the basement. I also have a thicker 18 gauge wire running 5v power from the whole house power supply that powers all the sensors. So, it is cat5 for power and "data" to the individual sensors that are connected to the main lines from the basement. Many cat5 cables are connected to the one 18ga power line with wire nuts. Labeling your wires is key here. It can turn into a rats nest fast too. Hopefully that makes sense.
What was the trouble with the temperature sensors?
I'm not sure. It would work for a while (weeks) then all of a sudden they would stop working. I tried various resistors and always powered them from the whole house power supply. I eventually just gave up and rewired them when I put my whole house fan in.
-
RE: Low Voltage Whole House Power Supply
@JonnyDev13 I use cat5 or cat6 wires for my contact sensors. I also use it for my PIR motion sensors which all go back to one node. I'm not sure of the exact number but I probably have about 25 contact and PIR sensors going to my one node (an Arduino Mega). Temperature is a little trickier and I originally had all my Dallas sensors going back to the one main node I have now spilt them by floor and they are performing much better.
To save space in my conduit I have run separate cat5/6 wires to my attic and I spliced in all the PIR and contact sensors there for my upper floor. As far as distance I believe my longest PIR sensor is about 60 ft or so and I've never had any issues. The Dallas sensors are more like 30 ft and I've limited them to 3 per node. -
RE: Still not going well for me.
@Coffeesnob I didn't look at your logs in too much detail (I still don't have the codes memorized) but like @hek is noticing you may not be getting a node id back. You could also try assigning a static node ID like this:
#define MY_NODE_ID 1
Also, try adding a 40uF or 100uF capacitor to the radio. The new 2.1.1 library is much more efficient and can use more power in shorter periods (because it can transmit faster).
-
RE: 💬 Various bootloader files based on Optiboot 6.2
@GertSanders Awesome, thank you for uploading it as a .rar!!! So easy now
@Samuel235 You should be able to just copy the entire folder from the .rar file into your Arduino folder. I had to create a "Hardware" folder as it didn't exist. I'm on Windows 10 and it looks like this:
After closing/re-opening the Arduino IDE it looks like this:
-
RE: 💬 Various bootloader files based on Optiboot 6.2
@GertSanders I am finally getting around to trying some of these bootloaders. Thanks for making them! Would you mind posting the latest .zip file to the openhardware site? I started with those files and was getting the same errors as others mentioned. As I got further down this thread I noticed I was missing some files.
Thanks again for making these! -
RE: Still not going well for me.
@Coffeesnob said in Still not going well for me.:
I am using a relay module and I can happily turn relays on using MYSController but can't seem to figure out how to turn them off.
Can't you just send a 0 instead of a 1? I don't ever use MYSController for controlling devices. Only for monitoring traffic. All my control is done with Vera. That being said though you should only need to send a 0 to turn off the relay.
-
RE: Still not going well for me.
@Coffeesnob Sorry for the delayed reply. I was in the mountains the last few days. I'm glad you got it working! There are a lot of different factors at play when designing your own sensors and learning something new can take time but I think you are over the biggest hurdle now.
@mfalkvidd thanks for updating the documentation. You are awesome!
-
RE: Still not going well for me.
@Coffeesnob Yeah, I would order a couple of Nanos (or Pro Minis). They are cheap and are always helpful for troubleshooting.
Here is how I have my devices wired:
*need to configure these pins in the sketchHere is the code you will need to configure the sketch of the Mega. Make sure to put these lines above the #include <MySensors.h> line.
#define MY_RF24_CE_PIN 49
#define MY_RF24_CS_PIN 53
You should not need to change anything in MyConfig.h if you wire as described above.The Nano can be wired as described above and no changes need to be made in your sketch or MyConfig.h. This code assumes you are using MySensors 2.x.
I hope that makes sense.
As for a MYSController video, I'm not aware of any out there yet. I have it on my list of videos to make but it's not at the top...
-
RE: Still not going well for me.
@Coffeesnob If you can, you may want to try using two nanos or pro minis before trying to use the Mega. Mega's can be tricky to get right the first time. Also, where are you defining the radio pins for both of the sketches? Did you do it in myconfig.h? If so, did you change it back when you uploaded the nano code?
-
RE: 💬 Bed Occupancy Sensor
@diamantmatch It's the BareConductive library https://github.com/BareConductive/mpr121 (see the comments in the code for more info)
-
RE: [SOLVED] After upgrade to mysensors 2.1 problems with radio module might manifest itself more.
@Nicklas-Starkel I recently updated my Mega sensor (that had been running for months without any issues) to 2.1 and experienced issues with NACKs too. It would work for a little while (half a day or so) then the NACKs would start appearing. A few hours after the NACKs showed up it would then only produce NACKs. I seemed to have finally resolved the issue by switching the 4.7uF capacitor with a 47uF on the NRF radio. It has been running for 3 days without a single NACK. I know it's not the same issue you're having but maybe something to try. By the way, the capacitor is soldered right to the radio pin headers.
-
RE: Send msg in background
@zsakul Try downloading the latest version from github. The master branch will be updated to version 2.1 very soon and I recommend waiting for that. https://github.com/mysensors/MySensors/tree/master
Once you have updated you should be able to use MY_TRANSPORT_WAIT_READY_MS in your code. I have it working in my device.
You could change MY_TRANSPORT_WAIT_READY_MS in the myconfig.h file but if you do it there every node you build will have this setting (which my not be desired).
-
RE: How To: Make a Simple/Cheap Scene Controller (with video)
@Matt-Pitts I still haven't had time to convert/test the sketch for version 2.0. If you want to take a shot at it there is info here: https://forum.mysensors.org/topic/4276/converting-a-sketch-from-1-5-x-to-2-0-x
I will get to it eventually I just have other projects that are consuming my time right now. Sorry.
-
RE: Send msg in background
@zsakul I know this is really late but I was just doing a search and came across your post. Hopefully you have found the solution but if not you need to put "#define MY_TRANSPORT_DONT_CARE_MODE" above #include <MySensors.h> in your code. Also, MY_TRANSPORT_DONT_CARE_MODE has been replaced by MY_TRANSPORT_WAIT_READY_MS 1 in the most recent version.
-
RE: Safe In-Wall AC to DC Transformers??
@MattNY Great, thanks for posting! Let us know how it goes and if you think it's good I'll add it to the first post in the thread.
-
RE: Irrigation Controller (up to 16 valves with Shift Registers)
@Andrej_AB Can you post the full log from your sensor? The device is never getting presented in what you've posted so far. I don't have enough time to dig in to the code to know if this will help but can you try moving
void presentation() { sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); for (byte i = 0; i <= NUMBER_OF_VALVES; i++) { present(i, S_LIGHT); } }
so it's above
void setup()
I still haven't updated my irrigation controller to 2.0 yet so I haven't tested any of the code.
-
RE: 💬 Insulated Whole House Fan
@rechin304 Awesome! Glad you got it working!!
-
RE: Irrigation Controller (up to 16 valves with Shift Registers)
@Andrej_AB It looks like it's communicating ok because it's getting the time. Have you ever had a mysenors node #5 in your Vera previously and deleted it? Could it be that the Vera thinks it's already there? What happens if you clear your eeprom on your irrigation controller then manually assign a different ID and then try to pair it again?
-
RE: Irrigation Controller (up to 16 valves with Shift Registers)
@Andrej_AB I'm using 1.6.12 but I haven't changed my node to 2.0 yet.
What is the issue you are having with pairing? Do you see the presentation messages on your gateway? Do you have other nodes successfully paired with your Vera? -
RE: Rain Guage
@esawyja No, currently this example is written to be powered by external power so it wouldn't work well with batteries.
-
RE: Newbie Code Question: How is motion sensor tigger controlling code flow?
Yes, that is correct. I wanted more control over when the light gets turned on and at what brightness. The motion sensor just sends the triggered state back to the controller and the controller decides to turn the lights on. This keeps the lights from turning on when I'm sleeping
-
RE: How To: Make a Simple/Cheap Scene Controller (with video)
@dvr123 No, not yet
My thermostat project has taken priority over everything because I need one in my house. I have a prototype working but I need to finish it. It is taking much longer than expected and I also haven't had much time lately. Sorry. -
RE: 💬 Insulated Whole House Fan
@rechin304 Sorry, just to make sure I understand, are you saying it works with a DHT22 or not? I may still be on an old library too.
-
RE: Irrigation Controller (up to 16 valves with Shift Registers)
@bsivley Are you using the libraries from the MySensors github page (https://github.com/mysensors/MySensorsArduinoExamples/tree/master/libraries)? I just compiled it without any errors. What version of the Arduino IDE are you using? What version of MySensors are you using?
-
RE: partial upgrade of nodes to v2.0 library?
I'm running a mixed setup of 1.5 and 2.0. it's not recommended but it may give you a little grace period while you upgrade everything (don't run in this configuration long term). I upgraded my gateway and I'm working on the sensors slowly. Everything is working fine for now.
-
RE: 💬 Insulated Whole House Fan
@enlo Thanks. Yeah, it's acrylic glass (Plexiglas). It was a pain to use though as I couldn't clean off the paint very well. My next project I'm working on I'm going to try to use regular glass.
-
RE: 💬 Insulated Whole House Fan
@rechin304 Something is most likely wrong with your wiring or the sensor. I am using a DHT22 without any issues in my rain gauge which is on 2.0 (I'm using the most recent beta release). Try connecting a 4.7k resistor between the data pin and power on the DHT like this.
-
RE: Pro mini
@micah I have had this happen to a couple of mine too. It only takes a few times before I learned never to apply 12v to the raw pin
I have been able to revive all of my pro minis by soldering on a new capacitor here: