Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. StKilda
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    StKilda

    @StKilda

    1
    Reputation
    14
    Posts
    360
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    StKilda Follow

    Best posts made by StKilda

    • RE: Powering the nano with a battery

      @mfalkvidd Thanks. The sensor (an LM393 light pulse sensor) and the radio seem to consume about 12mA each (at their respective voltages).

      To test the sensor / gateway / controller combination I powered the sensor with a 9v battery. Looks like after about 12 hours it stopped transmitting (although the units lights are still lit) but guess it lost power to run.

      Will have to think about long term power as thats clearly not sustainable. However, it all seems to be working so the major learning is going well!

      posted in Hardware
      StKilda
      StKilda

    Latest posts made by StKilda

    • RE: Reporting an independent float switch and relay

      Success. stole some code from a post a while ago: No concept of how efficient this is, but hey...

      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-2018 Sensnology AB
         Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
      
         Documentation: http://www.mysensors.org
         Support Forum: http://forum.mysensors.org
      
         This program is free software; you can redistribute it and/or
         modify it under the terms of the GNU General Public License
         version 2 as published by the Free Software Foundation.
      
       *******************************
      
         REVISION HISTORY
         Version 1.0 - Henrik Ekblad
      
         DESCRIPTION
         Example sketch showing how to control physical relays.
         This example will remember relay state after power failure.
         http://www.mysensors.org/build/relay
      */
      
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable repeater functionality for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MyConfig.h>
      #include <MySensors.h>
      #include <SPI.h>
      
      #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      
      #define FLOAT_SWITCH_PIN 3 //FLOAT SWITCH PIN
      
      #define LED_GRN_PIN 7
      #define LED_RED_PIN 8
      #define MY_TRANSPORT_WAIT_READY_MS (3000)
      #define CHILD_ID 4
      #define RELAY_ON 1
      #define RELAY_OFF 0
      
      boolean lastSensorState;
      unsigned long lastUpdate;
      
      MyMessage msg(CHILD_ID, V_STATUS);
      
      void setup()
      {
          pinMode(RELAY_PIN, OUTPUT);
          pinMode(FLOAT_SWITCH_PIN, INPUT);
          // Define LED
          pinMode(LED_GRN_PIN, OUTPUT);
          pinMode(LED_RED_PIN, OUTPUT);
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Rollermat", "3.0");
        
          // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_BINARY);
        
      }
      
      
      void loop()
      {
      
      
      
        // LOW corresponds to the float switch being at its highest point (i.e. rollermat is clogged)
        if(digitalRead(FLOAT_SWITCH_PIN) == LOW)
        {
           digitalWrite(RELAY_PIN, RELAY_ON); //turn on the motor
           digitalWrite(LED_GRN_PIN, LOW);    //turns on the Green LED
           digitalWrite(LED_RED_PIN, HIGH);    //turns off the Red LED
        }
        
        //otherwise the float switch is HIGH
        // HIGH corresponds to the float switch being at its lowest point (i.e. rollermat is clean and water is flowing)
        else
        {
           digitalWrite(RELAY_PIN, RELAY_OFF); //turns off the pump
           digitalWrite(LED_GRN_PIN, HIGH);    //turns off the Green LED
           digitalWrite(LED_RED_PIN, LOW);    //turns on the Red LED
        }
        
        boolean sensorState = digitalRead(FLOAT_SWITCH_PIN);
        if (sensorState != lastSensorState)
        {
          #ifdef DEBUG
            digitalWrite(FLOAT_SWITCH_PIN,sensorState? HIGH : LOW); 
            Serial.println(sensorState? "Motor On" : "Motor Off");
          #endif
          send(msg.set(sensorState?"1":"0"));  // Update gateway on change of state
          lastSensorState = sensorState;
        }
        
      }
      
      
      
      posted in My Project
      StKilda
      StKilda
    • RE: Reporting an independent float switch and relay

      Ha. Another rookie error - the sketch is sending the current state on every loop so it's flooding the gateway. I need to modify so it only sends when it changes state. Can you point me to an example that does this and I will adjust to my sketch?

      posted in My Project
      StKilda
      StKilda
    • RE: Reporting an independent float switch and relay

      Update: I booted up the gateway and controller. The above sensor/actuator sketch then operated normally. I then powered down the gateway - and the sensor/actuator continued to operate independently. I'm guessing that it needed to present itself at least once.

      posted in My Project
      StKilda
      StKilda
    • RE: Reporting an independent float switch and relay

      Thanks. But I am still not getting any joy. Here is the full sketch. When I comment out all the ySensor related lines the sketch works. As before, at the moment I have no controller or gw running - but as far as I can see this should not prevent the relay and LED from operating. I'm new to this so perhaps am making a basic error. Thanks.

      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable repeater functionality for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MyConfig.h>
      #include <MySensors.h>
      #include <SPI.h>
      
      #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      
      #define FLOAT_SWITCH_PIN 3 //FLOAT SWITCH PIN
      
      #define LED_GRN_PIN 7
      #define LED_RED_PIN 8
      #define MY_TRANSPORT_WAIT_READY_MS (3000)
      #define CHILD_ID 1
      #define RELAY_ON 1
      #define RELAY_OFF 0
      
      
      MyMessage msg(CHILD_ID, V_STATUS);
      uint8_t value = RELAY_ON;
      
      void setup()
      {
          pinMode(RELAY_PIN, OUTPUT);
          pinMode(FLOAT_SWITCH_PIN, INPUT);
          // Set relay to last known state (using eeprom storage)
          pinMode(LED_GRN_PIN, OUTPUT);
          pinMode(LED_RED_PIN, OUTPUT);
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Rollermat", "3.0");
        
          // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_BINARY);
        
      }
      
      
      void loop()
      {
      
      
      
        // LOW corresponds to the float switch being at its highest point (i.e. rollermat is clogged)
        if(digitalRead(FLOAT_SWITCH_PIN) == LOW)
        {
           digitalWrite(RELAY_PIN, RELAY_ON); //turn on the motor
           digitalWrite(LED_GRN_PIN, LOW);    //turns on the Green LED
           digitalWrite(LED_RED_PIN, HIGH);    //turns off the Red LED
        }
        
        //otherwise the float switch is HIGH
        // HIGH corresponds to the float switch being at its lowest point (i.e. rollermat is clean and water is flowing)
        else
        {
           digitalWrite(RELAY_PIN, RELAY_OFF); //turns off the pump
           digitalWrite(LED_GRN_PIN, HIGH);    //turns off the Green LED
           digitalWrite(LED_RED_PIN, LOW);    //turns on the Red LED
        }
        
          value = value == RELAY_ON ? RELAY_OFF:RELAY_ON;
          send(msg.set(value));
      }
      
      posted in My Project
      StKilda
      StKilda
    • Reporting an independent float switch and relay

      I've got some code which uses an arduino to control a relay (12v motor) based on a float switch position. It is essentially "standalone" right now and works fine. I've copied the code below.

      I'd like to convert it to be of use via mySensors so that it can report its activity to the gateway but continues to act independently.

      I've tried to take the example mySensor code for a relay actuator, and inserted what I thought to be the relevant sections for presenting itself to the gw (and removed the parts on receiving commands) - and while the code compiles and loads - the unit does not function.

      I've wired up the radio - but not got a gw or controller turned on at the moment - but I was expecting the unit to operate regardless.

      Is this possible? If so can someone point me in the right direction please. Many thanks

      /***********************************************************************************
       * Rollermat control
       *
       *
       *  Wiring
       *  Pin 3 - Float Switch
       *  Pin 4 - Relay to 12v motor
       *  Pin 7 - Green LED 
       *  Pin 8 - Red LED
       *
       *  Control Behavior:
       *    If the float switch is floating (i.e. rollermat is clogged) then turn on the pump and green led
       *    If the float switch is not floating (i.e. rollermat is clean) turn off the pump and green LED and turn on the red LED
       *
       **********************************************************************************
      */
      
      
      
      //define the input/output pins
      #define FLOAT_SWITCH_PIN 3
      #define MOTOR_1_PIN 4
      #define LED_PIN 7
      #define LED_RED 8
      #define CHILD_ID 1   // Id of the sensor child
      
      
      
      
      
      //setup runs once
      void setup()
      {
        //setup input pins for float switch 
        
        pinMode(FLOAT_SWITCH_PIN, INPUT);
        
        
        //setup output pins for relay and LED board
        pinMode(MOTOR_1_PIN, OUTPUT);
        pinMode(LED_PIN, OUTPUT);
        pinMode(LED_RED, OUTPUT);
      
      }
      
      
      
      //loop() runs indefinitely 
      void loop()
      {
       
      
      
        // LOW corresponds to the float switch being at its highest point (i.e. rollermat is clogged)
        if(digitalRead(FLOAT_SWITCH_PIN) == LOW)
        {
           digitalWrite(MOTOR_1_PIN, HIGH); //turn on the motor
           digitalWrite(LED_PIN, LOW);    //turn on the Green LED
           digitalWrite(LED_RED, HIGH);    //turn of the Red LED
        }
        
        //otherwise the float switch is HIGH
        // HIGH corresponds to the float switch being at its lowest point (i.e. rollermat is clean and water is flowing)
        else
        {
           digitalWrite(MOTOR_1_PIN, LOW); //turn off the pump
           digitalWrite(LED_PIN, HIGH);    //turn off the Green LED
           digitalWrite(LED_RED, LOW);    //turn on the Red LED
        }
      }```
      posted in My Project
      StKilda
      StKilda
    • RE: Powering the nano with a battery

      @zboblamont @Hermann-Kaiser Thanks guys. I'll order me one.

      posted in Hardware
      StKilda
      StKilda
    • Using the relay actuator example to light LED directly off the digital outputs?

      Hey. I've successfully set up an energy pulse sensor talking via a gateway to a Raspberry pi (running Domoticz) (Yay!). While I can see the Watts data on Domoticz - I want to display some elements in a basic format. For example when watts is zero to light an LED on a remote display and When watts is greater than x to light a different LED.

      Looking at the relay actuator example - it seems I could pretty much use this code telling the arduino that it's controlling x "relays" and then running the led (and series resistor) off the digital output?

      Does domoticz pick up the fact that the hardware has x relays and allow me to then use blocky to logic which "relays" (ie LED) are activated etc?

      Thanks for the help!

      StKilda

      posted in My Project
      StKilda
      StKilda
    • RE: 💬 Power Meter Pulse Sensor

      I have two meters I would like to measure: One that the LED is off most of the time and briefly pulses on per increment (at 3200 pulses per Kwh - so I adjusted the pulse factor accordingly). This works fine. The second meter, the LED pulses off (meaning the led it lit most of the time, and pulses off briefly). Do I need to adjust the code in any way to deal with this meter? Thanks. Really impressed it works virtually out of the box.

      posted in Announcements
      StKilda
      StKilda
    • RE: Powering the nano with a battery

      @mfalkvidd Thanks. The sensor (an LM393 light pulse sensor) and the radio seem to consume about 12mA each (at their respective voltages).

      To test the sensor / gateway / controller combination I powered the sensor with a 9v battery. Looks like after about 12 hours it stopped transmitting (although the units lights are still lit) but guess it lost power to run.

      Will have to think about long term power as thats clearly not sustainable. However, it all seems to be working so the major learning is going well!

      posted in Hardware
      StKilda
      StKilda
    • Powering the nano with a battery

      ok. Noob question. With a nano, I have at the radio wired to the 3.3v output and a ground pin, and the sensor tied to the 5v out and the other ground pin. If I want to power the three items from a 9v battery to the Vin pin - I presume I have to hack the battery to share a GND pin? Is there a well trodden path to do this? Thanks

      posted in Hardware
      StKilda
      StKilda