Navigation

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

    Hausner

    @Hausner

    2
    Reputation
    48
    Posts
    745
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Hausner Follow

    Best posts made by Hausner

    • RE: 230V power supply to Arduino

      I have with succes used these:

      http://www.aliexpress.com/item/Travel-Convenient-EU-Plug-Wall-USB-Charger-Adapter-For-Samsung-Galaxy-S5-S4-S3-Note-3/32220133044.html

      They are really easy to dismatle, and the result is this - https://www.dropbox.com/s/ep43uyve5v0msv6/20141206_214210.jpg?dl=0

      At $1.10 I didn't even think about making my own PSU 🙂

      posted in Hardware
      Hausner
      Hausner
    • RE: Motion (PIR), actuator and Temp sensor

      Ok, finally got it to work with this:

      // Example sketch showing how to control physical relays. 
      // This example will remember relay state even after power failure.
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      OneWire oneWire(ONE_WIRE_BUS);
      DallasTemperature sensors(&oneWire);
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      //boolean receivedConfig = false;
      boolean metric = true;
      #define RELAY_1 5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_2 6
      #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
      
      // Motion sensor defs
      unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 4   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 3   // Id of the sensor child
      
      boolean lastTrippedState;
      
      MySensor gw;
      //
      MyMessage msgTemp(0, V_TEMP);
      MyMessage msgRelay2(2, V_LIGHT);
      MyMessage msgMotion(3, V_TRIPPED);
      
      void setup()  
      {   
        gw.begin(incomingMessage, AUTO, true);
        gw.sendSketchInfo("Temp/Relay/Motion Sensor", "1.0");
        //
        gw.present(1, S_LIGHT);
        pinMode(RELAY_1, OUTPUT);
        //
        gw.present(2, S_LIGHT);
        pinMode(RELAY_2, OUTPUT);
        digitalWrite(RELAY_1, gw.loadState(1)? RELAY_ON : RELAY_OFF);
        digitalWrite(RELAY_2, gw.loadState(1)? RELAY_ON : RELAY_OFF);
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        //
        gw.present(CHILD_ID, S_MOTION);
        
        // 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++) {   
           gw.present(0, S_TEMP);
        //}
      }
      //
      void loop() 
      {
        gw.process();
        boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
        if (tripped != lastTrippedState)
        {  
          Serial.println(tripped? "tripped" : "not tripped");
          gw.send(msgMotion.set(tripped?"1":"0"));  // Send tripped value to gw//
          //digitalWrite(RELAY_1, tripped? 1 : 0);
        }
        lastTrippedState = tripped;
        
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures(); 
      
        // 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>((gw.getConfig().isMetric?sensors.getTempCByIndex(0):sensors.getTempFByIndex(0)) * 10.)) / 10.;
      
          // Only send data if temperature has changed more then 1 degC and no error
          if (int(lastTemperature[0]) != int(temperature) && temperature != -127.00) { //added integer
      
            // Send in the new temperature
            gw.send(msgTemp.setSensor(0).set(temperature,1));
            lastTemperature[0]=temperature;
          }
         //}
      }
      
      void incomingMessage(const MyMessage &message) {
        // 
        if (message.type==V_LIGHT && message.sensor == 2) 
        {
          // Change relay state
          digitalWrite(RELAY_2, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          gw.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());
        }
      }
      
      posted in Hardware
      Hausner
      Hausner

    Latest posts made by Hausner

    • Local heating override.

      Hi,

      I need some help.

      I have a Node controlling my floorheating, but now I want to make a "local" override button, incl diode indicating lights.

      My idea is to build it all in a clear plastic housing (so I can see the relay lights). I then thounght about using a tactile button as "override" and some 3mm leds as indicators. Green = Auto, Red = "Manuel" and Blue = Overridden.

      This Is my working scetch on a Nano.

      /**
       * 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.
       *
       *******************************
       *
       * 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
       */ 
      
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      #include <MySensor.h>
      #include <SPI.h>
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      #define NUMBER_OF_RELAYS 8
      const int RELAY[] = {A0, A1, A2, A3, A4, 6, 7, 8};
      #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
      
      MySensor gw(radio, hw);
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, 12, true, 0);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=0; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(RELAY[pin], OUTPUT);    
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(RELAY[pin], gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(RELAY[message.sensor-1], message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.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());
         } 
      }
      

      I need to put in 3 LEDS and a button somewhere. Any help would be appriciated.

      posted in My Project
      Hausner
      Hausner
    • Same value from 2 different placed DS18B20

      Hi,

      I'm having a hard time figuring out, why i'm getting the same value from 2 different DS18B20 from the same node. Both DS18 are on Pin 3.

      I know for SURE, that the values/readings can never be the same, as they are placed 2 different places. It's ALWAYS the second DS that somehow get the first DS's value, and that is then transmitted. The node is monitoring a DIY solar water heating system. 1 DS18B20 (S=1) is placed in the collection tank (55 gal water), and the other is placed inside the waterhose to monitor the heat in the panel.

      Sketch:

      // Running DS temperature sensor(s) and relay(s) on one mysensor arduino node
          // Combines Onewire and Relay code
          // 2014-10-14 Pego: Tested and Running on Uno/Clone and MQTT gateway
          
          // Example sketch showing how to send in OneWire temperature readings
          // Example sketch showing how to control physical relays. 
          // This example will remember relay state even after power failure.
          
          #include <MySensor.h>  
          #include <SPI.h>
          #include <DallasTemperature.h>
          #include <OneWire.h>
          
          #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
          #define MAX_ATTACHED_DS18B20 16
          
          #define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
          #define NUMBER_OF_RELAYS 2 // Total number of attached relays
          #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
          
          unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) 30000 orig
          OneWire oneWire(ONE_WIRE_BUS);
          DallasTemperature sensors(&oneWire);
          MySensor gw;
          float lastTemperature[MAX_ATTACHED_DS18B20];
          int numSensors=0;
          boolean receivedConfig = false;
          boolean metric = true; 
          // Initialize temperature message
          MyMessage msg(0,V_TEMP);
          
          void setup()  
          { 
            // Startup OneWire 
            sensors.begin();
          
            // Startup and initialize MySensors library. Set callback for incoming messages. 
            //gw.begin(); 
            gw.begin(incomingMessage, AUTO, true);
          
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("Temp and Relays", "1.0");
          
            // 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++) {   
               gw.present(i, V_TEMP);
            }
          
            // Fetch relay status
            for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
              // Register all sensors to gw (they will be created as child devices)
              gw.present(sensor, S_LIGHT);
              // Then set relay pins in output mode
              pinMode(pin, OUTPUT);   
              // Set relay to last known state (using eeprom storage) 
              digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
            }
          
          }
          
          
          void loop()     
          {     
            // Process incoming messages (like config from server)
            gw.process(); 
          
            // Fetch temperatures from Dallas sensors
            sensors.requestTemperatures(); 
          
            // 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>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
           
              // Only send data if temperature has changed more then 1 degC and no error
              if ((lastTemperature[i]) != temperature && temperature != -127.00 && temperature != 85.00) { //added integer
           
                // Send in the new temperature
                gw.send(msg.setSensor(i).set(temperature,1));
                lastTemperature[i]=temperature;
              }
            delay(1000);
            }
            //gw.sleep(SLEEP_TIME); //no sleep for relays!!!!
          }
          
          void incomingMessage(const MyMessage &message) {
            // We only expect one type of message from controller. But we better check anyway.
            if (message.type==V_LIGHT) {
               // Change relay state
               digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
               // Store state in eeprom
               gw.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());
             } 
          }
      

      Readings on node serial port:

      repeater started, id 41
      send: 41-41-33-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
      send: 41-41-33-0 s=255,c=3,t=6,pt=1,l=1,st=ok:33
      read: 0-33-41 s=255,c=3,t=6,pt=0,l=1:M
      send: 41-41-33-0 s=255,c=3,t=11,pt=0,l=15,st=ok:Temp and Relays
      send: 41-41-33-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
      send: 41-41-33-0 s=0,c=0,t=0,pt=0,l=5,st=ok:1.4.1
      send: 41-41-33-0 s=1,c=0,t=0,pt=0,l=5,st=ok:1.4.1
      send: 41-41-33-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
      send: 41-41-33-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.0
      read: 0-33-41 s=2,c=1,t=2,pt=0,l=1:1
      Incoming change for sensor:2, New status: 1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.6
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:31.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:31.0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.8
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.9
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.8
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.6
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.2
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:29.2
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.7
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.3
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.5
      read: 0-33-41 s=2,c=1,t=2,pt=0,l=1:0
      Incoming change for sensor:2, New status: 0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.0
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:26.0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.3
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.4
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:26.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.5
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.6
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.7
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:26.8
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:26.9
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.0
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.3
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.4
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.6
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.7
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.8
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:27.9
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.0
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.3
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.6
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:28.7
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.8
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:28.9
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:28.9
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.0
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:29.0
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.2
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:29.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.3
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.4
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:29.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.5
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.6
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.7
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.8
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:29.9
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.0
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.1
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.1
      send: 41-41-33-0 s=1,c=1,t=0,pt=7,l=5,st=ok:24.2
      send: 41-41-33-0 s=0,c=1,t=0,pt=7,l=5,st=ok:30.3
      read: 0-33-41 s=2,c=1,t=2,pt=0,l=1:1
      Incoming change for sensor:2, New status: 1
      

      As you can see, every once in a while S=1 reports the same value as S=0. I've tried to add a delay in the loop section, but without any luck. So now I'm stuck 😞

      posted in Troubleshooting
      Hausner
      Hausner
    • RE: Motion (PIR), actuator and Temp sensor

      Ok, finally got it to work with this:

      // Example sketch showing how to control physical relays. 
      // This example will remember relay state even after power failure.
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      OneWire oneWire(ONE_WIRE_BUS);
      DallasTemperature sensors(&oneWire);
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      //boolean receivedConfig = false;
      boolean metric = true;
      #define RELAY_1 5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_2 6
      #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
      
      // Motion sensor defs
      unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 4   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 3   // Id of the sensor child
      
      boolean lastTrippedState;
      
      MySensor gw;
      //
      MyMessage msgTemp(0, V_TEMP);
      MyMessage msgRelay2(2, V_LIGHT);
      MyMessage msgMotion(3, V_TRIPPED);
      
      void setup()  
      {   
        gw.begin(incomingMessage, AUTO, true);
        gw.sendSketchInfo("Temp/Relay/Motion Sensor", "1.0");
        //
        gw.present(1, S_LIGHT);
        pinMode(RELAY_1, OUTPUT);
        //
        gw.present(2, S_LIGHT);
        pinMode(RELAY_2, OUTPUT);
        digitalWrite(RELAY_1, gw.loadState(1)? RELAY_ON : RELAY_OFF);
        digitalWrite(RELAY_2, gw.loadState(1)? RELAY_ON : RELAY_OFF);
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        //
        gw.present(CHILD_ID, S_MOTION);
        
        // 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++) {   
           gw.present(0, S_TEMP);
        //}
      }
      //
      void loop() 
      {
        gw.process();
        boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
        if (tripped != lastTrippedState)
        {  
          Serial.println(tripped? "tripped" : "not tripped");
          gw.send(msgMotion.set(tripped?"1":"0"));  // Send tripped value to gw//
          //digitalWrite(RELAY_1, tripped? 1 : 0);
        }
        lastTrippedState = tripped;
        
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures(); 
      
        // 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>((gw.getConfig().isMetric?sensors.getTempCByIndex(0):sensors.getTempFByIndex(0)) * 10.)) / 10.;
      
          // Only send data if temperature has changed more then 1 degC and no error
          if (int(lastTemperature[0]) != int(temperature) && temperature != -127.00) { //added integer
      
            // Send in the new temperature
            gw.send(msgTemp.setSensor(0).set(temperature,1));
            lastTemperature[0]=temperature;
          }
         //}
      }
      
      void incomingMessage(const MyMessage &message) {
        // 
        if (message.type==V_LIGHT && message.sensor == 2) 
        {
          // Change relay state
          digitalWrite(RELAY_2, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          gw.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());
        }
      }
      
      posted in Hardware
      Hausner
      Hausner
    • RE: Sensebender Micro

      Would this work with a 3,7V Li-Ion 18650 cell? Because I've got a S... load from old laptops

      posted in Announcements
      Hausner
      Hausner
    • RE: Motion (PIR), actuator and Temp sensor

      @hek said:

      If you want to sleep the node, then using pin-interrrupt is a great way of waking the node when motion is detected.

      You can use use the radio-irq pin for you sensors. It is currently not used by the mysensors library.

      So, not need to wire the radio IRQ PIN at all?

      posted in Hardware
      Hausner
      Hausner
    • RE: Motion (PIR), actuator and Temp sensor

      Ok, so basicly you are saying, that the PIR DOESN'T require an irq pin on the arduino?

      posted in Hardware
      Hausner
      Hausner
    • Motion (PIR), actuator and Temp sensor

      Hi,

      I'm trying to make and sensor, as subject says. I've got temp (DS18B20) and actuator working, but not the PIR (HC-SR501).

      PINs as follow:
      RADIO IRQ = PIN2
      Temp = PIN3
      PIR data = PIN4
      Actuator = PIN 5,6

      My question is now, does a PIR require an Interrupt PIN on the arduino (PIN 2,3) , or can I use any PIN?

      posted in Hardware
      Hausner
      Hausner
    • RE: Monitor a DIY solarpanel with ASC712 - HELP

      No, serial monitor was just for testing. I would like to push it to mqtt.

      I found the V_VOLTAGE and V_CURRENT, and the serial monotir showed up correctly as 38/39.

      posted in Troubleshooting
      Hausner
      Hausner
    • Monitor a DIY solarpanel with ASC712 - HELP

      Has anyone gotten a ASC712 to work with a actuator node?

      I'm trying to monitor my diy solar panel, so that I can see what it is producing(if).

      I've tried with the code below, but I can't get the node to send the readings to the gateway. I'm using a 30A ASC712 to do the readings. (Don't mind the motion sensor part).

      My last code:

      // Example sketch showing how to control physical relays. 
      // This example will remember relay state even after power failure.
      
      #include <MySensor.h>
      #include <SPI.h>
      const int analogIn = A0;
      int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module
      int RawValue= 0;
      int ACSoffset = 2500; 
      double Voltage = 0;
      double Amps = 0;
      double Voltage_new = 0;
      double Amps_new = 0;
      
      #define RELAY_1 6  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 2 // Total number of attached relays
      #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
      
      // Motion sensor defs
      unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motionsensor.  (Only 2 and 3 generates interrupt!)
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 3   // Id of the sensor child
      volatile int state = LOW;
      boolean lockLow = true;
      boolean lastTripped = 0;
      
      MySensor gw;
      MyMessage msgMotion(CHILD_ID, V_TRIPPED);
      MyMessage msgvolt(4, V_VOLTAGE);
      MyMessage msgcur(5, V_CURRENT);
      MyMessage msg(CHILD_ID, V_LIGHT);
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay/Motion Sensor", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
        
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as  input
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID, S_MOTION);
        // attachInterrupt(DIGITAL_INPUT_SENSOR, ON, CHANGE);
        //delay(30000);
        gw.present(4, V_VOLTAGE);
        gw.present(5, V_CURRENT);
      }
      
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      
        //boolean tripped = (digitalRead(DIGITAL_INPUT_SENSOR) == HIGH);
        //  if (lastTripped != tripped ) {
      //	gw.send(msgMotion.set(tripped?"1":"0")); // Send new state
      //	lastTripped=tripped;
      //   }
        
        //Serial.print("Raw Value = " ); // shows pre-scaled value 
        //Serial.print(RawValue);
        //gw.send(msgvolt);
        //Serial.print("\t mV = "); // shows the voltage measured 
        //Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
        //Serial.print("\t Amps = "); // shows the voltage measured
        for ( int i=0; i<=20; i++ ){
          RawValue += analogRead(analogIn);
          delay(50);
        }
        Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
        Amps = ((Voltage - ACSoffset) / mVperAmp);
        
        //gw.send(msgcur);
        Serial.print("mV = "); // shows the voltage measured
        Serial.println(Voltage);
        //Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after             decimal point
        //delay(2500);
      }
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
       if (message.type==V_LIGHT) {
       // Change relay state
       digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
       // Store state in eeprom
       gw.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());
       }
      }
      

      Any help would be appreciated 🙂

      PS: Att HEK - why isn't there a "insert code" button, just like the "insert link" button?

      posted in Troubleshooting
      Hausner
      Hausner
    • RE: Motion/actuator sensor

      Turned out that the Nano was faulty.

      I rebuilded the setup with a new Nano, and it's now working as designed 🙂

      posted in Troubleshooting
      Hausner
      Hausner