just received 1st test unit. very nice quality. now i need to find / make a case for it. @berkseo, do you happen to have a case design yet?
Posts made by rchamp
-
RE: 💬 EFEKTA Motion sensor
-
Diy remotes
Hey there, I've successfully converted just about everything in my house to with zwave sensors or homebrewed mysensors modules for lighting / temp hum, motions, etc.
The trouble I've been having is sourcing /building a multi button remote.
It's either go with a very expensive and at times not the most functional /attractive zwave device or build a clunky diy multi button MyS module that is just to large to be practical.
Has anyone taken the plunge to build a small battery powered multi button sensor? Seems the challenge is using a button array to wake the module with the single interrupt. I've been starting to dig into potentially using an i2c module but then size starts becoming an issue. I've been keeping my eye on a few projects in the open hardware group, but are still a little too hacked together. Smd soldering is easy but unfortunately I don't have the time to learn how to build a pcb from scratch.
How difficult is it to build an i2c io multiplexer? Ideally we have someone with better eagle skills than mine (close to none) that can combine emccubes mysgrowled sensor and a i2c multiplexer onto a single board
I feel this is one area we need to focus on more to make this project whole.
Anyone have projects or ideas they can throw my way. I'm going to be doing some serious digging later this year to try and make something useful to the community
-
RE: 💬 MySGrowLED - MySensors control for Grow Lights or Greenhouse
scratch that. i'm a ditz, apparently. i had the LEDs wired up the wrong way. i had the positive wire of the LED wired to the LED port on the board. i switched the negative was wired to the LED port on the pcb and voila! LED's work.
now i'll need to tinker more and play with fan PWM and other outputs on it.
Thanks for being a sounding board!
-
RE: 💬 MySGrowLED - MySensors control for Grow Lights or Greenhouse
bummer.
is the pro mini always output 3.3v on the pins? even if i switch in arduino IDE to 5V 16mHz?
-
RE: 💬 MySGrowLED - MySensors control for Grow Lights or Greenhouse
@rchamp i also noticed on the MOSFET mentioned (IRLZ44N) and the one i'm using (L7812CV) that the drain is in the middle, not the far side, but the wiring schematic shows ground on the far side, not the middle.
am i missing something? i have 2 boards wired up. one with default pins, and one where i've switched the drain and the source to match the PCB. however it seems as the 3.3v coming from pin 5 isn't enough to trigger the switch. any ideas and clarifications would be helpful. i'm still very green to microelectronics
-
RE: 💬 MySGrowLED - MySensors control for Grow Lights or Greenhouse
Hi there, just wired up my first one. i am very interested in this PCB as the form factor is quite nice.
however, i'm running into an issue with the MOSFET not firing. i checked voltage to the gate and i'm transmitting 3.3v. i think that isn't enough to activate the switch. has this been the case for you or others?
-
RE: Controllingood power to moisture sensors
I'm in the 2.0 code. I'll have to play around some more and do some tests over the next few weeks. I like using the intermediary modules to generate a binary alert vs doing the analog reads. Seems faster to calibrate based on the moisture levels I need for different plants. However, the battery drain of those modules is crazy.
I'll do some current measements aND report back. If the consumption is too high for the pro mini digital out, I reckon I can use a mosfet to control power to the modules and power it on and wait a little before getting my reads. I think that will be the fastest solution and least path of resistance (no pun intended)
-
Controllingood power to moisture sensors
Hi there,
I just recently built a battery powered moisture sensor with 2 of the sensors posted on the site.
Detection is quite accurate and I didn't need to tweak much. However, I noticed they draw quite a bit of power even with removing the leds.
Anyone have ideas how I can modify my code to leverage powering them using digital out pins vs vcc to turn them on after sleep and off before going to sleep? Currently 2 AA batteties will only last a week with the APM sleeping at 15 min intervals? I need to check to see if the APM can handle the current of each sensor. Haven't hooked up the multimeter to test draw quite yet but and looking for ideas.
Many thanks -
RE: Q: neopixel color change based on relays (lights) in vera
thsnk you for the input. how does the interface look in vera? I'm not too clear on using the V_var options. I do like doing this through a single sensor vs trying to use different.
I think my biggest problem right now is understanding how to write the code to understand the differences of the messages coming in from vera/the myS gateway
-
Q: neopixel color change based on relays (lights) in vera
Hi there, i created a very crude sensor that connected to a strip of neopixels. i have it simply fade to white when the light is pressed on and fade to black (off) when pressed off in vera.
However, i've tried to now create some more "relays" as switches to allow me to trigger different light effects/modes, but i don't know how to create a switch, or case to check "when relay 1 on, color mode 1, relay2 on color 2, etc" It always reads a general 1 or 0, regardless of which light send the command from vera.
Any ideas on how i can change the code in the receive function to listen to each switch(relay) and then trigger a different condition from there?
below is my 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 * * DESCRIPTION * Example sketch showing how to control physical relays. * This example will remember relay state after power failure. * http://www.mysensors.org/build/relay */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 12 // Enable repeater functionality for this node #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <Adafruit_NeoPixel.h> #define LED_PIN 5 #define RELAY_1 1 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 4 // 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 NUM_LEDS 60 //60 for full cabinet set #define ledFadeTime 5 #define BRIGHTNESS 100 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800); int gamma[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114, 115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142, 144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175, 177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213, 215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 }; void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { strip.setBrightness(BRIGHTNESS); strip.begin(); strip.show(); // Initialize all pixels to 'off' } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Kitchen Island Lights", "1.0"); 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_LIGHT); } } void loop() { } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // 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()); int showState = message.getBool(); Serial.print("Newstate variable data:"); Serial.println(showState); if (showState==1) { //rgbFadeIn(255, 255, 255, ledFadeTime); // White rgbFadeIn(255, 255, 255, ledFadeTime); // orange //colorWipe(strip.Color(255, 255, 255), 50); // White }else{ rgbFadeOut(255,255,255,ledFadeTime); //colorWipe(strip.Color(0, 0, 0), 50); // Black/off } } } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } } void rgbFadeIn(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) { for(uint8_t b = 0; b <255; b++) { for(uint8_t i=0; i < strip.numPixels(); i++) { strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255); } strip.show(); //delay(wait); } } void rgbFadeOut(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) { for(uint8_t b=255; b > 0; b--) { for(uint8_t i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, red * b/255, green * b/255, blue * b/255); } strip.show(); //delay(wait); } }
-
RE: 💬 Easy/Newbie PCB for MySensors
Only issue I've have was with resistor to D3 which I don't use. My first board I put a resistor there and when doing a trace noticed I was constantly getting regulated 3.3v and it fried my dht11. Might Have been I interpreed the purpose of it wrong as I am new to electrical engineering, but I digress. I just power the dht of of vcc and gnd in prototype area and wire sensor outpUT directly to D3 breakout. No resistor.
My biggest challenge is finding/building quality quick connects for quick changes and mods /addons. I've reverted to Barrel connectors as they're easily available and can get pigtail versions and panel mount Versons easily
-
RE: 💬 Easy/Newbie PCB for MySensors
I agree with sundberg84 here. Would it be nice to have those other features? Sure, but then you're limited to what else you can do. This is a GREAT board for many/most sensors around the house. And in regards to light or temp/hum, in my experience it's better to have these detached and in better location for detection while keeping "main" board. more out of sight.
I'll post up some pics of my builds for ideas, but I've built sensors with temp/hum, temp/hum/motion (both battery powered running for over 7 months) and my latest a Neopixel multi strip driver for kitchen cabinets using 5v regulated power. And I haven't had any issues with the cheap through hole ceramic caps for .10uf or the electrolytic caps for 4.7 or 10uf sizes on this board
-
RE: Parking Sensor
Hey There, I'm getting ready to play around with this once a few more parts arrive to give me ideas on other potential uses for distance sensor and LEDs, but one thing i'm confused about.
The sketch mentioned using pins 4, 5 and 6.
Adafruit and all docs i've seen and played around with mention that neopixels need a PWM pin to operate.
Pin 4 doesn't appear to be PWM (on pro mini)
I see that trig and echo are typically wired to 5 & 6 in most cases which are PWM.
so in short, not enough PWM pins .Are the neopixels still working because the signal is being sent at "full" brightness?
-
RE: UI5 Mysensors library 2.0 gateway issues
Note. i left the plugin in place, and was able to enroll the node after some time.
I have a feeling it just took Vera / plugin longer than I expected to detect the USB serial connection to the GW.
node ID's seem to come in fine and libversion displays as 2.0.0 for the node. the 2 nodes (+ the updated GW) all appear to be running stable. if i run into another issue i will go for the development branch for the plugin
-
RE: Using a 5v slim battery
understood. i just happened to already have these as 'extras', so i figured i'd build a node and give it a whirl.
I'll definitely do some more research on @ceech his postings.
thx for the insight
-
RE: 💬 Easy/Newbie PCB for MySensors
Just wanted to say great work on this board. I have the first one wired up w/ batteries, 3.3v APM w/led and regulations removed, voltage regulator, dht11 and motion w 3v mod and works wonderfully. Once I get my caliper in, I'll get the right mounting screws, finish my enclosure and post the pics.
-
RE: 💬 Easy/Newbie PCB for MySensors
what is the size of the mounting holes? i don't have a caliper yet to measure this small of a size (ordering on amazon)
-
RE: Using a 5v slim battery
here is the battery pack and solar panel.
6700mAh portable charger
https://www.amazon.com/dp/B00Y2PX4U2/ref=twister_B01E6NLNMU?_encoding=UTF8&psc=115W Solar charger
https://www.amazon.com/gp/product/B01DIP5RBA/ref=od_aui_detailpages00?ie=UTF8&psc=1 -
Using a 5v slim battery
Hey there,
I have an extra ravpower 6700 mah 5v portable charger and an easyacc 15W solar panel charger.
I'm considering trying a 5v node where the panel charges the battery and the battery provides continuous power to a nano (or apm using sundberg84s easy/newbie pcb).
I'll post more info about the battery and solar pack when I'm at my laptop tonight
I plan on the node and components being super low power (mostly soil sensors, rain sensor, air quality, maybe wind) with high sleep times. Theoretically, assuming no overheating and no outdoor heat/water leakage variables to damage components wouldn't this go forever or until a component died?
I did validate that the battery pack can be charged and provide power simultaneously (2A in /2A out).
One thing I don't think I'll effectively accomplish is battery%, due to the embedded circuitry, but was considering doing an led pulse or image capure of leds on battery to have a general idea of %
-
UI5 Mysensors library 2.0 gateway issues
I'm having issues with my new gateway.
I recently updated my gateway node with library version 2.0 and was successful uploading. However, it doesn't look that the device in ui5 is updating. it still shows version 1.5.1
also trying to include my new DHT11/motion node times out
-
RE: Converting a sketch from 1.5.x to 2.0.x
@hek it's actually a close nano with an FTDI board connected via serial inputs. I had this directly connected to my Vera, and communication with my old sensors was working just fine.
EDIT: Fixed. All in all, it was user error. I was trying to connect through FTDI adapter. I unplugged FTDI board, connected USB directly to nano clone, and upload worked fine.
Do I need to update mysensors plugin as well on Vera UI5?
-
RE: Converting a sketch from 1.5.x to 2.0.x
I'm trying to upgrade my gateway to 2.0, but every time I go to upload, I get a 'error' not in sync.
I'm using just a standard nano w/ NRF24.
Note, my hardware profile is set properly to nano, 328p and proper com.
I restart app, and switched to my APM hardware profile and loaded my new 2.0 sensor code into my new APM node (DHT11 + motion) and was able to upload no problem.
Is there something i'm missing for the gateway?
Idon'tunderstandwhatwouldcauseittostopbeingabletocommunicate,
-
Log Relay Power Consumption
In Vera, for normal light switches, I can enter a "User Supplied Wattage" so i can estimate the amount of energy consumed "Amount of Watts consumed by dimmable lights in Kitchen over the past month". I'd love to be able to add a field for this for the sensors in my relay sketch.
Is there a way i can report a wattage?
-
battery powered LED notification light
Hi There,
I have an idea to make a battery powered node that I can trigger remotely (like the relay node sketch). However, my scenario is a little different.
I have a contact to a separately battery powered 3 LED circuit (came from a party gag ring that blinks when button is pushed once, and off when pushed a second time). I Soldered some lead wires to where the button was making the connection and can turn it on and off when momentarily closing the circuit active low (if that's the correct terminology).
Is there a way i can use the relay sketch, but somehow let it sleep or consume less power?
It seems from the threads I've been lurking that any time a node needs to receive data from the controller/gw, that it needs to have a dedicated always-on power source.
I already have a basic battery powered 3v circuit (CR3477) with APM, nrf24 and digital contact to control the LED circuit
-
RE: Push button interrupt now functioning properly
strange. I changed the NODE_ID to 1 vs using the default AUTO selection from the gateway, and now I am seeing status in Vera. i think the gateway is having issues properly assigning node IDs. Will have to look into that some other time. Not a big deal for me as I have an excel table of all of my nodes anyway.
here's some photos of my doorbell node
-
RE: Push button interrupt now functioning properly
I made that change and removed writing the pin to HIGH.
However, in both cases, while i'm correctly seeing reads in the serial monitor, I'm not getting any status change on the motion created in VERA. I did a clean inclusion to vera (the node and sensor were never added to vera prior) and did the normal, include, reload and then turn on and off the sensor to get the sensor name and version details)
Serial monitor reports normal, but not vera.
Ideas?!
-
RE: Push button interrupt now functioning properly
I'm getting some better results. Right now i have a .sleep(20) prior to reading the input.
I also set the interrupt to detect on FALLING edge. Seems to be more stable.
However, about one out of every 10 times i push the button i get a "1, 0,1" instead of a "1,0" .
I then changed the pinMode to "INPUT_PULLUP" vs just "INPUT". I also changed the interrupt condition back to "CHANGE" and that seemed to do the trick to reliably capture button presses. Thanks for the quick response!!
Here's a snapshot of my working code for reference for others that may experience my trouble
/** * 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 * * Interrupt driven binary switch example with dual interrupts * Author: Patrick 'Anticimex' Fallberg * Connect one button or door/window reed switch between * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other * one in similar fashion on digital I/O pin 2. * This example is designed to fit Arduino Nano/Pro Mini * */ #include <MySensor.h> #include <SPI.h> #define SKETCH_NAME "Binary Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define PRIMARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3) #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif MySensor sensor_node; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); void setup() { sensor_node.begin(); // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT_PULLUP); // Activate internal pull-ups digitalWrite(PRIMARY_BUTTON_PIN, HIGH); // Send the sketch version information to the gateway and Controller sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER); // Register binary input sensor to sensor_node (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. sensor_node.present(PRIMARY_CHILD_ID, S_DOOR); } // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; // Short delay to allow buttons to properly settle sensor_node.sleep(20); value = digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value sensor_node.send(msg.set(value==HIGH ? 0 : 1)); sentValue = value; } // Sleep until something happens with the sensor sensor_node.sleep(PRIMARY_BUTTON_PIN-2, CHANGE, 0); }
-
RE: Push button interrupt now functioning properly
I'm trying out that sketch now. I'm getting weird results in the serial log. I'm going to try different interupt options instead of CHANGE to see if that helps
-
RE: Push button interrupt now functioning properly
to add to this, is it an issue with the debouncer and the interrupt? i'm still a bit mystified about the debouncer library
-
Push button interrupt now functioning properly
Hi there, I just finished building my push button sensor to act as a doorbell for my system.
I used the basic binary switch sensor example as my basis. I have it connected to pin 3 on my arduino pro mini clone. When reading the serial logs, i learned that the pin registers high (1) when not pushed, and low (0) when pushed. So, i changed the send from 1:0 to 0:1 to send the correct state to Vera. all works fine there.
When i tried to implement the sleep with interrupt, it seems as if the arduino sleeps indefinitely and does not wake upon state change (button push).
Any idea as to why?
Here is my 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. * ******************************* * * 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 */ #include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define CHILD_ID 3 #define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #define NODE_ID 20 #define SLEEP_TIME 120000 MySensor gw; Bounce debouncer = Bounce(); int oldValue=-1; // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(CHILD_ID,V_TRIPPED); void setup() { gw.begin(NULL, NODE_ID, false); // 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); // 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. gw.present(CHILD_ID, S_DOOR); } // 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 Serial.println("Value = "); Serial.print(value); gw.send(msg.set(value==HIGH ? 0 : 1)); oldValue = value; } // Sleep until something happens with the sensor gw.sleep(BUTTON_PIN-2, CHANGE, SLEEP_TIME); }
-
RE: Moisture Sensor and relay node. Relay becomes unresponsive
Thank you,
I changed the code to this:
previousMillis = currentMillis; flipPolarity(true, flip1, flip2); gw.wait(10); int val1 = analogRead(sensorPin); gw.wait(10); flipPolarity(false, flip1, flip2); gw.wait(10); int val2 = 1023 - analogRead(sensorPin ); gw.wait(10);
and
int soilReading = senseSoil(SENSOR_PIN, VOLTAGE_FLIP_PIN_1, VOLTAGE_FLIP_PIN_2); // perform soil reading
At first, it seems to work. but then again after a couple of minutes the issue comes up.
I've commented out my moisture sensor code and the relay works flawlessly. I might end of caving and use one of those prebuilt moisture modules i've seen others use, but i wish i understood why my code isn't working. I'm by no means a programmer.
-
RE: Relay_Actuator add second relay?
thank you. i corrected my code to not enable as a repeater
-
Moisture Sensor and relay node. Relay becomes unresponsive
Hi There,
I'm new to the MySensors world. I've successfully brought up a gw node connected to my vera and 2 sensor nodes; a barometric pressure sensor outside, and a temperature sensor inside the house all connected to my Veralite controller running UI5.
I have since then dove into trying to get my next project working, a sensor node with a relay and a home made moisture sensor.
After trying just the relay first, i got that up and enrolled in my vera. Yay! i could send and receive data into Vera and i could locally control my relay with a button. Cool! So the next step was to work on adding my moisture sensor. This has been troublesome for me.
After hours of working on it over the weekend, i successfully got the second sensor on the node to add to Vera!
However, after just a couple button presses of the "light switch" from the web UI, or from my AuthomationHD app, the relay will not work. It seems as if the information is not making it to my node.
Below is my code. Anyone have any ideas?
I've been browsing the forum and the MySensors API, but i'm a bit stumped.
I've also noticed that my moisture sensor is not staying within the range i have mapped (at least as it reports to Vera web UI). Perhaps that has to do with how the S_HUM and V_HUM templates work? Anyone know where i can find more info on these?
Right now i'm using a bare ATmega328P so i dont have Serial debugging until another ESB TTL module arrives from China (had to use my one that i had to get the gw working since i had a clone nano and Vera didn't understand the chipset of the onboard USB)
#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> //#include "Bounce2.h" char SKETCH_NAME[] = "Patio Plant Node"; char SKETCH_VERSION[] = "0.5"; // Define Relay states #define RELAY_ON 1 // switch around for realy HIGH/LOW state #define RELAY_OFF 0 // Define MySensor gateway MySensor gw; // Define relays #define noRelays 1 const int relayPin[] = {4}; // switch around pins to your desire const int buttonPin[] = {3}; // switch around pins to your desire class Relay // relay class, store all relevant data (equivalent to struct) { public: int buttonPin; // physical pin number of button int relayPin; // physical pin number of relay byte oldValue; // last Values for key (debounce) boolean relayState; // relay status (also stored in EEPROM) }; Relay Relays[noRelays]; Bounce debouncer[noRelays]; MyMessage msg[noRelays]; // Define Moisture Sensor #define SENSOR_PIN A0 #define VOLTAGE_FLIP_PIN_1 7 #define VOLTAGE_FLIP_PIN_2 8 #define SENSOR_CHILD 2 MyMessage sensorMsg(SENSOR_CHILD, V_HUM); long interval = 5000; //define timer to delay between reads (60 seconds) long previousMillis = 0; // initialize timer for sense soil method void setup() { // setup sensor as a repeater node. allows for relay functionality by being able to receive messages from Vera gw.begin(incomingMessage, AUTO, true); delay(250); gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); delay(250); // Initialize Relays with corresponding buttons for (int i = 0; i < noRelays; i++) { Relays[i].buttonPin = buttonPin[i]; // assign physical pins Relays[i].relayPin = relayPin[i]; msg[i].sensor = i; // initialize messages msg[i].type = V_LIGHT; debouncer[i] = Bounce(); // initialize debouncer debouncer[i].attach(buttonPin[i]); debouncer[i].interval(5); pinMode(Relays[i].buttonPin, INPUT_PULLUP); pinMode(Relays[i].relayPin, OUTPUT); Relays[i].relayState = gw.loadState(i); // retrieve last values from EEPROM digitalWrite(Relays[i].relayPin, Relays[i].relayState ? RELAY_ON : RELAY_OFF); // and set relays accordingly gw.send(msg[i].set(Relays[i].relayState ? true : false)); // make controller aware of last status gw.present(i, S_LIGHT); // present sensor to gateway delay(250); } // Initialize moisture sensor and components pinMode(VOLTAGE_FLIP_PIN_1, OUTPUT); pinMode(VOLTAGE_FLIP_PIN_2, OUTPUT); pinMode(SENSOR_PIN, INPUT); gw.present(SENSOR_CHILD, S_HUM); // present sensor to gateway delay(250); } void loop() { gw.process(); // relay part for (byte i = 0; i < noRelays; i++) { debouncer[i].update(); byte value = debouncer[i].read(); if (value != Relays[i].oldValue && value == 0) { Relays[i].relayState = !Relays[i].relayState; digitalWrite(Relays[i].relayPin, Relays[i].relayState ? RELAY_ON : RELAY_OFF); gw.send(msg[i].set(Relays[i].relayState ? true : false)); gw.saveState( i, Relays[i].relayState ); } // save sensor state in EEPROM (location == sensor number) Relays[i].oldValue = value; } //moisture sensor part int oldValue = 0; int soilReading = soilReading + senseSoil(SENSOR_PIN, VOLTAGE_FLIP_PIN_1, VOLTAGE_FLIP_PIN_2); // perform soil reading if (isnan(soilReading)) { Serial.println("Failed reading moisture level"); } else if (soilReading != oldValue) { oldValue = soilReading; gw.send(sensorMsg.set(soilReading)); Serial.print("H: "); Serial.print(soilReading); } } //// ************************************************* //// // Process Incoming Message // //// ************************************************* //// void incomingMessage(const MyMessage & message) { if (message.type == V_LIGHT) { if (message.sensor < noRelays) { // check if message is valid for relays..... previous line [[[ if (message.sensor <=noRelays){ ]]] Relays[message.sensor].relayState = message.getBool(); digitalWrite(Relays[message.sensor].relayPin, Relays[message.sensor].relayState ? RELAY_ON : RELAY_OFF); // and set relays accordingly gw.saveState( message.sensor, Relays[message.sensor].relayState ); // save sensor state in EEPROM (location == sensor number) } } } //// ************************************************* //// // Flip Polarity Method // //// ************************************************* //// /* this method flips the polarity of the of the digital output pins to help accurately provide a soil moisture reading */ void flipPolarity(boolean flip, int flip1, int flip2) { if (flip) { digitalWrite(flip1, HIGH); digitalWrite(flip2, LOW); } else { digitalWrite(flip1, LOW); digitalWrite(flip2, HIGH); } } //// ************************************************* //// // Sense Soil Method // //// ************************************************* //// /* When this method runs, a timer will start. when the timer exceeds the interval time set, the reading part will begin during the interval reading, the flip polarity method will run and grab a reading. Then, the flip polarity method will run again and the grab a second reading. Last, get an average and return value to the requester. */ int senseSoil(int sensorPin, int flip1, int flip2) { unsigned long currentMillis = millis(); // set currentMillis to current time if ((currentMillis - previousMillis) > interval) // run rest of method when timer exceeds interval time { previousMillis = currentMillis; flipPolarity(true, flip1, flip2); delay(250); int val1 = analogRead(sensorPin); delay(250); flipPolarity(false, flip1, flip2); delay(250); int val2 = 1023 - analogRead(sensorPin ); delay(250); int averageSoilReading = (val1 + val2) / 2; // map the sensor range to a range of four options: int range = map(averageSoilReading, 0, 1023, 0, 100); return range; } }
-
RE: Relay_Actuator add second relay?
I wanted to clarify that i got it working.
I was browsing through the MySensors API and came across the Processing incomming messages section.
What I interpreted out of the explanation there is that a node acting as a relay actuator NEEDS to be configured as a repeater node in order to run the code needed to interpret incoming messages.
I kept removing the parameters in gw.begin() to make the node a non repeater because i have such a short range between my gateway and the node. Once i updated my sketch to configure the node as a repeater... BOOM! we're up and running!
I did notice when configuring this node in Vera, that i needed to cycle the sensor 3 times to be fully operational. My steps were as follows:
- Delete node and light objects from vera. then Reload Vera.
- Run inclusion on gateway
- turn on node
- power cycle node to auto configure light object in vera to display on/off buttons and get sketch name and node details.
- power cycle node one more time. this seemed to get the sensor and Vera to sync up and report state properly back to UI5. after this everything was working wicked smooth.
Now i need to work on adding in my DIY soil sensor in.
I hope my resolution may help any other newbies in the world of this wonderful MySensors journey!
Cheers
-
RE: Relay_Actuator add second relay?
@Michel--
Many Kudos.
i tried your code modified for my single relay and button pushes successfully trigger the relay! I'm also reading status correctly in Vera.I am having some trouble controlling the relay from Vera. It appears as if the msgs from Vera aren't a) being received by the node, b ) not interpreting the node
I'm new to programming and not too sure of where to look.
Any Suggestions?/** * 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 * Example sketch for a "light switch" where you can control light or something * else from both HA controller and a local physical button * (connected between digital pin 3 and GND). * This node also works as a repeader for other nodes * http://www.mysensors.org/build/relay */ #include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID 1 // Id of the sensor child #define RELAY_ON 0 #define RELAY_OFF 1 Bounce debouncer = Bounce(); int oldValue=0; bool state; MySensor gw; MyMessage msg(CHILD_ID,V_LIGHT); void setup() { gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Relay & Button", "1.0"); // 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); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID, S_LIGHT); // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); // Set relay to last known state (using eeprom storage) state = gw.loadState(CHILD_ID); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); } /* * Example on how to asynchronously check for new messages from gw */ void loop() { gw.process(); debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue && value==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }