brump
Junior Member
Posts: 81
|
Post by brump on Nov 18, 2016 21:15:28 GMT
Hello, This week I started my home automation project. Initially, I built a gateway and three nodes. Gateway:Arduino one (modified for 3.3v) + Ethernet shield W5100 + RFM69HW 915MHz Compiled version 2.4 (Computorist). During the initial tests, communication between the gateway and the nodes was unstable. I modified the file W5100.h, as already informed in several posts of the Papa and Computorist. After that, everything is working 100%. Nodes:
I built three prototypes: 1 - Arduino one (modified for 3.3V) + RFM69HW 915MHz 2 - Arduino nano (modified for 3.3V) + RFM69HW 915MHz 3 - Arduino nano (modified for 3.3V) + RFM69HW 915MHz Although I built three nodes, I'm only working on the first one. My spare time is very little this time of year. Node 1:*Features: 1 - Activate a lamp (On / Off) with manual feedback of the switch (2 positions). 2 - Activate a dimmer lamp. (PWM) 3 - Select direction of ceiling fan. (Up or Down). 4 - Control ceiling fan speed. As a base I'm using the code Computorist_Node_v2.2Md_choises_pub.ino
Updated by the Papa. I will be posting the modifications and tests implemented as they are updated, as well as the files for OpenHab. I´m using version 2.0b4 of openhab. Doubts:
In openhab, is it possible to create some kind of box in which we can select a rule for time control? Example: Select the time to start the irrigation system. I want to thank everyone who contributed their comments, codes and tips.
Papa, Computorist, Greginkansas, ...Attachments:
|
|
|
Post by papa on Nov 18, 2016 22:09:28 GMT
You're welcome, brump. Good to hear from you & how your progress is coming.
You're trying some things that I have not tried: OpenHAB 2, dimmer lamp, & ceiling fan speed.
Regarding your Node's Feature #1 (using a 2 position switch to switch a lamp on & off), for software, you might be able to use my choices version of the sketch & select (UNcomment) a) SWITCH1 or SWITCH2B & b) ACTOR.
You wrote / asked, "In openhab, is it possible to ... Select the time to start the irrigation system?" I would think it is possible. I have the start of some ideas, but need to think more. Who else has done this or has a good idea for accomplishing it?
brump, I look forward to hearing your progress & your documentation of adding new features to this project.
|
|
|
Post by greginkansas on Nov 19, 2016 0:15:50 GMT
A dimmer item with this on the sitemap might be a start Setpoint item=Dining_Room_light_level minValue=0 maxValue=24 step=1 the item in your rules as a var
|
|
|
Post by papa on Nov 19, 2016 3:25:27 GMT
brump, I believe this could be a start to your Setting Irrigation Time (Note: I have limited ability to test the following) ...
Items file Dimmer Irrigate_Time "Sprinkle Time [%s]" <sprinkler> // ^^ [%s] displays Irrigate_Time value, can be deleted // ^^ Assumes icon file sprinkler.png
// Probably also need string item(s) to send commands to turn sprinkler ON & ?? OFF
Sitemap file Selection item=Irrigate_Time mappings=[1=6am, 2=7am, 3=9am, 4=10pm] // ^^ On the User Interface line, makes a link to a selection list to click select one item
Rules file entry might start something like ... rule "Set Irrigation Start" when Item Irrigate_Time changed then var start = Irrigate_Time.state if (start == 1) { // here: ?? create timer for value 1 in mappings // probably including sendCommand([Sprinkler On]) // & ?? [Sprinker Off] } if (start == 2) { // here: ?? create timer for value 2 in mappings, etc. } // if etc. for the other values end
======
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Nov 28, 2016 14:18:11 GMT
A dimmer item with this on the sitemap might be a start Setpoint item=Dining_Room_light_level minValue=0 maxValue=24 step=1 the item in your rules as a var Thanks Greginkansas. I wrote the items, sitemap and rules for dimmer light tests. Everyone is working. I'll post this file later. At the moment my internet access is slow. I work on a ship and my time is short. Brump
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Nov 28, 2016 14:29:47 GMT
brump, I believe this could be a start to your Setting Irrigation Time (Note: I have limited ability to test the following) ... Items file Dimmer Irrigate_Time "Sprinkle Time [%s]" <sprinkler> // ^^ [%s] displays Irrigate_Time value, can be deleted // ^^ Assumes icon file sprinkler.png // Probably also need string item(s) to send commands to turn sprinkler ON & ?? OFF Sitemap file Selection item=Irrigate_Time mappings=[1=6am, 2=7am, 3=9am, 4=10pm] // ^^ On the User Interface line, makes a link to a selection list to click select one item Rules file entry might start something like ... rule "Set Irrigation Start" when Item Irrigate_Time changed then var start = Irrigate_Time.state if (start == 1) { // here: ?? create timer for value 1 in mappings // probably including sendCommand([Sprinkler On]) // & ?? [Sprinker Off] } if (start == 2) { // here: ?? create timer for value 2 in mappings, etc. } // if etc. for the other values end ====== Papa, Thanks for help me. I found in github/openhab this post on wiki section: Alarm Clock IIII created a sitemap to test it, but the timer does not seem to fire automatically on openhab2. I have not tested on openhab 1.8.3. Sorry for taking the time to respond, my internet access is very bad here on the vessel. I have modified your computourist_node_v2.2Md_choices_pub.ino file and entered my codes, you have already released a 2.2Mf version. What would be a version that I can post here? Brump
|
|
|
Post by papa on Nov 28, 2016 14:52:25 GMT
Good to hear from you, Brump.
You could post your node version as computourist_node_v2.2Md_choices_brump.ino
Also post your config file entries (from items, rules, & sitemap) that go along with your node code additions.
Then maybe someone here can make more suggestions.
|
|
|
Post by papa on Dec 5, 2016 3:04:27 GMT
brump, lucidbuddha discovered that the multi-choice node sketch you downloaded & customized, computourist_node_v2.2Md_choices_pub, has a serious error in it. The NETWORKID in line 193 should be 100 to match NETWORKID in the Gateway sketch (not 200). With this error, Gateway & node will not connect.
I will correct the Md version where it was originally posted. The Me & Mf versions do NOT have this error.
My apology for connection problems I may have caused you or others.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Dec 19, 2016 11:00:30 GMT
Papa, before the initial tests I changed the all. I did not pay attention that they were with different information.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Dec 19, 2016 11:11:06 GMT
I am achieving success in my project. The code with the simple function for the dimmer is attached. computourist_node_v2.2Me_choices_pub_brump.zip (15.83 KB) I'm just using a led to test the dimmer function. It's OK. This week I will try to implement the zero cross detector and the triggering of an SCR trigger for the dimmer control.
At Openhab, I was successful with the timer for the sprinkler. Attached is the files for openhab 2.0.0b4. conf.zip (17.68 KB)
This week I will better organize my modules and separate each module to a specific location, as was the previous plan.
|
|
|
Post by papa on Dec 19, 2016 16:08:09 GMT
brump: "I am achieving success in my project."
papa: I've been thinking about you, brump, & wondering how you were progressing. I'm thrilled for you & celebrate with you. One can get frustrated with this project, but what satisfaction when we learn, get things to work, & document some tweak or advance for the project! When I get a chance soon, I look forward to looking over the code you posted & what I can learn from it. You're venturing into things I have not tried.
brump: "I will better organize my modules and separate each module to a specific location, as was the previous plan."
papa: I also look forward to hearing more about your upcoming efforts.
|
|
|
Post by papa on Dec 28, 2016 21:02:50 GMT
brump, you said, (in my thread, How to Use More Than One RFM69 Network)
Sorry to hear the latest troubles. But let's please keep conversations about your project in this thread. :-) Easier to follow that way.
I looked at your version of the Multi-choice Node sketch. Looks like you followed the existing patterns & inserted your PWM code nicely. Using Arduino D5 for the PWM should work fine as long as the pin is not also used by SWITCH1 or Miniwireless SPI Flash Memory. I have not tried the added PWM code for dimming, but am glad to hear it works for you.
I also looked through your OpenHAB config files. I can see some differences in what is required or recommended for OpenHAB 2. The code related to irrigation seems pretty involved. I cannot tell if it's actually controlling something yet.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Dec 30, 2016 0:33:05 GMT
brump, you said, (in my thread, How to Use More Than One RFM69 Network) Sorry to hear the latest troubles. But let's please keep conversations about your project in this thread. :-) Easier to follow that way. This error mentioned previously... I reinstall the windows 10 Pro because files of operation system was corrupted. After install mosquito (V: 1.4.10) and start a service was not communicate with RFM_Gateway. This problem ocurred because windows firewall blocked a mosquitto broker.For this solved, I open "mosquitto.exe" in c:/program files/mosquitto and allow the all options in firewall dialog box. Image Example. After this step, all communications are ok.
It´s necessary reinstall openhab2 and bundles, persistence, actions, etc. OBS: I tests openhab2-Snapshot. After this, all communications are ok.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Dec 30, 2016 1:02:48 GMT
I looked at your version of the Multi-choice Node sketch. Looks like you followed the existing patterns & inserted your PWM code nicely. Using Arduino D5 for the PWM should work fine as long as the pin is not also used by SWITCH1 or Miniwireless SPI Flash Memory. I have not tried the added PWM code for dimming, but am glad to hear it works for you. Thanks. I put my code in pin D5 for tests, it´s possible change it. I working in zero crossing detector and triac control for lamp. 120VAC / 60Hz; 120VAC / 50Hz; 240VAC / 60Hz; 240VAC / 50Hz. All options are avaliable, switch before in node code. I also looked through your OpenHAB config files. I can see some differences in what is required or recommended for OpenHAB 2. The code related to irrigation seems pretty involved. I cannot tell if it's actually controlling something yet. The code for the irrigation system is working for me. I put it in the Sitemap just for testing, after moving it.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Jul 23, 2017 0:50:39 GMT
Hello, My project is slowing due to the import process in Brazil being an average of 5 months. Below a little of my progress: -Zero Cross detector and Triac Control I used a library to control the dimmer. The library can be found here: Dimmer-master.zip (15.21 KB). To set the interrupt pin to be used at zero cross detector just edit the lines below in the Dimmer.h header file: Dimmer.h
Line 35: #define DIMMER_ZERO_CROSS_PIN 2 Line 36: #define DIMMER_ZERO_CROSS_INTERRUPT 0 Note: Board Digital Pins Usable For Interrupts Uno, Nano, Mini, other 328-based 2, 3 Pin 2 (RFM69 radio IRQ) is already being used by Papa's version of Computourist's code. So I used pin 3 and DIMMER_ZERO_CROSS_INTERRUPT 1. Change the lines in Dimmer.h to these: Line 35: #define DIMMER_ZERO_CROSS_PIN 3
Line 36: #define DIMMER_ZERO_CROSS_INTERRUPT 1
Mode operating mode. * Possible modes: * NORMAL_MODE: Uses timer to apply only a percentage of the AC power to the lamp every half cycle. * RAMP_MODE: Same as in normal mode, but it applies to ramp effect when changing levels. @see rampTime * COUNT_MODE: Counts AC waves and applies full half-cycles from time to time. * @param rampTime time it takes for the value to rise from 0% to 100% in RAMP_MODE, in seconds. Default 1.5. @see setRampTime (). * @param freq AC frequency, in Hz. Supported values are 60Hz and 50Hz, use others at your own risk. Dimmer (uint8_t pin, uint8_t mode = DIMMER_NORMAL, double rampTime = 1.5, uint8_t freq = 60); My circuit can be seen here. See below an updated schematic with more explanatory comments. Basically the circuit is divided into two parts: Zero Cross Detector and Triac Control. The dimmer function implemented in the test code can be seen here. computourist_node_v2.2Mf_choices_pub_brump.ino (58.71 KB) Papa: See below for the latest version of the node choices sketch that includes the dimmer code. brump: At the moment I am waiting for the RFM69HW modules to arrive to continue with new tests.
|
|
|
Post by papa on Jul 23, 2017 19:05:39 GMT
brump, my sympathies on how import difficulties are delaying your project.
Thanks so much for taking the time to document your progress on dimmer features for our DIY Home Automation. I'm sure some of our readers will benefit from what you have provided.
Looks like you followed the multi-choice sketch's conventions very well. I appreciate how you provided an updated sketch for the dimmer feature. When I get a chance, I'll look at adding your code updates to my latest version. I also appreciate the schematic you posted.
You might add OpenHAB entries to work with the dimmer circuit & sketch.
I close with a caution for readers who may try this dimmer circuit:
This dimmer circuit will use dangerous mains voltage. Be VERY, VERY, VERY CAREFUL. Turn off the power source before you connect this circuit to house wiring. Check, double-check, triple-check ... your wiring AND how it connects to house wiring. Make sure you protect living things from accidentally connecting with the mains part of this circuit.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Jul 23, 2017 20:25:47 GMT
brump, my sympathies on how import difficulties are delaying your project. Thanks so much for taking the time to document your progress on dimmer features for our DIY Home Automation. I'm sure some of our readers will benefit from what you have provided. Looks like you followed the multi-choice sketch's conventions very well. I appreciate how you provided an updated sketch for the dimmer feature. When I get a chance, I'll look at adding your code updates to my latest version. I also appreciate the schematic you posted. You might add OpenHAB entries to work with the dimmer circuit & sketch. I close with a caution for readers who may try this dimmer circuit: This dimmer circuit will use dangerous mains voltage. Be VERY, VERY, VERY CAREFUL. Turn off the power source before you connect this circuit to house wiring. Check, double-check, triple-check ... your wiring AND how it connects to house wiring. Make sure you protect living things from accidentally connecting with the mains part of this circuit.Hi Papa, Everything that each one puts, all their discoveries, mistakes and hits, however small, will make a great difference for someone! I appreciate what everyone contributes and will contribute to the DIY home automation project. Thank you for the encouragement I have always received from you! For my tests, I created the following lines in openhab 2. Sitemap:Slider item=Node2dimmer label="Light Dimmer Node 2 [%s %%]" Items:
Dimmer Node2dimmer "Ligh Node2 Dimmer [%s %%]" {mqtt=">[mosquitto:home/rfm_gw/sb/node02/dev32:state:*:default"} Rules:
rule "Dimmed Light" when Item Node2dimmer received command then var Number percent = 0 if(Node2dimmer.state instanceof DecimalType) percent = Node2dimmer.state as DecimalType if(receivedCommand==INCREASE) percent = percent + 5 if(receivedCommand==DECREASE) percent = percent - 5 if(percent<0) percent = 0 if(percent>100) percent = 100 postUpdate(Node2dimmer, percent); end TRIAC - I forgot to mention that I put TIC206D because my eagle library did not have the T1635-600 component of ST, because that's what I intend to use. It is the same as the BTA16 ST line, only in D2PACK encapsulation, which would result in a smaller occupied area on the PCB. This triac is for 16 Amps and holds most of the equipment we want to power. It is also indicated in inductive loads, for example: ceiling fan. Note: I did not mention in the previous post two things: 1- Use a heat sink in any TRIAC to prevent it from burning. If you choose to use TO-220 encapsulation you can create your own heatsink so that it wraps its "box" using aluminum bar. 2 - As already mentioned by the Papa, VERY CAREFUL WITH ELECTRICAL NETWORK, CAN COME TO KILL YOU! CHECK EVERYTHING BEFORE TESTING! ================================= Papa: Great additions in this post, brump. I also smile big at your Deep Diving avatar.
|
|
|
Post by papa on Jul 26, 2017 15:55:58 GMT
computourist_node_v2.2MgG_choices_pub.ino (72.27 KB) << As brump verified below, this updated version of the Multi-Choice Node Sketch now includes brump's latest coding for dimmers. See this post above for the needed Dimmer library & changes to it. See the same post above for the dimmer circuit schematic. And again BE VERY, VERY CAREFUL WITH THIS. Brump, I have not tested this inclusion of your code. Could you please test & let me know the results?
Also, brump, for those of us who know less electronics than you ...
could you indicate more in reference to the schematic:
How is this circuit connected to power, lighting, & the Arduino?
On the schematic, what is the small. separate circuit above the larger one?
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Jul 26, 2017 20:34:08 GMT
<< I believe this updated version of the Multi-Choice Node Sketch now includes brump's latest coding for dimmers. See this post above for the needed Dimmer library & changes to it. See the same post above for the dimmer circuit schematic. And again BE VERY, VERY CAREFUL WITH THIS. Brump, I have not tested this inclusion of your code. Could you please test & let me know the results?
Also, brump, for those of us who know less electronics than you ...
could you indicate more in reference to the schematic:
How is this circuit connected to power, lighting, & the Arduino?
On the schematic, what is the small. separate circuit above the larger one?
Papa, I tested your code. It's working! In line 220: #define VERSION "2.2Mgf" // version of this sketch, can be queried as device 3 Can you change the version to 2.2MgG? The commented schematic is below: So is it easy to understand for everyone?
|
|
|
Post by papa on Jul 27, 2017 14:42:22 GMT
Thanks, brump, for verifying that your code in the latest node choices sketch is correct & for catching the needed change in line 220 of the sketch. I posted a corrected sketch above. Thanks also for the comments on the schematic. That is helpful. PS In the schematic, I do not see a value for the capacitor C2. Could you add that, please?
Other dimmer circuits seem to use the same capacitor value twice. So would 1nF be the correct value for C2?
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 15, 2017 18:48:54 GMT
Thanks, brump, for verifying that your code in the latest node choices sketch is correct & for catching the needed change in line 220 of the sketch. I posted a corrected sketch above. Thanks also for the comments on the schematic. That is helpful. PS In the schematic, I do not see a value for the capacitor C2. Could you add that, please?
Other dimmer circuits seem to use the same capacitor value twice. So would 1nF be the correct value for C2?
Sorry for the long delay in answering. My wife is pregnant and these past months have been run. C2 value: 4.7uF papa: Thanks, brump. Best wishes on the new family member.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 15, 2017 19:44:57 GMT
I would like to share an option for anyone who wants to use arduino power at 5VDC. As we already know the RFM69HW radios are powered with 3.3V. Using the 74HC4050 (non-inverting HIGH-to-LOW level shifter), we can isolate the voltage on the arduino pins, ensuring that the signals are 3.3V on the radio side and 5VDC on the Arduino side. For more details consult the datasheet of CI: 74HC4050The circuit below illustrates the example: In the site adafruit has available the breakout board. The circuit uses the IC described above, regulators, etc. All ready for anyone who just wants to use the module. learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-breakouts/overviewpapa: Yes, as greginkansas reminded us recently in another thread, the Adafruit RFM68 breakout board will allow one to use the RFM69 radio with a standard 5 volt Arduino Uno, which would help those who have trouble getting Buono Unos to their location.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 15, 2017 19:56:04 GMT
Returning to the progress of my project:
I am trying to implement an eeprom to save the states from the last saved states.
If the power fails, or for some reason the node restarts, I need it to be in the last saved state to ensure full functionality. A rule can be created for clock-driven drives, since the node sends its last state to openhab, in the rule we can decide whether that state remains or will be updated according to the time the energy is reestablished.
More complex rules can be created with equipment that involves drive times such as sprinklers. If the total trigger time is 30 minutes and the power is turned off 15, the other 15 minutes need to be completed to ensure the total time. That's just a rude example.
Has anyone ever created anything like this?
|
|
ragoth
Junior Member
Posts: 64
|
Post by ragoth on Oct 16, 2017 1:28:26 GMT
Dear Mr. Brump, there is a small correction in your circuit, that is the T2 (BC817)transistor emitter should be grounded along with R8 (4K7) resistor.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 17, 2017 1:48:49 GMT
Dear Mr. Brump, there is a small correction in your circuit, that is the T2 (BC817)transistor emitter should be grounded along with R8 (4K7) resistor. Thanks Ragoth, papa: Yes, thanks, ragoth, for helping perfect the schematic.Really went unnoticed. It's corrected.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 28, 2017 19:54:02 GMT
Project update. I am finishing version 1 of my generic node.
|
|
|
Post by papa on Oct 29, 2017 23:44:48 GMT
Impressive, brump. Say more about what your generic node can do.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Oct 30, 2017 8:53:02 GMT
Impressive, brump. Say more about what your generic node can do. Hardware in this version is capable of: - control up to 4 relays with 10A load each. - control two loads with the dimmer function. - monitor the ac current of the outputs. (ACS712) - up to 5 inputs using analog input channels. - 1 channel for DHT22 temperature sensor. Now we just need to adapt the software to perform the intended functions. We need to create an eeprom map only to store the state functions of the last drive. As described in a topic above. If you do not have communication with the gateway that node needs to work in manual mode, otherwise the house will be compromised. And power outages would cause the whole house to come back off. (In Brazil, we are in the summer and with excessive heat energy consumption increases greatly by the use of air conditioning in homes, causing blackouts frequently in different regions of the country). What do you think of implementing the state store in the nodes code?
|
|
|
Post by papa on Oct 30, 2017 13:25:29 GMT
brump: "What do you think of implementing the state store in the nodes code?"
papa: That may be useful for blackouts & power outages as you described. For example, if a power outage interrupted a period of irrigation, one would want the system to resume watering & complete the irrigation. I have not implemented such a state store & will probably not have time the next several weeks to look at that. Maybe another forum member can help with this.
Thanks for more specifics about your "generic node." Looks like you have a neatly done, useful product which packs many functions into a compact space. More questions: Will an ATMega processor be mounted on the board to host the programming or will this board be connected to an Arduino compatible (that is, is the board actually a "shield?") If it will connect to an Arduino compatible, how will it connect?
brump: "we just need to adapt the software to perform the intended functions."
papa: Except for "monitor the ac current of the outputs," I believe the "choices" sketch contains the basics for much of what is needed. However, variables & coding will need adapting to handle multiples of relays, analog inputs, dimmers, etc.
|
|
brump
Junior Member
Posts: 81
|
Post by brump on Dec 8, 2017 16:39:03 GMT
I updated my pcb. I sent it to allpcb.com and next week I will be with the pcbs in hand. I'm posting updates and assemblies.
|
|