Navigation

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

    Posts made by BastienVH

    • RE: Easy/Newbie PCB for MySensors

      @sundberg84
      About D2: you mean I shouldn't solder the IRQ of the radio to the board?
      I will try that next time.

      I've been testing the PIR with a nano and the 3.3V it supplies and that works fine.
      If I take VCC or ground (or both) from the board with booster, the PIR starts acting up.
      I guess I'll have to try some more if I want to get to the bottom of things.

      posted in Hardware
      BastienVH
      BastienVH
    • RE: Easy/Newbie PCB for MySensors

      @sundberg84
      Hey, I've been having a bit of trouble lately.
      I've been trying to setup a node with your board which supports a PIR and a temp sensor (ds18b20).
      Since there is a spot for a resistor on D3 on your board, I attached the temp sensor to that pin.
      The PIR needs a pin that supports interrupts, so I connected that to D2.
      Here is where the confusion starts.
      If I read this page correctly, D2 is already in use for the radio.
      I only checked it after I soldered everything together and found out my PIR doesn't work (it always sends a 1-signal).

      Any thoughts on this?
      Is D2 really free for use on the board?

      Thanks!

      posted in Hardware
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @sundberg84 said:

      If you use the FTDI connector, make sure its the 3.3v and connect it to Gnd/Pwr on the PCB and not Arduino FDTI connector.
      You could just exclude those pins and connect a battery directly and use that as power and the FDTI as programmer/serial debug only

      Bat or Reg is nessecary!
      See this picture for battery use: https://www.openhardware.io/view/4/EasyNewbie-PCB-for-MySensors
      https://www.openhardware.io/uploads/568ed84b60aa3f8965fbf095/image/3.jpg
      All components in the image is needed (except battery measurment).
      If you dont want to use booster you need to bypass that one with a wire/jumper (or set the jumper on REG instead of BAT but that kills the logic).

      The battery doesnt "need" the 0,1uF but see here:https://www.mysensors.org/build/battery
      "The tap point could be bypassed with a 0.1 uF capacitor to keep the noise level low, at this otherwise high impedance point. "

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: openHAB binding

      After reinstalling OpenHAB, the binding works fine, thank you!
      Just a question, don't know if you can help.

      I mapped my serial gateway to /dev/MSgw because ttyUSBx tends to change when unplugging / replugging multiple USB devices into the computer (raspberry pi in my case).
      I've also got a 433MHz gateway attached and when debugging have to unplug it sometimes.
      When trying to start OpenHAB with /dev/MSgw as gateway address I get this:

      2016-02-14 10:58:33.418 [DEBUG] [.b.m.internal.MySensorsBinding] - activate
      RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyUSB1
      2016-02-14 10:58:34.048 [ERROR] [.o.b.m.internal.gateway.Serial] - Unable to find Serial port '/dev/MSgw'
      

      Do you know how/if I can still you my own custom paths to the gateway?
      Now I changed it to ttyUSB1, but that port might change after rebooting.

      posted in OpenHAB
      BastienVH
      BastienVH
    • RE: openHAB binding

      @bkl
      Thanks for your response.
      After adding the line of code to the logback, my debug output remains the same.
      No message that new items have been added based on the configuration, nor parse-errors.

      It's just the same as before: the messages are received, but not interpreted correctly, just the raw data like below:
      2016-02-13 15:05:55.551 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=0, message-type=set, ack=false, sub-type=V_HUM, payload=48.0

      I will start over again from scratch tomorrow, reinstall openhab and your binding to see if it helped.

      posted in OpenHAB
      BastienVH
      BastienVH
    • RE: openHAB binding

      Hi,

      I've tried out you binding on OpenHAB 1.8.1.
      It appears OpenHAB can connect to my serial gateway and receives the messages from my node, but doesn't know what to do with it.

      This is en excerpt of my log:

      2016-02-13 15:05:52.548 [INFO ] [.b.m.internal.MySensorsBinding] - New MySensor node found: node-id=20
       * Example item: 20;255;I_BATTERY_LEVEL      - Use this to report the battery level 0-100 (%)
       * Example item: 20;255;I_SKETCH_NAME        - Sketch name that can be used to identify sensor
       * Example item: 20;255;I_SKETCH_VERSION     - Sketch version that can be reported to keep track of the version of sensor
      2016-02-13 15:05:54.479 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=255, message-type=internal, ack=false, sub-type=I_SKETCH_NAME, payload=Temp/Hum/Motion
      2016-02-13 15:05:54.486 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=255, message-type=internal, ack=false, sub-type=I_SKETCH_VERSION, payload=1.0
      2016-02-13 15:05:54.498 [INFO ] [.b.m.internal.MySensorsBinding] - New MySensor sensor found (Humidity sensor): node-id=20, sensor-id=0 with type S_HUM
       * Example item: 20;0;V_HUM                - Humidity
      2016-02-13 15:05:54.521 [INFO ] [.b.m.internal.MySensorsBinding] - New MySensor sensor found (Temperature sensor): node-id=20, sensor-id=1 with type S_TEMP
       * Example item: 20;1;V_TEMP               - Temperature
       * Example item: 20;1;V_ID                 - Optional unique sensor id (e.g. OneWire DS1820b ids)
      2016-02-13 15:05:54.545 [INFO ] [.b.m.internal.MySensorsBinding] - New MySensor sensor found (Motion sensor): node-id=20, sensor-id=2 with type S_MOTION
       * Example item: 20;2;V_TRIPPED            - Tripped status of a security sensor. (Tripped/Untripped)
       * Example item: 20;2;V_ARMED              - Armed status of a security sensor. (Armed/Bypassed)
      2016-02-13 15:05:54.567 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=2, message-type=set, ack=false, sub-type=V_TRIPPED, payload=1
      2016-02-13 15:05:55.537 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=1, message-type=set, ack=false, sub-type=V_TEMP, payload=19.0
      2016-02-13 15:05:55.551 [INFO ] [.b.m.internal.MySensorsBinding] - Unknown: MySensors message: node-id=20, child-sensor-id=0, message-type=set, ack=false, sub-type=V_HUM, payload=48.0
      

      All the sensors get declared and recognized as their type, but the messages are not being interpreted correctly.

      This is my .items-file:

      Number Humidity "Livingsensor [%s %%Rh]" <water> (GF_Living) {mysensors="20;0;V_HUM"}
      Number Temperature "Livingsensor [%s ยฐC]" <temperature> (GF_Living) {mysensors="20;1;V_TEMP"}
      Switch Motion "Livingsensor [%s]" <motion> (GF_Living) {mysensors="20;2;V_TRIPPED"}
      

      And the sitemap (which of course doesn't update anything yet):

      sitemap default label="Main Menu"
      {
      	Frame label="Systeem"{
      	Group item=System	label="Systeeminfo"	icon="computer" {
      				Text	item=uptime	icon="computer"
      				Text	item=Raspi_CPU	icon="computer"
      				Switch	item=wakingup
      	}
      	}
      	Frame label="MySensors" {
      	Switch item=Motion
      	Text item=Humidity
      	Text item=Temperature
      }
      }
      

      It's been a while since I used OpenHAB and went looking for something more lightweight that had better integration for MySensors, but with your binding, I could revert to include everything I've built for OpenHAB in the past.

      Thanks for your initial work and I hope you can help me out.

      posted in OpenHAB
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @sundberg84
      When I get the caps, I'll place them on the board.
      I did notice alot of noise when I was reading battery state on a breadboard in an earlier build, so I will get that sorted.
      Only problem is I can't find them locally, so have to get them from China.
      Will take a while...

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @BastienVH
      Replying to myself to follow up on my assembly-issues.
      I have been able to get the board to work.
      I don't have my 0.1ยตF caps yet, so I just put a little blob of solder in the holes so the current could run through.
      Now I've got myself 2 working board. I just have to find a good way to attach my PIR, dallas temp, ... to them.

      Thanks for the work and help!

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: Buttons that send different signals to the same sensor

      @mwild95
      Could you share your sketch?
      I'm planning to mysensor-ize my 433 wall plugs and it might be a good starting point ๐Ÿ™‚

      posted in MyController.org
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @sundberg84
      Thanks for the explanation!
      I think I've got it now.
      Will test and get back with the results when I've gotten my hands on some more solder wire!

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      I have a 3.3v arduino.
      At the moment it's powered the FTDI232 connected to my computer.
      I will transfer to battery once I'm done.
      Do you mean the "BAT" / "REG"?
      I haven't soldered that. I'm guessing that's necessary?

      Also, while I have you hear ๐Ÿ˜‰ , if I want to use the battery measuring, do I have to add the 0.1uF capacitor?
      What advantage does it provide?

      Thanks for your help!

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @sundberg84
      Hey, I've been trying to get my boards to work, but without succes so far.
      They are revision 7 and have mounted 2 boards with a pro mini and the radio but they're not working.
      For the second one I actually checked both the arduino and radio beforehand to see if they functional, which they were.
      Now with them mounted, I still get the "radio init fail" message in the arduino serial monitor.
      The first board, I mounted with the cap, the second one not yet (I ran out of solder wire).

      Any ideas how to troubleshoot this?
      Should I upload some pictures so you can check the solderjob?

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

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

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Can't get motion interrupt to work in my (combined temp, battery and motion) sketch

      @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);
        }
      }
      
      posted in Troubleshooting
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      @dels said:

      You have to reboot your individual sensors so HA can see their Presentation message. Your output seems to be good for the gateway itself, but the gateway is not an actual "item" in HA, when it detects the sensors though, you should see their status.

      It seems I did in fact forget to reboot my node when trying to include it in HA. (long day messing around with code...)
      Here is a console log from today in which I start up HA and reboot my node.
      HA receives the messages, but the node never shows up in the web interface:

      pi@raspberrypi ~ $ hass
      Config directory: /home/pi/.homeassistant
      WARNING:homeassistant.bootstrap:Colorlog package not found, console coloring disabled
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on>
      INFO:homeassistant.bootstrap:Home Assistant core initialized
      INFO:homeassistant.loader:Loaded discovery from homeassistant.components.discovery
      INFO:homeassistant.loader:Loaded introduction from homeassistant.components.introduction
      INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
      INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
      INFO:homeassistant.loader:Loaded http from homeassistant.components.http
      INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
      INFO:homeassistant.loader:Loaded sun from homeassistant.components.sun
      INFO:homeassistant.loader:Loaded mysensors from homeassistant.components.mysensors
      INFO:homeassistant.loader:Loaded history from homeassistant.components.history
      INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
      INFO:homeassistant.loader:Loaded api from homeassistant.components.api
      INFO:homeassistant.loader:Loaded updater from homeassistant.components.updater
      INFO:homeassistant.components.introduction:
      
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
              Hello, and welcome to Home Assistant!
      
              We'll hope that we can make all your dreams come true.
      
              Here are some resources to get started:
      
               - Configuring Home Assistant:
                 https://home-assistant.io/getting-started/configuration/
      
               - Available components:
                 https://home-assistant.io/components/
      
               - Troubleshooting your configuration:
                 https://home-assistant.io/getting-started/troubleshooting-configuration/
      
               - Getting help:
                 https://home-assistant.io/help/
      
              This message is generated by the introduction component. You can
              disable it in configuration.yaml.
      
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=introduction>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=discovery>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=http>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
      /home/pi/.homeassistant/lib/fuzzywuzzy/fuzz.py:33: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
        warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=conversation, service=process>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): maps.googleapis.com
      INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=07:28:30 26-01-2016, friendly_name=Sun, next_setting=16:19:22 25-01-2016, elevation=1.59 @ 08:45:51 25-01-2016>>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sun>
      INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sensor>
      INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: service=mysensors.sensors, discovered=>
      INFO:homeassistant.loader:Loaded sensor.mysensors from homeassistant.components.sensor.mysensors
      INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_off>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_on>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=switch>
      INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: service=mysensors.switches, discovered=>
      INFO:homeassistant.loader:Loaded switch.mysensors from homeassistant.components.switch.mysensors
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=mysensors>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.python.org
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=updater>
      INFO:homeassistant.core:Starting Home Assistant (16 threads)
      INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
      INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
      INFO:mysensors.mysensors:Trying to connect to /dev/MSgw
      INFO:homeassistant.core:Timer:starting
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:netdisco.service:Scanning
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:mysensors.mysensors:/dev/MSgw is open...
      INFO:mysensors.mysensors:Connected to /dev/MSgw
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.1
      INFO:homeassistant.components.discovery:Found new service: DLNA http://192.168.1.70:1972/DeviceDescription.xml
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.3
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:homeassistant.components.mysensors:No sketch_name: node 20
      INFO:homeassistant.components.mysensors:No sketch_name: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=3,t=11,pt=0,l=19,sg=0:Humidity and mo
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.1
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=0,t=7,pt=0,l=0,sg=0:
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=1,c=0,t=6,pt=0,l=0,sg=0:
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=2,c=0,t=1,pt=0,l=0,sg=0:
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:homeassistant.components.http:"GET /states HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/frontend-1003c31441ec44b3db84b49980f736a7.html HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/favicon-192x192.png HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/favicon.ico HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/logbook/2016-1-25 HTTP/1.1" 200 -
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=1,c=1,t=0,pt=7,l=5,sg=0:22.0
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:51.0
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=2,c=1,t=16,pt=0,l=1,sg=0:1
      INFO:homeassistant.components.mysensors:update sensor_update: node 20
      INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=07:28:30 26-01-2016, friendly_name=Sun, next_setting=16:19:22 25-01-2016, elevation=1.67 @ 08:45:51 25-01-2016>, old_state=<state sun.sun=above_horizon; next_rising=07:28:30 26-01-2016, friendly_name=Sun, next_setting=16:19:22 25-01-2016, elevation=1.59 @ 08:45:51 25-01-2016>>
      ^CINFO:homeassistant.core:Stopping
      INFO:homeassistant.core:Bus:Handling <Event homeassistant_stop[L]>
      INFO:mysensors.mysensors:Disconnecting from /dev/MSgw
      INFO:mysensors.mysensors:Stopping thread
      INFO:homeassistant.components.recorder:Closing database
      

      This is the line when I start my node:
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0

      Your thoughts?

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Can't get motion interrupt to work in my (combined temp, battery and motion) sketch

      @martinhjelmare
      Ok, I didn't know that declaring the int wake as the reply from gw.sleep would actually make the node go to sleep again.
      I've now setup my loop like this and it appears to work:

      void loop()
      {
        int wake = gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME);
        Serial.println(wake);
        if (wake > 0) {
          Serial.println("wake by motion");
          Serial.println("reading motion");
          motion();
        }
        else {
          Serial.println("wake by timer");
          Serial.println("reading motion");
          motion();
          Serial.println("reading temp/hum");
          humTemp();
        }
        Serial.println("going to sleep now.");
      }
      

      Only thing is, I only get my first temp/hum/motion data AFTER the node has been in sleeping for SLEEPTIME.
      Could I put a command to read motion and temp/hum in my setup or is that bad coding ettiquette?

      PS: Thanks martin for being such a helpful member!
      I feel like your everyones personal debugger!

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

      Hi everyone,

      It's been a while but now I've received some more arduinos, I'm back in action with developing my sketches.
      After the last problem (everytime motion is detected, temp also gets updated and sent), I've been tinkering with my sketch and if-statements.

      At the moment, I've got this (migrated from dallas to DHT for testing purposes):

      /**
      #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 = 15000; // Sleep time between reads (in milliseconds) - low for testing purposes
      
      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 ;
      
      void setup()
      {
        gw.begin(NULL, node_id);
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
      
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("Humidity and motion", "1.0");
      
        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()
      {
      // OPTION 1: work with if statement
         int wake;
        wake = gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME);
      
         if (wake > 0) {
           Serial.println("wake by motion");
           Serial.println("reading motion");
           motion();
         }
      
         else {
           Serial.println("wake by timer");
           Serial.println("reading motion");
           motion();
           Serial.println("reading temp/hum");
           humTemp();
         }
      
      //OPTION 2: NO IF-STATEMENT (commented out at the moment)
        /*
        motion();
        Serial.println("read temp / hum");
        humTemp();
      */
        Serial.println("going to sleep now.");
        gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); //sleep a bit
      }
      
      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);
        }
      }
      

      Strange things are happening...

      If I use OPTION 2, without if, so temp is always checked, interrupt get triggered instantly as shown here and sends a 'deactivate'-message 0 when the sensors sets back to 0 after +- 8 sec:

      1
      send: 20-20-0-0 s=2,c=1,t=16,pt=0,l=1,sg=0,st=ok:1
      read temp / hum
      going to sleep now.
      0
      send: 20-20-0-0 s=2,c=1,t=16,pt=0,l=1,sg=0,st=ok:0
      read temp / hum
      going to sleep now.
      

      If I use OPTION 1 (preferred because no unnecessary temp measurement), the interrupt seems to only occur when the motion signal goes back to 0 (low), which is late and doesn't provide me with a 1-signal (meaning it will not communicate presence, but only when the built-in timer of =- 8 seconds has passed).

      wake by motion
      reading motion
      0
      going to sleep now.
      

      The use of wake comes from this topic and the API.
      Any suggestions or does someone see what I missed?

      Thanks alot!

      posted in Troubleshooting
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      @martinhjelmare

      Sorry, I was away from the computer for a little while.
      I did reuse an old node id, that could have been the problem.
      Assigned a new node ID and this is where I stand now:

      Firts up: the node 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 = 15000; // 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 ;
      
      void setup()
      {
        gw.begin(NULL, node_id);
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
      
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("Humidity and motion", "1.0");
      
        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()
      {
        /* int wake;
        wake = gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME);
      
         if (wake == 1) {
           Serial.println("wake by motion");
           Serial.println("reading motion");
           motion();
         }
      
         else {
           Serial.println("wake by timer");
           Serial.println("reading motion");
           motion();
           Serial.println("reading temp/hum");
           humTemp();
         }
        */
        motion();
        
        Serial.println("read temp / hum");
        humTemp();
      
        Serial.println("going to sleep now.");
        gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); //sleep a bit
      }
      
      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);
        }
      }
      

      Now, my HA config:

      homeassistant:
        # Name of the location where Home Assistant is running
        name: Home
        # Location required to calculate the time the sun rises and sets
        latitude: xxxxxxxx
        longitude: xxxxxxxxxxxxxx
        # C for Celcius, F for Fahrenheit
        temperature_unit: C
        # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
        time_zone: Europe/Brussels
      
      # View all events in a logbook
      logbook:
      
      # Checks for available updates
      updater:
      
      # Discover some devices automatically
      discovery:
      
      # Track the sun
      sun:
      
      # Allows you to issue voice commands from the frontend
      conversation:
      
      # Enables support for tracking state changes over time.
      history:
      
      # Enables the frontend
      frontend:
      
      # Show links to resources in log and frontend
      introduction:
      
      mysensors:
        gateways:
          - port: '/dev/MSgw'
        debug: true
        persistence: false
      

      and the output when starting hass:

      
      Config directory: /home/pi/.homeassistant
      WARNING:homeassistant.bootstrap:Colorlog package not found, console coloring disabled
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on>
      INFO:homeassistant.bootstrap:Home Assistant core initialized
      INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
      INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
      INFO:homeassistant.loader:Loaded http from homeassistant.components.http
      INFO:homeassistant.loader:Loaded history from homeassistant.components.history
      INFO:homeassistant.loader:Loaded introduction from homeassistant.components.introduction
      INFO:homeassistant.loader:Loaded updater from homeassistant.components.updater
      INFO:homeassistant.loader:Loaded conversation from homeassistant.components.conversation
      INFO:homeassistant.loader:Loaded discovery from homeassistant.components.discovery
      INFO:homeassistant.loader:Loaded mysensors from homeassistant.components.mysensors
      INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
      INFO:homeassistant.loader:Loaded api from homeassistant.components.api
      INFO:homeassistant.loader:Loaded sun from homeassistant.components.sun
      INFO:homeassistant.components.introduction:
      
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
              Hello, and welcome to Home Assistant!
      
              We'll hope that we can make all your dreams come true.
      
              Here are some resources to get started:
      
               - Configuring Home Assistant:
                 https://home-assistant.io/getting-started/configuration/
      
               - Available components:
                 https://home-assistant.io/components/
      
               - Troubleshooting your configuration:
                 https://home-assistant.io/getting-started/troubleshooting-configuration/
      
               - Getting help:
                 https://home-assistant.io/help/
      
              This message is generated by the introduction component. You can
              disable it in configuration.yaml.
      
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=introduction>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=recorder>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=http>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=logbook>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=history>
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.python.org
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=updater>
      /home/pi/.homeassistant/lib/fuzzywuzzy/fuzz.py:33: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
        warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=conversation, service=process>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=conversation>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=discovery>
      INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sensor>
      INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: discovered=, service=mysensors.sensors>
      INFO:homeassistant.loader:Loaded sensor.mysensors from homeassistant.components.sensor.mysensors
      INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_off>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=switch, service=turn_on>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=switch>
      INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: discovered=, service=mysensors.switches>
      INFO:homeassistant.loader:Loaded switch.mysensors from homeassistant.components.switch.mysensors
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=mysensors>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=api>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=frontend>
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): maps.googleapis.com
      INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sun.sun=below_horizon; next_setting=16:19:22 25-01-2016, friendly_name=Sun, next_rising=07:29:47 25-01-2016, elevation=-33.1 @ 20:51:46 24-01-2016>, entity_id=sun.sun>
      INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=sun>
      INFO:homeassistant.core:Starting Home Assistant (16 threads)
      INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
      INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
      INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
      INFO:homeassistant.core:Timer:starting
      INFO:mysensors.mysensors:Trying to connect to /dev/MSgw
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:netdisco.service:Scanning
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:mysensors.mysensors:/dev/MSgw is open...
      INFO:mysensors.mysensors:Connected to /dev/MSgw
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:54.0
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.1
      INFO:homeassistant.components.discovery:Found new service: DLNA http://192.168.1.70:1972/DeviceDescription.xml
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:53.0
      INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sun.sun=below_horizon; next_setting=16:19:22 25-01-2016, friendly_name=Sun, next_rising=07:29:47 25-01-2016, elevation=-33.21 @ 20:51:46 24-01-2016>, entity_id=sun.sun, old_state=<state sun.sun=below_horizon; next_setting=16:19:22 25-01-2016, friendly_name=Sun, next_rising=07:29:47 25-01-2016, elevation=-33.1 @ 20:51:46 24-01-2016>>
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:54.0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:53.0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:54.0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:53.0
      INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state sun.sun=below_horizon; next_setting=16:19:22 25-01-2016, friendly_name=Sun, next_rising=07:29:47 25-01-2016, elevation=-33.36 @ 20:51:46 24-01-2016>, entity_id=sun.sun, old_state=<state sun.sun=below_horizon; next_setting=16:19:22 25-01-2016, friendly_name=Sun, next_rising=07:29:47 25-01-2016, elevation=-33.21 @ 20:51:46 24-01-2016>>
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 20-20-0 s=0,c=1,t=1,pt=7,l=5,sg=0:54.0
      INFO:homeassistant.components.http:"GET /states HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/frontend-1003c31441ec44b3db84b49980f736a7.html HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/favicon-192x192.png HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /static/favicon.ico HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/bootstrap HTTP/1.1" 200 -
      INFO:homeassistant.components.http:"GET /api/stream?api_password=no_password_set&restrict=state_changed,component_loaded,service_registered HTTP/1.1" 200 -
      

      I don't get errors anymore, but nothing shows up in the web interface.
      I think the messages aren't being interpreted?

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      @martinhjelmare
      Yeah, I was also trying to get my motion sketch working, so that log message may have been something left over from that.

      This is everything in my terminal

      INFO:mysensors.mysensors:/dev/MSgw is open...
      INFO:mysensors.mysensors:Connected to /dev/MSgw
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.1
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.70
      INFO:homeassistant.components.discovery:Found new service: DLNA http://192.168.1.70:1972/DeviceDescription.xml
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 10-10-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 10-10-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.3
      INFO:homeassistant.components.mysensors:update sensor_update: node 10
      INFO:homeassistant.components.sensor.mysensors:Motion Sensor 10.1: value_type 16, value = 0
      Exception in thread Thread-6:
      Traceback (most recent call last):
        File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
          self.run()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 312, in run
          response = self.handle_queue()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 222, in handle_queue
          reply = func(*args, **kwargs)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 108, in logic
          self._handle_presentation(msg)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 51, in _handle_presentation
          self.alert(msg.node_id)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 175, in alert
          self.event_callback("sensor_update", nid)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/mysensors.py", line 226, in node_update
          callback(self, node_id)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/mysensors.py", line 149, in mysensors_callback
          entity.update_ha_state(True)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity.py", line 108, in update_ha_state
          self.unit_of_measurement is not None:
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/sensor/mysensors.py", line 137, in unit_of_measurement
          self.value_type == self.gateway.const.SetReq.V_PERCENTAGE or \
        File "/usr/lib/python3.4/enum.py", line 255, in __getattr__
          raise AttributeError(name) from None
      AttributeError: V_PERCENTAGE
      

      I hope you can find something there...

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      @martinhjelmare
      I never got the "n:0 c:0 ...." message, only "Connected to /dev/MSgw".
      I found out there was an instance of FHEM running and occuping the GW.
      I stopped that and now it does give the "gateway started" message.

      Now the error occurs indeed before the gateway started message.

      Now I get the following after trying to let a node with DHT send its data to the gateway:

      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 10-10-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
      INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 10-10-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.3
      INFO:homeassistant.components.mysensors:update sensor_update: node 10
      INFO:homeassistant.components.sensor.mysensors:Motion Sensor 10.1: value_type 16, value = 0
      Exception in thread Thread-15:
      Traceback (most recent call last):
        File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
          self.run()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 312, in run
          response = self.handle_queue()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 222, in handle_queue
          reply = func(*args, **kwargs)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 108, in logic
          self._handle_presentation(msg)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 51, in _handle_presentation
          self.alert(msg.node_id)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 175, in alert
          self.event_callback("sensor_update", nid)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/mysensors.py", line 226, in node_update
          callback(self, node_id)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/mysensors.py", line 149, in mysensors_callback
          entity.update_ha_state(True)
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity.py", line 108, in update_ha_state
          self.unit_of_measurement is not None:
        File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/sensor/mysensors.py", line 137, in unit_of_measurement
          self.value_type == self.gateway.const.SetReq.V_PERCENTAGE or \
        File "/usr/lib/python3.4/enum.py", line 255, in __getattr__
          raise AttributeError(name) from None
      AttributeError: V_PERCENTAGE
      

      Is there a list with which kinds of sensors are supported in HA?
      Is motion/pir supported?

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      @martinhjelmare
      I was running pyserial 2.6, but have now installed version 2.5.
      I get the error, the moment I restart a sensor to have it included in HA.
      When I press the reset button on my sensor, the error shows up almost instantly in the terminal.
      So I guess that means that HA can connect to the serial gateway and receive messages, but just doesn't deal with it properly...

      Also: I had some trouble uninstalling the pyserial version and after some messing around, I now get this in my 'pip freeze'

      pyserial-py3k==2.5
      

      No mention of a 'normal' pyserial.

      Thanks for the help you've already provided!

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Error using Home Assistant with a serial gateway

      Hi Martin,

      @martinhjelmare
      I've been trying the last couple of days to get it working, but to no avail...

      I stell get errors like

      ValueError: need more than 1 value to unpack
      

      The number can change though.
      I've tried your suggestions, updated and rebooted the pi but still no luck.
      Uninstalled and reinstalled home assistant but that also didn't help.

      Any other things I could try?

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      I would share the link to my upload, but I don't want to get in the way of sundberg.
      I think it's better for sundberg to share his link in the top post and donate whatever he makes to the mysensors project (like he said).
      If you can't wait, I'll PM you the link and donate the $1 to mysensors, but it feels wrond to take money (even if I'm giving it away straight afterwards) for something I didn't create myself...

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      I just received my order from Dirtypcbs. The protopack I ordered had 11 boards, so that's nice.
      They took 10 days to arrive in Belgium.
      From first glance, it looks like they's work, but I'll have to test it this weekend to be sure.
      Here's a picture.
      0_1453379527295_DSC06500.jpg

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • Error using Home Assistant with a serial gateway

      Hi,

      I've been taking a look at Home Assistant lately, but encountered some problems setting it up.
      The first time I installed HA (0.10), I could connect my serial gateway and my temp sensor was recognized and added to the display on top of the web page.
      My install seems to have been corrupted though.
      When I wanted to test it out some more this week (with versions 0.10, 0.11.0 and 0.11.1) I can't get mysensors to work.

      HA can connect to the gateway, as seen here:

      INFO:mysensors.mysensors:/dev/ttyUSB2 is open...
      INFO:mysensors.mysensors:Connected to /dev/ttyUSB2
      

      But a little further on, I receive this error in the console:

      Exception in thread Thread-7:
      Traceback (most recent call last):
        File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
          self.run()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 312, in run
          response = self.handle_queue()
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 222, in handle_queue
          reply = func(*args, **kwargs)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 105, in logic
          msg = Message(data)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 397, in __init__
          self.decode(data)
        File "/home/pi/.homeassistant/lib/mysensors/mysensors.py", line 417, in decode
          self.sub_type) = [int(f) for f in data]
      ValueError: need more than 0 values to unpack
      

      Has anyone else encountered this or have any idea how to solve this issue?

      Thanks in advance!

      posted in Home Assistant
      BastienVH
      BastienVH
    • RE: Another beginner project

      @Astrofotograf
      Pilight can use 433MHz senders and receivers connected to the GPIO-pins of the Raspberry Pi.
      Problem with that is that the pi will need to filter all of the frequency noise which leads to higher cpu-usage and slower processing of other tasks (OpenHAB is quite resource-heavy in my opinion - on a RPi B+).
      That's why they also have pilight-usb-nano which is a sketch/hex-file to upload to an arduino nano. This way the nano will filter out the noise and only feed recognizable commands to pilight, which in its way sends the commands to OpenHAB.
      In that regard it acts as a gateway for your controller.

      posted in My Project
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      @GertSanders
      I'll check when they arrive.
      The red is really nice but was actually a mistake, I didn't check the board color setting because I was so excited to order this PCB! ๐Ÿ˜‰
      You get a choice of red, yellow, green, blue, black or white. All without extra cost, which is nice.

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: Another beginner project

      When I used OpenHAB as a controller , I used the pilight plugin.
      If you setup a pilight-instance, you can connect it to OpenHAB and let that read out states and send commands.
      I didn't look dor a way to directly control an arduino from OpenHAB, seeing as pilight worked fine.

      EDIT: just to clarify: pilight has an arduino sketch you can upload to a nano (which is what I used) to act as a gateway.
      You won't need the expensive RFXCom.

      posted in My Project
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      I checked their website again and you should be able to upload de gerber files in a zip-file.
      I uploaded a rar, which was not recognized, I guess.
      After that, I uploaded the board-file and it generated gerberfiles based on that brd-file.
      This is a screenshot of the board generated by dirtypcbs on my order page.
      We'll have to wait and see how they turn out.

      dirtypcbscreenshot.jpg

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: ๐Ÿ’ฌ Easy/Newbie PCB for MySensors

      I ordered my pcbs from dirtypcbs (it was my first order) and was also quite confused.
      After failing to add the rar-file (I got an error-message about the file format), I only uploaded the .brd-file and that was accepted.
      After your comment sundberg, I am very curious to see how the boards turned out and if they are usable.
      They were shipped on Monday, so it will be a few weeks before they reach me thought.

      posted in OpenHardware.io
      BastienVH
      BastienVH
    • RE: Can't get motion interrupt to work in my (combined temp, battery and motion) sketch

      @AWI
      Thank you so much!
      I've been at this the entire morning and I just couldn't see it...

      Now the interrupt works perfectly!
      I'm just gonna find a way to only send the motion status on interrupt and not the battery level and motion temp.
      I think it'll be with some if statement.

      I'm off to mess around with the cvode some more!

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

      Hi everyone,

      I've been having some trouble combining the temp, battery and motion sketch.
      I put the code together and battery level, temperature and motion info gets sent on the regular intervals, but I can't get the motion to trigger an interrupt.
      The code is below.

      I've tried flashing the the regular motion sketch and alter the names of the motion pin to MOTION_INPUT_SENSOR and that works.
      Also, I'm using a HC-SR501 on a 3.3V pro mini, but as I said, it acts correctly when using the regular sketch.

      Could someone take a look at my code and see what I might have missed?

      Here's my 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       */
      
      // Include libraries
      #include <MySensor.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      // Define data
      #define CHILD_ID_TEMP 0              // Temp child ID
      #define CHILD_ID_MOTION 2            // MOTION child ID
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      #define MOTION_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define INTERRUPT MOTION_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      
      // Initialize mysensor
      MySensor gw;
      
      // Initialize D_Temp
      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.
      
      // Variables
      unsigned long SLEEP_TIME = 20000; // Sleep time between reads (in milliseconds)
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors = 0;
      int node_id = 13;
      int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
      int oldBatteryPcnt = 0;
      boolean receivedConfig = false;
      boolean metric = true;
      
      // Initialize childs
      MyMessage msgMot(CHILD_ID_MOTION, V_TRIPPED);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      void setup()
      {
        // Start up the OneWire library
        sensors.begin();
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      
        // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
        analogReference(INTERNAL1V1);
      #else
        analogReference(INTERNAL);
      #endif
      
        // Startup and initialize MySensors library. Set callback for incoming messages.
        gw.begin(NULL, node_id);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Temp en Motion sensor met batterij", "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, S_TEMP);
         }
           pinMode(MOTION_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_MOTION, S_MOTION);
      
      }
      
      
      void loop()
      {
        // get the battery Voltage
        int sensorValue = analogRead(BATTERY_SENSE_PIN);
      #ifdef DEBUG
        Serial.println(sensorValue);
      #endif
      
        // 1M, 470K divider across battery and using internal ADC ref of 1.1V
        // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
        // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
        // 3.44/1023 = Volts per bit = 0.003363075
        float batteryV  = sensorValue * 0.003363075;
        int batteryPcnt = sensorValue / 10;
      
      #ifdef DEBUG
        Serial.print("Battery Voltage: ");
        Serial.print(batteryV);
        Serial.println(" V");
      
        Serial.print("Battery percent: ");
        Serial.print(batteryPcnt);
        Serial.println(" %");
      #endif
      
        if (oldBatteryPcnt != batteryPcnt) {
          // Power up radio after sleep
          gw.sendBatteryLevel(batteryPcnt);
          oldBatteryPcnt = batteryPcnt;
        }
      
        // Process incoming messages (like config from server)
        gw.process();
      
        // 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)
        gw.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>((gw.getConfig().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
            gw.send(msgTemp.setSensor(i).set(temperature, 1));
            // Save new temperatures for next compare
            lastTemperature[i] = temperature;
          }
            // Read digital motion value
        boolean tripped = digitalRead(MOTION_INPUT_SENSOR) == HIGH; 
              
        Serial.println(tripped);
        gw.send(msgMot.set(tripped?"1":"0"));  // Send tripped value to gw 
        }
        gw.sleep(SLEEP_TIME,CHANGE, SLEEP_TIME);
      }
      

      I hope you don't lose your way in the sketch, because it's kind of cobbled together from other sketches I found, so it isn't well structured.
      Thanks in advance!

      Just a quick edit: this is the altered standard sketch that does work with the interrupt:

      /**
       * 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
       * Motion Sensor example using HC-SR501 
       * http://www.mysensors.org/build/motion
       *
       */
      
      #include <MySensor.h>  
      #include <SPI.h>
      
      unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define MOTION_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define INTERRUPT MOTION_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1   // Id of the sensor child
      int node_id = 10;
      
      MySensor gw;
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()  
      {  
        gw.begin(NULL, node_id);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Motion Sensor", "1.0");
      
        pinMode(MOTION_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);
        
      }
      
      void loop()     
      {     
        // Read digital motion value
        boolean tripped = digitalRead(MOTION_INPUT_SENSOR) == HIGH; 
              
        Serial.println(tripped);
        gw.send(msg.set(tripped?"1":"0"));  // Send tripped value to gw 
       
        // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
        gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
      }
      
      posted in Troubleshooting
      BastienVH
      BastienVH
    • RE: pimatic-mysensors controller plugin

      @Dheeraj
      I feel so stupid now... I built this circuit on a breadboard and after fiddling around with it yesterday, I forgot to place the resistor for the battery in the right pin. It was now on a different row.
      Saw it and fixed it. Now I get a battery percentage in Pimatic!

      Thanks for your help!

      posted in pimatic
      BastienVH
      BastienVH
    • RE: pimatic-mysensors controller plugin

      Hi,

      After using OpenHAB for quite some time, I've made the transition to Pimatic.
      I've got a pro mini 3V running on 2 AA batteries with a DS18B20-temp-sensor.
      I would like to be able to display the battery level but am having some trouble.
      I combined the temp and battery sensor into 1, but the battery status isn't being analyzed properly.
      When I restart the node it transmits a value of 12 and shortly after that a value of 0.

      Any ideas how to solve this?
      Is this related to pimatic and the format in which it receives battery data or is it simply a fault in my code?

      Thanks in advance!

      This is my code:

      /**
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       */
      
      #include <MySensor.h>  
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      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. 
      MySensor gw;
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      int node_id = 12;
      int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
      int oldBatteryPcnt = 0;
      boolean receivedConfig = false;
      boolean metric = true; 
      // Initialize temperature message
      MyMessage msg(0,V_TEMP);
      
      void setup()  
      { 
        // Startup up the OneWire library
        sensors.begin();
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      
        // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
         analogReference(INTERNAL1V1);
      #else
         analogReference(INTERNAL);
      #endif
      
       // Startup and initialize MySensors library. Set callback for incoming messages. 
        gw.begin(NULL, node_id);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Temperature Sensor met battery", "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, S_TEMP);
        }
      }
      
      
      void loop()     
      {     
         // get the battery Voltage
         int sensorValue = analogRead(BATTERY_SENSE_PIN);
         #ifdef DEBUG
         Serial.println(sensorValue);
         #endif
         
         // 1M, 470K divider across battery and using internal ADC ref of 1.1V
         // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
         // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
         // 3.44/1023 = Volts per bit = 0.003363075
         float batteryV  = sensorValue * 0.003363075;
         int batteryPcnt = sensorValue / 10;
      
         #ifdef DEBUG
         Serial.print("Battery Voltage: ");
         Serial.print(batteryV);
         Serial.println(" V");
      
         Serial.print("Battery percent: ");
         Serial.print(batteryPcnt);
         Serial.println(" %");
         #endif
      
         if (oldBatteryPcnt != batteryPcnt) {
           // Power up radio after sleep
           gw.sendBatteryLevel(batteryPcnt);
           oldBatteryPcnt = batteryPcnt;}
           
        // Process incoming messages (like config from server)
        gw.process(); 
      
        // 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)
        gw.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>((gw.getConfig().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
            gw.send(msg.setSensor(i).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        gw.sleep(SLEEP_TIME);
      }
      
      posted in pimatic
      BastienVH
      BastienVH
    • RE: Battery Sensor with stepup and on/off transistor

      @n3ro
      I have been looking into making some battery powered sensors.
      I have some questions about your setup, because I've been looking for some step up convertors but the 3.3v seems so expensive compared to the step up your using (I've only found this 3.3v one) which is 3+ times more expensive than this 5v one).

      Do you power your pro mini 3.3v from the 5v step up?
      Did you remove the on board power regulator (I'm thinking you haven't)?
      Does your DHT sensor work fine with 5v?

      I've been breaking my head over how to make the cheapest battery powered sensor possible, but it's been difficult since I'm very much still a noob.

      posted in Hardware
      BastienVH
      BastienVH
    • RE: Soldering iron / station requirements

      Hi,

      Thank you so much for your replies.
      This community is so awesome!

      Shipping cost to Belgium is only 6.49 for the Hakko-clone, so I think I'm going for that one.
      It also has a small tip, which should come in handy for electronics-soldering.
      What size solder wire do you use?

      posted in General Discussion
      BastienVH
      BastienVH
    • Soldering iron / station requirements

      Hi everyone,

      I'm new on the forum, but have been reading alot about Mysensors the last couple of months and have decided to take the plunge: I want to start building my own sensors.

      I am currently using OpenHAB on a Rasppberry Pi for my home automation (together with some 433 MHz plugs and Milight-lights), but want to add some sensors to the network.

      I don't have a soldering iron, but want to order one online.
      What soldering iron are you using?
      I know I should buy one with temperature control, but what size should the tip be?
      I used my dads soldering iron to solder pins onto an arduino nano, but that tip was way too big.

      I'm not looking to spend too much money, because I still need to order arduinos, sensors, cases, ... ๐Ÿ˜‰

      Would this be usable for example?

      Thanks for your suggestions!

      posted in General Discussion
      BastienVH
      BastienVH