Navigation

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

    Topics created by BastienVH

    • BastienVH

      Error using Home Assistant with a serial gateway
      Home Assistant • • BastienVH  

      21
      0
      Votes
      21
      Posts
      8963
      Views

      BastienVH

      @martinhjelmare Thanks for the heads up! After following the steps there, I get my node up and running. Thanks for the help!
    • BastienVH

      Can't get motion interrupt to work in my (combined temp, battery and motion) sketch
      Troubleshooting • • BastienVH  

      10
      0
      Votes
      10
      Posts
      3039
      Views

      BastienVH

      @martinhjelmare Great, thanks. The sketch now works as it should. Below is the finished sketch. I also added a counter so that after 10 consecutive interrupts from the motion sensor, the temp and hum get read and transmited. (motion-on generates an interrupt and motion-off generates an interrupt, so it's actually 5 motion triggers) Otherwise if there is a lot of movement during a certain timeframe (mornings), hum and temp won't be measured. Later I will edit the sketch to have all transmits together to save more battery power. Here's the sketch: /** * 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 * This sketch provides an example how to implement a humidity/temperature * sensor using DHT11/DHT-22 * http://www.mysensors.org/build/humidity */ #include <SPI.h> #include <MySensor.h> #include <DHT.h> #define DIGITAL_INPUT_MOTION 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_MOTION-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_MOT 2 #define HUMIDITY_SENSOR_DIGITAL_PIN 4 unsigned long SLEEP_TIME = 150000; // Sleep time between reads (in milliseconds) MySensor gw; DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED); int node_id = 20; boolean lastTripped = false ; int wake = 0; int motionCount = 0; void setup() { gw.begin(); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo("Humidity and motion", "1.1"); pinMode(DIGITAL_INPUT_MOTION, 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_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); gw.present(CHILD_ID_MOT, S_MOTION); metric = gw.getConfig().isMetric; } void loop() { Serial.println(wake); if (wake == 1 && motionCount <= 10) { Serial.println("wake by motion"); Serial.println("reading motion"); motion(); motionCount = motionCount + 1; Serial.println(motionCount); } else { Serial.println("wake by timer"); Serial.println("reading motion"); motion(); Serial.println("reading temp/hum"); humTemp(); motionCount = 0; Serial.println("motionCount is reset"); } Serial.println("going to sleep now."); wake = gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); } void motion() { // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_MOTION); Serial.println(tripped); if (lastTripped != tripped) { gw.send(msgMot.set(tripped ? "1" : "0")); // Send tripped value to gw lastTripped = tripped; } } void humTemp() { gw.wait(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } }
    • BastienVH

      Soldering iron / station requirements
      General Discussion • • BastienVH  

      6
      0
      Votes
      6
      Posts
      2369
      Views

      Anticimex

      @BastienVH I use 0.8mm wire. I have found it suits me for all-around soldering of both through-hole and SMD. For tip I would recommend a chisel tipped one. That provides the best heating and you can turn it depending on the area you solder in. Very rarely I change tip to a pointy one, but for sure, it is good to have the option to switch tips. They eventually wear out. Of course, it is a matter of personal taste as well