💬 AC-DC double solid state relay module




  • Hardware Contributor

    Have we done any testing on the power circuitry here, short term tests, long term tests at all? I'm about to do the same setup as you have here in terms of the 240VAC-5VDC converting. Would love to know what your findings are.



  • And whats the best way for soldering the thermal fuse? alligator-clips for heatsink, alot of heat, wide soldering tip and fast?


  • Hardware Contributor

    Your 'board layout' image is missed the 2 resistors that you have included on the schematic (i think anyway, i can't read your schematic very well, poor resolution). I'm guessing these are not needed?


  • Hero Member

    @Samuel235 At the moment I have one board (version 3.3.1, which is missing the temperature sensor) up and running for over a week. It's in a small closed box, and it has two lamps attached to it which are powered on every evening. So far everything seems to be ok. Temperature is still low inside this box after a few hours (couldn't perform any specific measurements yet, so that's why I added the temperature sensor in this one).

    @Cliff-Karlsson I just soldered the thermal fuse really quick. But maybe some other kind of heatsink would be useful! So any suggestions are welcome for this. 🙂

    @Samuel235 I have been using DipTrace to design all my PCBs, and I must admit that the schematic view in this software kit isn't the best.. I'll see what I can do to have the schematic quality improved! But all components which are on the schematic are on the PCB, so no components are missing on the board itself.


  • Hardware Contributor

    @aproxx, I'm pleased to hear you're having no issues to date with your module!

    In that case could you point out where the two resistors are on your board before your AC power goes into the AC/DC transformer please? I'm interested in knowing why these are there 🙂

    A lot of us here use Eagle CADSOFT for our PCB and Schematic needs. It meets every requirement i can possibly imagine being needed.


  • Hero Member

    @Samuel235
    I assume you were referring to the 2 resistors at the high voltage circuit? These were actually used as placeholders for the temp cutoff and the slow blow fuse. As I didn't have these component in DipTrace I used resistors to replace them in the scheme. But I have updated the schematic to avoid any confusion!

    As for the EAGLE software: Is does meet all the needed requirements, but I just find DipTrace to be way more user-friendly.


  • Hardware Contributor

    @aproxx

    Ahh okay, thank you for pointing this out to me. My mind can rest now haha!


  • Hardware Contributor

    Could I ask the reason for the slow blow fuse here, what is specifically drawing high current at startup? I ask because i'm attempting to make my own on board AC-DC solution and I'm very tempted to put a fast acting fuse on the other side (DC side) of the AC-DC converter. I'm not sure what would be drawing your initial current spike (if you have one). The only things i can see for you is the on board relays....


  • Hardware Contributor

    @Samuel235 Check http://forum.mysensors.org/topic/1607/safe-in-wall-ac-to-dc-transformers/295 - below post #295 is a great discussion about slow/fast blow.


  • Hardware Contributor



  • Does anyone know how to convert diptrace to kicad format? I want to try and edit to make a RFM69 version.

    An on that note - would swapping a 3.3v arduino in and connecting the HLK to raw and supply rest of circuit from the VCC pin work? That way I do not need to level shift for the RFM69 and I don't need the voltage converter either.

    Thanks!


  • Hardware Contributor

    @sundberg84, @m26872 - Thanks for pointing me over there. I had read through those before but didn't take it all in back then as i wasn't doing my module back then. Thank you for reminding me!


  • Hardware Contributor

    Hello @aproxx I was developing something similar but using a ATMEGA328 chip, that way I would make it smaller! Can I ask you way do you use 2 100nf Capacitors after the HLK? And what is the width of the copper lines in the 220v and signal?

    Thank you
    And great work


  • Hardware Contributor

    @Soloam, the capacitors after the HLK are to filter out any noise from the HLK and the AC Input side of the circuitry. I personally shoot for a 100uF cap if its below 5A and anything over 5A i'de drop a 440uF in, along with a 0.1uF next to it. This isn't saying Aproxx is wrong or incorrect in any way, that is just my personal preference.

    As for the trace width, i can't help you on that one as i can't open any of his board files to get a reading on them. I'm sure he will provide some more detailed information for you.


  • Hardware Contributor

    I let approx answer for his width trace 🙂

    You can find online tools to calc this, plus there are different strategy like using a pcb with thicker copper (2oz but more expensive than of 1oz common). Like no soldermask so you add some solder or/and piece of copper wire to improve thickness etc..The thicker copper, the smaller the trace.

    For the capacitor, it's for filtering output ripple, not input! there is no 5A on output.
    Only 2cap can't filter everything.. but that will improve and work better than nothing 😉 And increasing a lot the 100uf like 400uf won't change things, it could be less efficient. I won't do a lesson (I'm not expert too) but sometimes its preferable to use multiple different value capacitor depending on what you want to filter. And here again there are other filtering techniques which can be used. but that's if you have problem with those ripples on your circuit and it's easier to have a scope to check how this improve.


  • Hardware Contributor

    And there is the more advanced version of my reply, thanks to @scalz.


  • Hero Member

    @Soloam I'm actually not using 2 100nF capacitors, but 1 100nF and 100 uF capacitor. Exactly for the reason that scalz mentioned. 🙂 I'm not saying these are the perfect values to use, but I came across similar values some time ago, and these give me a decent and stable voltage.

    The width of my copper traces is 2mm for the entire high voltage circuit. I have used a trade width/thickness calculator, and it should be more than sufficient to power the HLK-PM01.
    However, it is not sufficient for the traces between the relays and the connectors because it should be able to handle up to 2A (limiting factor of the solid state relays). That's why I have designed this board with open air traces between the relays and the connectors. That way it's possible to reinforce the traces with solder, after which it should be able to withstand 2 Amps.

    And good luck with designing your version of the board! If there is a way to decrease the board size even further that would be great!


  • Hardware Contributor

    Hello all, I finished my version of this idea! Thank you to @aproxx for the help! I used a ATMEGA328, this wil make it a bit cheaper. https://www.openhardware.io/view/83

    I need some help validating the layout, most important the 220v traces and the capacitors used in the layout!

    Thank you all



  • Hello,
    My question is whether the code includes support DS18B20?


  • Hardware Contributor

    @aproxx, Could i ask what trace width and what clearance you used for the AC portion of this device? Also, what current did you base these settings on, what current do you expect to be flowing through the AC traces?



  • Just a thought : Why not use RAW instead of VCC so a 3.3V mini can be used as thus no logic conversion needed for RFM69? The SSR works find below 3v as it happens. Also means no need for the voltage changer. Could also look at getting the 3.3V HLMs also I guess.



  • How many pieces got ordering paying $ 14 http://dirtypcbs.com/index.php ?



  • Hi @approx, there is 4k7 resistor placeholder under arduino, near 100nf capacitor, but you didn't mention it in a project description - is this resistor optional?


  • Hardware Contributor

    @Konstantin-Kolesnichenko, I would highly recommend the pullup resistor.

    Please see https://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/ for more information regarding this resistor.



  • @okos I got 11 pieces for one order.
    @Samuel235 thank you, soldered one 🙂



  • anybody who's got a complete kit for sale ? Want to test build one (single relay is enough)
    (or maybe nicer: a 3in1 solution : Motion detection , relais , DHT of other temp sensor)



  • Is somewhere there present source for this module with temperature module support?



  • this looks like a great project. Have anyone made a complete shopping / whish-list on Alibaba for all the components needed? ( I´m lookin for safest version possible 😃

    Many thanks,
    Henrik


  • Hardware Contributor

    @badmannen I have ordered nearly everything on aliexpress but I had to buy from many different sellers to have everything, I don't know if they are all reliable, I will know in 3-4 weeks and then post the links for the items I received.
    I took some 250mA fuses as no one was selling 200mA slow fuses on aliexpress, and also some 77°C temp fuses instead of the 73° because they were less than half the price. I'll grill one or two to make sure they are real temp fuses when I receive them 😉

    Not sure if I order the PCBs from DirtyPCB now or if I wait to received my previous (and first order there) to be sure they will reach my mailbox...


  • Hardware Contributor

    @badmannen I have just received my temp fuses, 1 of the 10 is dead, I tested one that was ok to make sure it was a temp fuse. I used the thermometer function on my multimeter and heated at the same time with my soldering iron at lowest temperature possible (200°C).
    Heated until thermometer reached 50°C, fuse was still ok.
    Heated again a bit longer and I heard some noise when thermometer went over 60°C. I stopped and checked: the fuse was blown. Given that multimeter thermometer is not extremely precise and has some lag to increase the temperature, I think the claim of 77°C cut off is probably right or at least not far from reality. And at least I'm sure these are temp fuses. I'm not testing another one as I have only 8 left now and I'm nearly sure I'll burn a few when soldering 😄

    [edit] 77° fuses not sold anymore 😞
    http://www.aliexpress.com/item/10pcs-lot-RY77-TF-77-Degree-Celsius-77C-10A-250V-Temperature-Thermal-Fuse/32577243105.html
    I will order that next, from same seller, look like the same fuses, just 72°C which should be fine in our case.
    http://www.aliexpress.com/store/product/20pcs-lot-RY72-TF-72-Degree-Celsius-72C-10A-250V-Temperature-Thermal-Fuse/1021664_32660871006.html



  • Hi @aproxx , very nice module! Just one question: after studying the board I still not quite understand how an existing light switch needs to be connected. There are 3 connecters, one for AC and two relays. Where do I connect the light switch to?

    Cheers! Sacha



  • @Nca78 Thanks alot for the detailed info! really appreciate it. keep it coming pros and cons if any if you notice something

    //Henrik



  • @Soloam said:

    Hello all, I finished my version of this idea! Thank you to @aproxx for the help! I used a ATMEGA328, this wil make it a bit cheaper. https://www.openhardware.io/view/83

    I need some help validating the layout, most important the 220v traces and the capacitors used in the layout!

    Thank you all

    Is there any news on this design?


  • Hardware Contributor

    @badmannen said:

    @Nca78 Thanks alot for the detailed info! really appreciate it. keep it coming pros and cons if any if you notice something

    //Henrik
    You're welcome. I ordered 72°C fuses as in my previous link. Seller agreed to add one to replace the broken 77°C I received last week.

    I received the varistors, ssd relays and regulators, all correctly packaged in padded envelopes. Not tested yet, I will update this post later if I see a problem, but I'm not sure how I can efficiently test the varistors...

    http://www.aliexpress.com/item/Varistor-10D391K-10D-391K-VDR-10K391-Metal-voltage-dependent-resistor-50pcs-bag/1912418587.html

    http://www.aliexpress.com/item/10pcs-bag-New-original-solid-state-relay-G3MB-202P-DC-AC-PCB-SSR-In-5VDC-Out/32260339179.html

    http://www.aliexpress.com/item/Free-shipping-10pcs-lot-LE33CZ-LE33ACZ-TO-92-new-original/32591811172.html



  • @Nca78 How is the LE33 working for you? i couldn't make it drive the NRF...


  • Hardware Contributor

    @dpressle said:

    @Nca78 How is the LE33 working for you? i couldn't make it drive the NRF...

    As I said I didn't have time to test the last batch of components yet.
    It's suprising as the LE33 is supposed to allow up to 100mA current, that should be enough for the NRF. Not sure I will use them any as I have some 3.3V nanos and also some 3.3V HLKs so I could bypass it.
    I will test anyway and keep you updated.

    [edit] All components (slow blow fuses, capacitors,...) received, I'm just waiting for the PCBs now. And for some time to test 🙂


  • Hardware Contributor

    Hi,

    can we install this module in a wall ?
    Can we command shutters ?
    Thx



  • I updated source file for this module, so it supports MySensors 2.0 now and sends temperature data too. You can pick it at my github page. Total size for 'Arduino Pro or Pro Mini w/ ATmega328 (5V, 16 MHz)'
    Program size: 13 396 bytes (used 44% of a 30 720 byte maximum) (2,78 secs)
    Minimum Memory Usage: 614 bytes (30% of a 2048 byte maximum)



  • Hi Approx
    Thanks for the effort here. I have all the bits except for the PCBs which were shipped a week ago so not far off.


  • Hardware Contributor

    @tonnerre33 said:

    Hi,

    can we install this module in a wall ?
    Can we command shutters ?

    For the wall, that's the idea of keeping the 50*50mm size 🙂
    For the shutters technically yes, but there are (at least) 2 problems :

    • if you have the 2 relays on at the same time = 2 directions you will probably kill the motor, there is no hardware protection on this board to avoid that (one of the relays must have power only when the other one is in off state). This can be done in software so it's not blocking.
    • if you want to be able to control the level/percentage of closing, you need to measure time from min to max position, to do that you need to measure current (when motor stop consuming current it means shutter has reached it's 0% or 100% position). But there is no current sensor on this board, so you either need to implement a manual calibration process (that will lose precision over time) or use only manual control.

    I am planning to test it when I have some time, and when I receive the PCB.


  • Hardware Contributor

    @dpressle said:

    @Nca78 How is the LE33 working for you? i couldn't make it drive the NRF...

    I just used one on a test board made on an Easy PCB, it's just powering the radio like on this board and it is all fine at the moment.



  • @dpressle my experience shows, that this PCB works fine with LE33 when powered from mains, however nrf fails to receive data, when powered from FTDI through arduino.


  • Hardware Contributor

    @Konstantin-Kolesnichenko what voltage is selected on the ftdi adapter ? If it's 3.3V it's not surprising as the LE33 needs over 3.5V (3.3V + 0.2V voltage drop).



  • Hello, i have question can i use arduino pro mini 3.3 V?

    http://s.aliexpress.com/zmyyY7BV

    Thanx



  • @Nca78 you're right, my FTDI was at 3.3v after experiments with ESP8266. With 5v everything works as expected.


  • Hardware Contributor

    @okos said:

    Hello, i have question can i use arduino pro mini 3.3 V?

    http://s.aliexpress.com/zmyyY7BV

    Thanx

    I will try to use one and HLK-PM03 generating 3.3V, and bypassing the regulator on the PCB.
    The only question is about the SSR relays, they are supposed to work with 5V logic levels, I need to test the relays I have received work reliably with 3.3V logic.
    Datasheet says operating range is 4-6V but 4V is the maximum value at which they should switch on, so there's some hope here 😉


  • Hardware Contributor

    @Nca78 thanx for your answer 😉

    You are right, 2 directions can kill the motor that's why we need one relay for on/off the motor and the other for command up/down.
    But for command up/down, and in order to do an hardware protection, we can use an inversor relay.
    Do you know an inversor relay with the same size ? I didn't find that kind of relay 😞


  • Hardware Contributor

    @tonnerre33
    I have made a board for tshutters 😉
    on my side, it's completed. I'm actually checking files, writing docs for my git (bom etc..) I have so much projects almost completed to show so I have to clean my projects one by one 😣 and I don't talk about software stuff too..arghh!
    Here it is https://forum.mysensors.org/topic/2944/roller-shutter-node


  • Hardware Contributor

    Yes, i know this good project but he don't use an arduino pro mini like Aproxx 😉
    Your project need welding cms and i never do it ^^
    The Aproxx's board has Thermal Cutoffs, and i didn't see that in your project


  • Hardware Contributor

    @tonnerre33 yep. you're right, it's cms I'm sorry 😞 I think.. good luck to fit everything with arduino mini in wall.
    About the cutoff, I replaced this by a simple temperature sensor for monitoring. imho, i have two fuses onboards + varistor, enough for me comparing to some commercial products. If it burns you have a big problem somewhere!! But sure it's better to know what you do, thermal fuses is good 😉


  • Hardware Contributor

    @scalz don't be sorry, i just need to learn to weld cms xd But for not disturb this project, i'll continue ta ask my questions in your topic project 😉


  • Hardware Contributor

    @tonnerre33 said:

    But for command up/down, and in order to do an hardware protection, we can use an inversor relay.
    I don't know if we need an inversor relay. For sure it will be hard to find another relay as small as these SSRs
    Maybe I'm wrong but I from what I know roller shutter motors have a common ground and then you connect the phase for the direction you want to use. I think it can be done in software, with hardware it cannot be done on this PCB because of the way the SSRs are connected.

    @scalz on your board you use relays that are much bigger than those tiny SSRs, in the end it probably gives the same result for the space used on the board, and as you have the radio on the other side the depth difference is not very big, just 2mm from the plastic at the base of the connectors.



  • Hi I did everything according to the project and I have problem "error sending the switch command check device / hardware"
    One change for me is 10nF capacitor instead of 100nF (I dont have now
    )
    Could this be the reasons this error?!
    0_1470516115940_ERROR.JPG


  • Hardware Contributor

    @okos if you have the device in Domoticz it means it could run, and send data to the gateway controller.
    Did you change anything in hardware of software between the moment you added the node/sensor to Domoticz and the moment you tried to activate it ?
    Are you sure your settings for the ACK are ok ? Maybe you are not sending one in the node but waiting from one in Domoticz ? Check the "Ack" column in Domoticz and if it's true try to change it to false.



  • Aproxx you roxx. It works! Not sure what to do with it yet, but likely it will end up in a wall sometime soon on light duties. Thanks for sharing such a great design 🙂
    0_1470565848624_IMG_20160807_222603-800x735.jpg
    Hmm just pulled some switches, they are mostly SPDT jobbies on multiple switches, no idea how to hood this bad-boy up =(



  • Hi everyone,

    First I would like to thank the OP for sharing this great project 🙂

    Then I would like to ask what would happen if the node cannot connect to the gateway on startup? It would still be possible to use the switch?

    Thank you,


  • Hardware Contributor

    @Daniel-Oliveira said:

    Then I would like to ask what would happen if the node cannot connect to the gateway on startup? It would still be possible to use the switch?

    Hello, on startup if it cannot connect to gateway MySensors library will loop until it connects, so no. But once started as you have direct connection to the switch it will work even if the gateway fails.



  • @Nca78 Thank you for the reply,

    There is a way to overcame that? Like add a max retry of sorts? My concern is that if by some reason the gateway fails and the node reboots I will not be able use the switch.

    Or does MySensors have another fail safe mechanism that I'm not aware?


  • Hardware Contributor

    No that I know.
    But this situation is really unlikely, nodes are very stable usually (else you'll quickly see a problem). Basically you would need the gateway to fail, then a power outage to reboot your node.



  • @Nca78 said:

    @okos if you have the device in Domoticz it means it could run, and send data to the gateway controller.
    Did you change anything in hardware of software between the moment you added the node/sensor to Domoticz and the moment you tried to activate it ?
    Are you sure your settings for the ACK are ok ? Maybe you are not sending one in the node but waiting from one in Domoticz ? Check the "Ack" column in Domoticz and if it's true try to change it to false.

    Thanks for the answer 😃 Nca78, but I do not know where to look for settings Ack.
    Please help


  • Hardware Contributor

    @okos go to Setup menu / Hardware, then click on the "Setup" button for your MySensors gateway.
    In the top list select the node, and in the bottom you will see the sensors attached to this node, and a Ack column for each sensor. To edit the ack column just select item and you have the checkbox below the grid with update button.



  • This post is deleted!

  • Hardware Contributor

    First board soldered and tested, it runs very well, thank you for the great work @aproxx !
    Thank you @Konstantin-Kolesnichenko also for adapting the script to version 2.0.

    I just didn't dare to install the ds18b20, the tiny distance to the temp fuse pad gives me some nightmares 😰 so I prefer having no temperature sensor and put a piece of insulating tape on both sides.
    This one will go in the ceiling, but for next board I will keep the vcc pin of the NRF24 and change a bit the code to use touch sensors behind a livolo glass plate. I need some top level WAF before I can go on with the MySensorization of all the appartment 😄

    0_1471537898596_SSR_Relay_Board.jpg (like the others I will not show the back side and it's ugly pieces of insulating tape :D)

    @okos did you fix your problem ? I see your deleted message.



  • @okos did you fix your problem ? I see your deleted message.

    Now everything is ok.
    Nrf changed, and changed the position of the gate (it is now above - on the fridge :))

    But I have another problem
    I used the code from Konstantin Kolesnichenko (thanks), and even after the power is changing relay.

    Example:

    on relay 1
    off Relay 2

    turn off the power, and after power returning I

    on relay 2
    off Relay 1

    Why exchange ?


  • Hardware Contributor

    @okos I will try to do more tests tomorrow to see if I have the same problem. I see no obvious mistake in the script that would generate this though. The only thing I see would be if you have linked your module with physical switches and they are in different position. As the script assumes that at startup the buttons are in "off" position (circuit opened).

    I think we should have this code at the end of the setup() method to initialize the oldValue and oldValue2 variables.

      // Set the initial values of oldValue/oldValue2 variables from status of physical switches
      debouncer.update();
      debouncer2.update();
      oldValue = debouncer.read();
      oldValue2 = debouncer2.read();
    

  • Hardware Contributor

    @okos I confirm to you that without the change in my previous message, I had a similar problem (relay 1 always on and relay 2 always off at startup). After applying the change I don't have any problem on restart, it was just an initialization problem.
    I'm making some small improvements to the sketch, I will test tomorrow and post it.



  • Thanks Nca78, I'm waiting for a revised code


  • Hardware Contributor

    Hello,
    this is the updated code, the list of changes at the top of the script.
    In short :

    • fixed initialization of hardware buttons
    • improved debug information
    • made temperature sensor optional (via a #define) as I think it's location on the board is not safe

    I think the behavior of the node is fine now, it has debug for physical buttons and the script uses less program space (<12k, <8k if temp sensor is disabled: you can enable debug even with an old atmega168 pro mini :)) and less ram (514 bytes for global variables).

    I added the temp sensor on my first board to make some tests, it's in the ceiling now in a big (10x10cm) but air-tight electric box. Both relays are switched off at the moment and I'm waiting for the temperature to stabilize, then I will try to switch the loads on and off, leave on for a long time etc etc. 28W light tube on first relay, 2x28W on the other, it should not create problem.

    /**
     * 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
     *
     * Script for double SSR relay board by Aproxx
     * https://www.openhardware.io/view/77/AC-DC-double-solid-state-relay-module
     * https://forum.mysensors.org/topic/3671/ac-dc-double-solid-state-relay-module
     * Control 2 circuits either from controller or from physical buttons connected on pins 4 & 7
     * Optional DS18b20 is connected on pin 8
     * 
     *  HISTORY :
     * xx/xx/2016 original version by Aproxx
     * 08/02/2016 upgraded to MySensors 2.0 by mr_const
     * 08/30/2016 changes by Nca78 :
     *        - fixed initialization of physical buttons/debouncer status
     *        - centralized pin status change for relays in setRelayState method
     *        - centralized debug information for state changes in one method + added debug info when changed by physical switches
     *        - added #ifdef MY_DEBUG before each Serial.print (saves prog memory when not in debug mode) and F() macros for debug strings (saves RAM when in debug mode)
     *        - added #define USE_TEMP_SENSOR to make temperature sensor optional (not used if line is commented)
     *        - put back #define for repeater feature
     *        - add #define TEMPERATURE_ROUNDING for custom temperature rounding
    **/
    
    // MySensor Debug
    //#define MY_DEBUG
    
    // Enables repeater functionality (relays messages from other nodes)
    //#define MY_REPEATER_FEATURE
    
    // Comment line below if you don't want to use the temperature sensor
    #define USE_TEMP_SENSOR
    
    #define MY_RADIO_NRF24
    #include <MySensors.h>
    #include <SPI.h>
    #include <Bounce2.h>
    
    #define RELAY_PIN    3  // Arduino Digital I/O pin number for relay 
    #define RELAY_PIN_2  5
    #define BUTTON_PIN   4  // Arduino Digital I/O pin number for button 
    #define BUTTON_PIN_2 7
    
    #define CHILD_ID 11 // Id of the sensor child for 1st relay
    #define CHILD_ID_2 12 // Id of the sensor child for 2nd relay
    
    // Relay status
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    // Source of state change (used when printing debug information)
    #define CHANGE_STATE_SOURCE_RADIO 0
    #define CHANGE_STATE_SOURCE_SWITCH 1
    
    
    // Temperature sensor definitions
    #ifdef USE_TEMP_SENSOR
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #define ONE_WIRE_BUS 8
    #define CHILD_DSB_ID 13 // Id of the sensor child for temperature sensor
    #define TEMPERATURE_ROUNDING 10.f   // Change value to change rounding of temperature value: 10.f for 0.1°C change, 5.f for 0.2°C change, 2.f for 0.5°C change
    #endif
    
    
    
    Bounce debouncer = Bounce();
    int oldValue;
    bool state;
    Bounce debouncer2 = Bounce();
    int oldValue2;
    bool state2;
    
    MyMessage msg(CHILD_ID, V_LIGHT);
    MyMessage msg2(CHILD_ID_2, V_LIGHT);
    
    #ifdef USE_TEMP_SENSOR
    MyMessage msgTemp(CHILD_DSB_ID, V_TEMP);
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
    #endif
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Double Relay & Button", "0.2");
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_LIGHT);
      present(CHILD_ID_2, S_LIGHT);
    #ifdef USE_TEMP_SENSOR
      present(CHILD_DSB_ID, S_TEMP);
    #endif
    }
    
    void setup()
    {
    #ifdef USE_TEMP_SENSOR
      sensors.begin();
      sensors.setWaitForConversion(false);
    #endif
    
      // Setup the button
      pinMode(BUTTON_PIN, INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN, HIGH);
    
      // Setup the button
      pinMode(BUTTON_PIN_2, INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN_2, HIGH);
    
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
    
      debouncer2.attach(BUTTON_PIN_2);
      debouncer2.interval(5);
    
      // Set the initial values of oldValue/oldValue2 variables from status of physical switches
      //  if this is not done the loop() will detect status change and switch the relays on or off
      debouncer.update();
      debouncer2.update();
      oldValue = debouncer.read();
      oldValue2 = debouncer2.read();
    
    
      // Make sure relays are off when starting up
      setRelayState(RELAY_PIN, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(RELAY_PIN, OUTPUT);
    
      digitalWrite(RELAY_PIN_2, RELAY_OFF);
      // Then set relay pins in output mode
      pinMode(RELAY_PIN_2, OUTPUT);
    
      // Set relay to last known state (using eeprom storage)
      state = loadState(CHILD_ID);
      setRelayState(RELAY_PIN, state);
    
      state2 = loadState(CHILD_ID_2);
      setRelayState(RELAY_PIN_2, state2);
    }
    
    
    /*
       Example on how to asynchronously check for new messages from gw
    */
    void loop()
    {
    #ifdef USE_TEMP_SENSOR
      static float prevTemp = 0;
    #endif
    
      debouncer.update();
      debouncer2.update();
      // Get the update value
      int value = debouncer.read();
      int value2 = debouncer2.read();
    
      if (value != oldValue) {
        send(msg.set(state ? false : true), true); // Send new state and request ack back
        // Write some debug info
        printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID, value);
      }
      oldValue = value;
    
      if (value2 != oldValue2) {
        send(msg2.set(state2 ? false : true), true); // Send new state and request ack back
        // Write some debug info
        printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID_2, value2);
      }
      oldValue2 = value2;
    
      // Fetch temperatures from Dallas sensors
    #ifdef USE_TEMP_SENSOR
      sensors.requestTemperatures();
      // Fetch and round temperature to one decimal
      float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(0) * TEMPERATURE_ROUNDING)) / TEMPERATURE_ROUNDING;
    
      if (temperature != -127.00f && temperature != 85.00f && prevTemp != temperature) {
        // Send in the new temperature
        send(msgTemp.set(temperature, 1));
    #ifdef MY_DEBUG
        Serial.print("Sent temperature: ");
        Serial.println(temperature);
    #endif
        prevTemp = temperature;
      }
    #endif
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.isAck()) {
    #ifdef MY_DEBUG
        Serial.println(F("This is an ack from gateway"));
    #endif
      }
      else if (message.type == V_LIGHT && message.sensor == CHILD_ID) {
        // Change relay state
        state = message.getBool();
        setRelayState(RELAY_PIN, state);
        // Store state in eeprom
        saveState(CHILD_ID, state);
        // Write some debug info
        printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID, state);
      }
      else if (message.type == V_LIGHT && message.sensor == CHILD_ID_2) {
        state2 = message.getBool();
        setRelayState(RELAY_PIN_2, state2);
        // Store state in eeprom
        saveState(CHILD_ID_2, state2);
        // Write some debug info
        printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID_2, state2);
      }
    }
    
    // Set status of a relay pin
    void setRelayState(byte relayPin, bool value) {
      digitalWrite(relayPin, value ? RELAY_ON : RELAY_OFF);
    }
    
    // Print debug info, centralized in one place to minimize memory usage and have only one #ifdef MY_DEBUG for all state change messages
    void printStateChangedDebug(int source, int sensorID, bool value) {
    #ifdef MY_DEBUG
      Serial.print(F("Sensor value changed, source="));
      Serial.print(source == CHANGE_STATE_SOURCE_RADIO ? F("Radio") : F("Physical switch"));
      Serial.print(F(", Sensor="));
      Serial.print(sensorID);
      Serial.print(F(", New status: "));
      Serial.println(value);
    #endif
    }
    

  • Hardware Contributor

    Temperature stabilized, but module became irresponsive. Switched on then off, it lit up but didn't appear in Domoticz log. Then after some time the power light of the arduino went off. Slow blow fuse is dead 😞

    When I power the arduino through the programmer everything is fine, so I suppose the HLK died



  • @Nca78
    You check out what's happened? My plate at the moment is working without a problem and the temperature in the box 35°C (bulb 40W)

    But on the new board my domoticz does detect ds18b20 and I think the problem may be inaccurate soldering DS18B20 because it is a very small gap between the legs.
    What do you think?


  • Hardware Contributor

    @okos I think position of the ds18b20 is a real safety problem on this board. It's no use to put a relatively "safe" module like the HLK if we put secondary trace so close from the mains trace. Even without the ds18b20 soldered the traces are too close. I might drill the ds18b20 hole that is the closest from the main trace bigger to create some clearance.

    But I think my problem was from faulty HLK. I put a new slow blow fuse and a new HLK, it was a pain to change it 🙂 It's been running over 24h without problem now, didn't put a load yet.



  • I would like to suggest to move the termal fuse and the varistor.

    I would move the temp fuse to where the SB fuse is, the latter to where the varistor is. And finally the varistor to where the "My Sensors Board" inscription is.

    This would remove the mains trace from the middle of the PCB away from the ds18b20 and the connector for the switches.

    It would also allow to move the NRF24 and the switched connector closer to the HLK and thus further from the mains connector.

    Best regards



  • Can someone please point me out the software used to design the PCB?
    If I got some time I would like to try out the improvements that I've mentioned before.
    It makes more or less 10 years the last time that I've did some PCB design with Eagle, nostalgia.... 🙂


  • Hardware Contributor

    This post is deleted!

  • Hardware Contributor

    @Daniel-Oliveira

    I think it's DipTrace 😉


  • Hardware Contributor

    Running fine now, nearly one week with a load connected (2*28W tubes) and switching on/off without a problem.



  • @Nca78 said:

    Running fine now, nearly one week with a load connected (2*28W tubes) and switching on/off without a problem.

    Super 😄
    I solder already the third board, and I hope that the thermometer will be visible in domoticz.



  • Dear All,

    I'm interested in build some exemplar of this beautiful project, so for that reason I ordered all the items present in Bill Of Material.

    I ordererd most of the item without problem, but I get in trouble in finding the "Slow Blow Fuse (250v 0.2A)", as in the link given, the 0.2A fuse is not available and in plus the seller doesn't send to Italy.

    For that reason I started a search in a lot of different shop, from the most knowed to the less knowed, but I'm not able to find it for a reasonable price.
    As example I found a Company that sell 10 of it for a total of 3.40$ but they ship it for 35$, so I think is a nonsense.
    Other Company only sell minimum quantity of 1000 item, but I don't need that amount and in plus the price will become very high.

    So for that reason I ask you if someone can suggest me an internet shop where I can find it for a reasonable price (item+shipping), or eventually if it's possible to substitute that "Slow Blow Fuse (250v 0.2A)" with different kind of fuse maybe more easy to find.

    Or as a last chance, if someone eventually have 10 of it and is available to send me (off course I will pay for the item and for the shipping) in Italy.

    Thank you in advance for your attention.



  • @Mercury69
    See: Aliexpress Sorry these required a fuse holder 😞

    maybe this one ? Mouser.it


  • Hardware Contributor

    Sorry the shop I bought mine from doesn't sell a single fuse anymore ...
    I don't know if these fuses will fit on the board but they are the closest specced having some leads :
    https://www.aliexpress.com/item/10-pcs-lot-T250mA-250V-TE5-Slow-Blow-Subminiature-Fuse-UL-VDE-RoHS-Approved-250mA/32712347448.html

    I think it would be better for next revision of this board or future boards powered from main to use a fuse holder...



  • Thank you to all for your rapid answer.

    @Amster
    I saw the fuse in Mouser website, I think the same one is the following:

    http://www.mouser.it/ProductDetail/Littelfuse/0875200MXEP/?qs=%2Fha2pyFadugxaz6Ka1QIzhvtD8HnMnU0Sbd%2Fe9cxA257in2%2FbECi0w==

    I also called they and they told me that only after I will put the order they check the real availability in the various site they have and if present they send me, but if not present I have to wait 10 Week as this is the Factory Lead Time.
    And more of this the shipping will cost 20€, so a total of 39,80€ for 10 little fuse I think is too much.

    @Nca78

    I think I will go for the one you suggest. It's cheap, with free shipping and it seems not to big to don't fit in the board.

    Now I will have to wait about 1 month before all parts arrive, then I will let you know if fuse will fit or not.

    Thank you again for your attention and a big hello from Italy.



  • I bought here in Ukraine circular-shaped slow-blow fuses and soldered them almost normally (here is their datasheet http://www.rcscomponents.kiev.ua/datasheets/5rt.JPG), so far everything is ok.
    And here is my board instance:
    mysensors board



  • Very nice project. I would like to have access to few more pins to add some functionality like motion sensor, and light sensor. Of course those would be outside of the wall 🙂


  • Hardware Contributor

    @jendrush said:

    Very nice project. I would like to have access to few more pins to add some functionality like motion sensor, and light sensor. Of course those would be outside of the wall 🙂

    Hello, I would not advise to use this board with sensors accessible to fingers. The spacing between main voltage and low voltage traces is too narrow at some points on the board and a short circuit is possible. It is fine/safe to use only in a closed box or connected to wall switches as they are designed to be safe with main voltage.



  • @Nca78 said:

    Hello, I would not advise to use this board with sensors accessible to fingers. The spacing between main voltage and low voltage traces is too narrow at some points on the board and a short circuit is possible. It is fine/safe to use only in a closed box or connected to wall switches as they are designed to be safe with main voltage.

    I think that woundn't be so risky becouse o think about mounting it not behind light buttons, but in this box just below ceiling(where wires crossing their paths), this box is placed more than 2 meters above floor level.


  • Hardware Contributor

    @jendrush said:

    I think that woundn't be so risky becouse o think about mounting it not behind light buttons, but in this box just below ceiling(where wires crossing their paths), this box is placed more than 2 meters above floor level.

    Still a bit, no ?
    Anyway if you have requirement for a board that would be both easy to solder and safe even outside of electrical box, can you send them to me by private message ? I'm working on such a board and I'm opened to any improvement ideas of use cases that would not be filled by currently available boards.



  • @Nca78 said:

    Anyway if you have requirement for a board that would be both easy to solder and safe even outside of electrical box, can you send them to me by private message ? I'm working on such a board and I'm opened to any improvement ideas of use cases that would not be filled by currently available boards.

    I've just thought about little node that could be mounted in almost every room, and be barely visible. This box below ceiling is quite good place for this. I have plan to do something like dome(3d printed) instead of flat box cover to fit electronics there. As i told in previous messages i would like to have node that could turn on/off light, read temperature, movement, and light level by LDR.



  • Hello.
    I would like to ask whether it is normal that the switch does not work if the server domoticz off? I want to use the switch only crash server 😳 now i cant


  • Hardware Contributor

    @okos said:

    Hello.
    I would like to ask whether it is normal that the switch does not work if the server domoticz off? I want to use the switch only when I have a server crash and now does not work.😳

    That's a problem of MySensors, if you don't have physical switches connected directly on your node you are depending on a functionnal gateway/controller to run... That's why I'm going more toward the "upgraded" livolo-style wall switch now, even if the radio is down you can still maintain basic functionality of the switch. This board can do it but you need to have neutral wire in the switch box which I don't have 😞



  • @okos Unfortunately current mysensors version won't allow to 'boot' your code before their module connects to a controller. This is a main reason I moved to ESP8266 hardware.


  • Hardware Contributor

    @mr_const said:

    @okos Unfortunately current mysensors version won't allow to 'boot' your code before their module connects to a controller. This is a main reason I moved to ESP8266 hardware.

    It does, you can put a before() method in your sketch.


  • Admin

    You can disable this behaviour by defining:

    #define MY_TRANSPORT_DONT_CARE_MODE
    #define MY_PARENT_NODE_ID 0
    


  • Thanx for the answers
    This is not good news from the switch does not work without a server. Mr.const, Do you use esp8266 in domoticz to control the light?

    edit: hek, I not noticed your post.
    What changes adding this?

    #define MY_TRANSPORT_DONT_CARE_MODE
    #define MY_PARENT_NODE_ID 0```

  • Admin

    @okos said:

    What changes adding this?

    It disables the transport sanity check at startup.



  • @hek

    @hek said:

    You can disable this behaviour by defining:

    #define MY_TRANSPORT_DONT_CARE_MODE
    #define MY_PARENT_NODE_ID 0
    

    This is a really good news, I'll give it a try to check if it works correctly with controller and when controller is lost.



  • @hek said:

    You can disable this behaviour by defining:

    #define MY_TRANSPORT_DONT_CARE_MODE
    #define MY_PARENT_NODE_ID 0
    

    sorry for the ridiculous question but I have to enter into a sketch? or MyConfig.h?


  • Admin

    In the sketch before including MySensors.h



  • @hek

    @hek said:

    You can disable this behaviour by defining:

    #define MY_TRANSPORT_DONT_CARE_MODE
    #define MY_PARENT_NODE_ID 0
    

    Tried it. Doesn't work. Btw, I searched all mysensors sources (2.0) and didn't find any use of a MY_TRANSPORT_DONT_CARE_MODE definition.


  • Admin

    @mr_const said:

    MY_TRANSPORT_DONT_CARE_MODE

    Sorry, yes, It's all in the development branch:

    https://github.com/mysensors/MySensors/search?utf8=✓&q=MY_TRANSPORT_DONT_CARE_MODE



Suggested Topics

  • 5
  • 3
  • 41
  • 9
  • 245
  • 4
  • 10
  • 38

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts