Navigation

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

    Topics created by StKilda

    • StKilda

      Reporting an independent float switch and relay
      My Project • • StKilda  

      7
      0
      Votes
      7
      Posts
      944
      Views

      StKilda

      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; } }
    • StKilda

      Using the relay actuator example to light LED directly off the digital outputs?
      My Project • • StKilda  

      1
      0
      Votes
      1
      Posts
      464
      Views

      No one has replied

    • StKilda

      Powering the nano with a battery
      Hardware • • StKilda  

      11
      0
      Votes
      11
      Posts
      2256
      Views

      zafirkalvin

      You can power the Nano with 3 x AA (or AAA) alkaline cells (4.5v) connected to the 5v pin. The 4.5v will also be suitable Speed Test Scrabble Word Finder Solitaire for powering a servo. And the AA (or AAA) cells will last longer than the 9v PP3 style battery.
    • StKilda

      Total noob!
      Hardware • • StKilda  

      5
      0
      Votes
      5
      Posts
      994
      Views

      StKilda

      @wergeld thanks. While I do have a pi, it's currently managing my fish tank - so I will probably set things up on the laptop and if it works out will transfer things to another pi later on. What brought me to here was a desire to set up two light pulse meter sensors. One on my import meter the other on my solar generating meter. Currently I have a commercial hall effect display - but its pretty basic and it doesn't show direction, meaning if it shows 1Kwh - I have no idea if this is importing or exporting. I figure to show the direction with led initially (if its a net export import will be zero and export will be flashing). Anyway - thats my initial plan. if this works then I can think about pulse rate, Watts and then turning things on when exporting enough power.