Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Relay
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

💬 Relay

Scheduled Pinned Locked Moved Announcements
139 Posts 47 Posters 33.7k Views 45 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fhenrycoF Offline
    fhenrycoF Offline
    fhenryco
    wrote on last edited by
    #90

    wow! fantastic! ... the github link readme warns that it's not yet fully ready but the interface is already impressive!
    I still have the same question i had for nodemanager though : for measuring another battery than the one that feeds Vcc obviously another pin is needed, however why not propose as well the option of measuring such pin voltage but with Vcc as the reference rather than the internal 1.1V which most of the time makes necessary a voltage divider ? Actually i did the modification in nodemanager.cpp to use DEFAULT (~3.3V) rather than INTERNAL (1.1V) reference for a 3.3 pro mini and i can get the expected battery level without any voltage divider.

    Another unrelated question i have is : could there be any way to adapt the idea of the readVcc method (which is to measure the internal 1.1V against the Vcc reference to get Vcc) but using any voltage applied to a pin as the reference to again measure the internal 1.1 against it ? This would allow the masurement of any voltage greater than 1.1 without voltage divider while the usual method would be applied for measuring any voltage lower than 1.1 ... what did i miss that makes this impossible ?

    fhenrycoF 1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #91

      We need to use the internal reference since it is the only stable voltage source and you need the voltage divider to lower the measured voltage between 0 and 1.1v. There are not many options to choose from

      1 Reply Last reply
      0
      • fhenrycoF fhenryco

        wow! fantastic! ... the github link readme warns that it's not yet fully ready but the interface is already impressive!
        I still have the same question i had for nodemanager though : for measuring another battery than the one that feeds Vcc obviously another pin is needed, however why not propose as well the option of measuring such pin voltage but with Vcc as the reference rather than the internal 1.1V which most of the time makes necessary a voltage divider ? Actually i did the modification in nodemanager.cpp to use DEFAULT (~3.3V) rather than INTERNAL (1.1V) reference for a 3.3 pro mini and i can get the expected battery level without any voltage divider.

        Another unrelated question i have is : could there be any way to adapt the idea of the readVcc method (which is to measure the internal 1.1V against the Vcc reference to get Vcc) but using any voltage applied to a pin as the reference to again measure the internal 1.1 against it ? This would allow the masurement of any voltage greater than 1.1 without voltage divider while the usual method would be applied for measuring any voltage lower than 1.1 ... what did i miss that makes this impossible ?

        fhenrycoF Offline
        fhenrycoF Offline
        fhenryco
        wrote on last edited by fhenryco
        #92

        i also just realized that there is a special AREF pin intended for what i was thinking about ... but it's not available on the mini pro.

        My measurements using Vcc as Ref have been indeed very fluctuating, however what i get was highly sufficient to monitor the battery feeding a 3.3v step up regulator to the arduino and help anticipate failure

        1 Reply Last reply
        0
        • skywatchS Offline
          skywatchS Offline
          skywatch
          wrote on last edited by
          #93

          I just noticed another thing that should be changed in the 'relay with button' sketch....

          S_LIGHT should be S_BINARY
          V_LIGHT shoud be V_STATUS

          1 Reply Last reply
          0
          • A Offline
            A Offline
            APL2017
            wrote on last edited by
            #94

            I would like to clarify operation of the sketch, where more than 1 sensors input are used along with more than 1 relay actuator. in one node

            1. Does node need unique child ID for each sensor input AND relay output?
            2. If that is the case how child ID is assigned to relay actuators in the above examples?
            1 Reply Last reply
            0
            • jopebeJ Offline
              jopebeJ Offline
              jopebe
              wrote on last edited by jopebe
              #95

              This is a nice sketch and it is very universal for relays. Now m looking for a similar sketch for digital inputs such as buttons i.e.. I would like to join both. The problem: I want to use a mega for reading status of a lot of digital outputs (min.20) of another ISP. It is only High or Low. Only when the level changes, I want the mega send a message to the gateway. I tried this "for" loop, but it didnt help. There are too many informations sent to the gateway. I imagine a solution, where only a change at the pin will create an information, that is sent to the gateway.
              Here my test, which didnt run:
              void loop()
              {

              for (int sensor=16, pin=BIN_1; sensor<=NUMBER_OF_BIN; sensor++, pin++)
              {
              int BUTT;
              int BUTTOLD;
              BUTT =digitalRead(pin);
              if (BUTT != BUTTOLD && BUTT !=0){
              MyMessage msg(sensor, V_TRIPPED);
              send(msg.set(BUTT ? "1" : "0"));
              }
              BUTTOLD = BUTT;
              wait (900);
              }
              }
              Has anybody an idea or a hint for me?

              1 Reply Last reply
              0
              • gohanG Offline
                gohanG Offline
                gohan
                Mod
                wrote on last edited by
                #96

                I believe there is a logic error in the sketch as you would need to declare global variables BUTTOLD_XX unique for each button, otherwise how can you keep track of the variable between each loop and FOR iteraction?

                1 Reply Last reply
                0
                • jopebeJ Offline
                  jopebeJ Offline
                  jopebe
                  wrote on last edited by
                  #97

                  Thank You for Your quick answer.
                  Do I understand You correctly: I must index the BUTTOLD?
                  As BUTTOLD[pin) for example or how? Where?

                  1 Reply Last reply
                  0
                  • gohanG Offline
                    gohanG Offline
                    gohan
                    Mod
                    wrote on last edited by
                    #98

                    You need to create the single variables one by one, unless somebody else has a better way to do it

                    1 Reply Last reply
                    0
                    • Mitja BlazinsekM Offline
                      Mitja BlazinsekM Offline
                      Mitja Blazinsek
                      wrote on last edited by
                      #99

                      why i can't compile for arduino pro mini on other boards i can upload

                      mfalkviddM 1 Reply Last reply
                      0
                      • Mitja BlazinsekM Mitja Blazinsek

                        why i can't compile for arduino pro mini on other boards i can upload

                        mfalkviddM Online
                        mfalkviddM Online
                        mfalkvidd
                        Mod
                        wrote on last edited by
                        #100

                        @mitja-blazinsek the error messages are usually essential to figuring out. Did you get any?

                        1 Reply Last reply
                        0
                        • Mitja BlazinsekM Offline
                          Mitja BlazinsekM Offline
                          Mitja Blazinsek
                          wrote on last edited by
                          #101

                          Arduino: 1.8.1 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega168 (5V, 16 MHz)"

                          In file included from c:\users\mitja\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\io.h:99:0,

                                       from c:\users\mitja\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\pgmspace.h:90,
                          
                                       from C:\Users\mitja\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.20\cores\arduino/Arduino.h:28,
                          
                                       from sketch\button_relay.ino.cpp:1:
                          

                          C:\Users\mitja\Documents\Arduino\libraries\MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'bool hwUniqueID(uint8_t (*)[16])':

                          C:\Users\mitja\Documents\Arduino\libraries\MySensors/hal/architecture/AVR/MyHwAVR.cpp:246:26: error: 'SIGRD' was not declared in this scope

                          ((uint8_t)uniqueID) = boot_signature_byte_get(0x00);

                                                ^
                          

                          C:\Users\mitja\Documents\Arduino\libraries\MySensors/hal/architecture/AVR/MyHwAVR.cpp:247:30: error: 'SIGRD' was not declared in this scope

                          ((uint8_t)uniqueID + 1) = boot_signature_byte_get(0x02);

                                                    ^
                          

                          C:\Users\mitja\Documents\Arduino\libraries\MySensors/hal/architecture/AVR/MyHwAVR.cpp:248:30: error: 'SIGRD' was not declared in this scope

                          ((uint8_t)uniqueID + 2) = boot_signature_byte_get(0x04);

                                                    ^
                          

                          C:\Users\mitja\Documents\Arduino\libraries\MySensors/hal/architecture/AVR/MyHwAVR.cpp:249:30: error: 'SIGRD' was not declared in this scope

                          ((uint8_t)uniqueID + 3) = boot_signature_byte_get(0x01); //OSCCAL

                                                    ^
                          

                          Multiple libraries were found for "Bounce2.h"
                          Used: C:\Users\mitja\Documents\Arduino\libraries\Bounce2
                          Not used: C:\Users\mitja\Documents\Arduino\libraries\Bounce2-master
                          exit status 1
                          Error compiling for board Arduino Pro or Pro Mini.

                          This report would have more information with
                          "Show verbose output during compilation"
                          option enabled in File -> Preferences.

                          1 Reply Last reply
                          0
                          • Mitja BlazinsekM Offline
                            Mitja BlazinsekM Offline
                            Mitja Blazinsek
                            wrote on last edited by
                            #102

                            OK it's probaly because ia have mini with 168 chip i have to buys 328 :( again wait 1month to arive from china

                            1 Reply Last reply
                            1
                            • L Offline
                              L Offline
                              lekeb
                              wrote on last edited by
                              #103

                              hello.
                              I am building a node with several kind of sensors and two relays.
                              My sensors use CHILD ID from 0 to 3. I would like to start child ID of relay from 4.
                              How I can't do that with this sketch?
                              I guess I have to change this part of sketch :
                              "for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                              // Register all sensors to gw (they will be created as child devices)
                              present(sensor, S_BINARY);"

                              correct?

                              thanks

                              rejoe2R 1 Reply Last reply
                              0
                              • L lekeb

                                hello.
                                I am building a node with several kind of sensors and two relays.
                                My sensors use CHILD ID from 0 to 3. I would like to start child ID of relay from 4.
                                How I can't do that with this sketch?
                                I guess I have to change this part of sketch :
                                "for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                // Register all sensors to gw (they will be created as child devices)
                                present(sensor, S_BINARY);"

                                correct?

                                thanks

                                rejoe2R Offline
                                rejoe2R Offline
                                rejoe2
                                wrote on last edited by rejoe2
                                #104

                                @lekeb
                                You may do something like this:
                                In Header:

                                uint8_t DS_First_Child_ID = 7; //First Child-ID to be used by Dallas Bus
                                

                                an then in presentation():

                                for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
                                    present(i + DS_First_Child_ID, S_TEMP);
                                }
                                

                                But afaik, it's not recommended to shift the ChildID's for relays but always start with 1. Imo it's better to change the ChildID's of the other attached sensors. You may also take care (in case of shifting ID's) about a consistent mapping from ID to the PINs where the relays are attached.

                                Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                1 Reply Last reply
                                0
                                • gohanG Offline
                                  gohanG Offline
                                  gohan
                                  Mod
                                  wrote on last edited by
                                  #105

                                  Agreed, set you sensors to higher ID numbers like 20 or 30 and you are good to go .

                                  1 Reply Last reply
                                  0
                                  • L Offline
                                    L Offline
                                    lekeb
                                    wrote on last edited by
                                    #106

                                    ok thanks a lot I will try this night

                                    1 Reply Last reply
                                    0
                                    • L Offline
                                      L Offline
                                      lekeb
                                      wrote on last edited by
                                      #107

                                      perfect it works great. I started my temperature sensor at CHILD ID 4 and let relays from 1 to 2. I had to add also "DS_First_Child_ID" in the sent message to gateway.
                                      thanks

                                      1 Reply Last reply
                                      0
                                      • pepsonP Offline
                                        pepsonP Offline
                                        pepson
                                        wrote on last edited by
                                        #108

                                        Hi
                                        Please put to this topic code your sketch....
                                        Thanks

                                        1 Reply Last reply
                                        0
                                        • L Offline
                                          L Offline
                                          lekeb
                                          wrote on last edited by
                                          #109

                                          Sur,

                                          my node controls two relays, one water pressure sensor and three DS18b20

                                          /**
                                           code pour controle cave a vin, temp et pression
                                           */
                                          
                                          // Enable debug prints to serial monitor
                                          //#define MY_DEBUG
                                          
                                          // Enable and select radio type attached
                                          #define MY_RADIO_NRF24
                                          
                                          // Enable repeater functionality for this node
                                          #define MY_REPEATER_FEATURE
                                          
                                          #define MY_NODE_ID 15
                                          #include <SPI.h>
                                          #include <MySensors.h>
                                          #include <DallasTemperature.h>
                                          #include <OneWire.h>
                                          
                                          #define BARO_CHILD 0 //Child ID for pressure sensor
                                          #define BAR_SENSOR_ANALOG_PIN 0 // pin for pressure sensor
                                          
                                          #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
                                          
                                          #define ONE_WIRE_BUS 5 // Pin where dallase sensor is connected 
                                          #define MAX_ATTACHED_DS18B20 16
                                          #define RELAY_PIN 3 //pin for first relay
                                          #define NUMBER_OF_RELAYS 2
                                          #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
                                          
                                          OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
                                          DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
                                          float lastTemperature[MAX_ATTACHED_DS18B20];
                                          int numSensors=0;
                                          bool receivedConfig = false;
                                          bool metric = true;
                                          float lastpression;
                                          uint8_t DS_First_Child_ID = 4; //First Child-ID to be used by Dallas Bus
                                          MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
                                          MyMessage msg(0,V_TEMP);
                                          
                                          
                                          void before()
                                          {
                                              for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                                  // Then set relay pins in output mode
                                                  pinMode(pin, OUTPUT);
                                                  // Set relay to last known state (using eeprom storage)
                                                  digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
                                              }
                                              
                                              // Startup up the OneWire library
                                            sensors.begin();
                                          }
                                          
                                          void setup()
                                          {
                                             
                                          // requestTemperatures() will not block current thread
                                            sensors.setWaitForConversion(false);
                                          }
                                          
                                          void presentation()
                                          {
                                              // Send the sketch version information to the gateway and Controller
                                              sendSketchInfo("Buanderie node", "1.0");
                                          
                                              //present pressure sensor
                                              present(BARO_CHILD, S_BARO);
                                          
                                              for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                                  // Register all sensors to gw (they will be created as child devices)
                                                  present(sensor, S_BINARY);
                                              }
                                          
                                              
                                          // Fetch the number of attached temperature sensors  
                                            numSensors = sensors.getDeviceCount();
                                          
                                            // Present all sensors to controller
                                            for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
                                               present(i + DS_First_Child_ID, S_TEMP);
                                            }
                                          }
                                          
                                          
                                          
                                          void loop()
                                          {
                                            //read water pressure
                                          int lecture_adc = analogRead(BAR_SENSOR_ANALOG_PIN);
                                            float pression = ((lecture_adc*5/1024.0)-0.50)/1.7;
                                            if(pression != lastpression) { 
                                                send(pressureMsg.set(pression, 2));
                                            lastpression = pression;
                                            }
                                            
                                            
                                            // Fetch temperatures from Dallas sensors
                                            sensors.requestTemperatures();
                                          
                                            // query conversion time and sleep until conversion completed
                                            int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                                            // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
                                            sleep(conversionTime);
                                          
                                            // Read temperatures and send them to controller 
                                            for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
                                          
                                              // Fetch and round temperature to one decimal
                                              float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
                                          
                                              // Only send data if temperature has changed and no error
                                              #if COMPARE_TEMP == 1
                                              if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
                                              #else
                                              if (temperature != -127.00 && temperature != 85.00) {
                                              #endif
                                          
                                                // Send in the new temperature
                                                send(msg.setSensor(i + DS_First_Child_ID).set(temperature,1));
                                                // Save new temperatures for next compare
                                                lastTemperature[i]=temperature;
                                              }
                                            }
                                          }
                                          
                                          void receive(const MyMessage &message)
                                          {
                                              // We only expect one type of message from controller. But we better check anyway.
                                              if (message.type==V_STATUS) {
                                                  // Change relay state
                                                  digitalWrite(message.sensor-1+RELAY_PIN, 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());
                                              }
                                          }
                                          
                                          gohanG 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          8

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular