Autor Thema: MySensor Parking Sensor  (Gelesen 3542 mal)

Offline Edi77

  • Sr. Member
  • ****
  • Beiträge: 527
  • Der Weg ist das Ziel
MySensor Parking Sensor
« am: 04 Juni 2016, 03:06:05 »
Hallo,

Soweit funktioniert der Parking Sensor ja, und der FHEM hat ich auch gleichgefunden.
https://www.mysensors.org/build/parking
Allerdings kommt beim FHEM nicht wirklich was an was ich auswerten könnte
Bei Tripped1 ändert sich nur die letzte Ziffer wenn "eine Auto geparkt ist oder nicht"
Vielleicht kann mir jemand helfen?

2016-06-04_01:00:07 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:21:21 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:21:24 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:21:44 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:21:53 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:21:58 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:22:20 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:22:50 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:22:55 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:24:30 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:24:36 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:24:41 MYSENSOR_1 parentId: 0
2016-06-04_01:24:43 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_01:24:43 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_01:24:46 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:24:58 MYSENSOR_1 parentId: 0
2016-06-04_01:25:00 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_01:25:00 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_01:25:03 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:25:12 MYSENSOR_1 parentId: 0
2016-06-04_01:25:15 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_01:25:15 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_01:25:18 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:25:23 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:25:30 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:25:35 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:25:40 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:25:52 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:25:57 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:35:10 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:35:18 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:35:31 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:35:45 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:36:02 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:36:08 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:36:26 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:36:34 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:36:39 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:36:44 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:36:56 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:37:34 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:40:04 MYSENSOR_1 parentId: 0
2016-06-04_01:40:06 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_01:40:06 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_01:40:10 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:41:22 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:41:27 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:41:46 MYSENSOR_1 tripped1: 1795162113
2016-06-04_01:41:54 MYSENSOR_1 tripped1: 1795162112
2016-06-04_01:54:15 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:54:27 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:55:24 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:55:33 MYSENSOR_1 tripped1: 1090519040
2016-06-04_01:55:50 MYSENSOR_1 tripped1: 1090519041
2016-06-04_01:55:56 MYSENSOR_1 tripped1: 1090519040
2016-06-04_02:02:27 MYSENSOR_1 parentId: 0
2016-06-04_02:02:29 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_02:02:29 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_02:02:32 MYSENSOR_1 tripped1: 1795162113
2016-06-04_02:02:37 MYSENSOR_1 tripped1: 1795162112
2016-06-04_02:17:31 MYSENSOR_1 tripped1: 1090519041
2016-06-04_02:17:37 MYSENSOR_1 tripped1: 1090519040
2016-06-04_02:18:07 MYSENSOR_1 tripped1: 1090519041
2016-06-04_02:18:18 MYSENSOR_1 tripped1: 1090519040
2016-06-04_02:22:22 MYSENSOR_1 tripped1: 1090519041
2016-06-04_02:22:28 MYSENSOR_1 tripped1: 1090519040
2016-06-04_02:25:31 MYSENSOR_1 tripped1: 1090519041
2016-06-04_02:25:47 MYSENSOR_1 tripped1: 1090519040
2016-06-04_02:27:23 MYSENSOR_1 tripped1: 1090519041
2016-06-04_02:27:28 MYSENSOR_1 tripped1: 1090519040
2016-06-04_03:01:28 MYSENSOR_1 tripped1: 1795162113
2016-06-04_03:01:35 MYSENSOR_1 tripped1: 1795162112
2016-06-04_03:01:42 MYSENSOR_1 parentId: 0
2016-06-04_03:01:44 MYSENSOR_1 SKETCH_NAME: Parking Sensor
2016-06-04_03:01:44 MYSENSOR_1 SKETCH_VERSION: 1.0
2016-06-04_03:01:47 MYSENSOR_1 tripped1: 1795162112
2016-06-04_03:01:54 MYSENSOR_1 tripped1: 1795162113
2016-06-04_03:01:59 MYSENSOR_1 tripped1: 1795162112

Ich habe eine WLAN Gateway mit ESP 8266 in der Version 1.5.4 und der Parksensor hat dieses 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 - Created by Henrik Ekblad
 *
 * DESCRIPTION
 * Parking sensor using a neopixel led ring and distance sensor (HC-SR04).
 * Configure the digital pins used for distance sensor and neopixels below.
 * NOTE! Remeber to feed leds and distance sensor serparatly from your Arduino.
 * It will probably not survive feeding more than a couple of LEDs. You
 * can also adjust intesity below to reduce the power requirements.
 *
 * Sends parking status to the controller as a DOOR sensor if SEND_STATUS_TO_CONTROLLER
 * is defined below. You can also use this _standalone_ without any radio by
 * removing the SEND_STATUS_TO_CONTROLLER define.
 */

#define SEND_STATUS_TO_CONTROLLER  // Put a comment on this line for standalone mode

#include <Adafruit_NeoPixel.h>
#include <NewPing.h>

#ifdef SEND_STATUS_TO_CONTROLLER
#include <SPI.h>
#include <MySensor.h>
#endif

#define NEO_PIN      4 // NeoPixels input pin

#define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.

#define NUMPIXELS      24 // Number of nexpixels in ring/strip
#define MAX_INTESITY   20  // Intesity of leds (in percentage). Remeber more intesity requires more power.

// The maximum rated measuring range for the HC-SR04 is about 400-500cm.
#define MAX_DISTANCE 100 // Max distance we want to start indicating green (in cm)
#define PANIC_DISTANCE 5 // Mix distance we red warning indication should be active (in cm)
#define PARKED_DISTANCE 20 // Distance when "parked signal" should be sent to controller (in cm)

#define PARK_OFF_TIMEOUT 20000 // Number of milliseconds until turning off light when parked.

// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

#ifdef SEND_STATUS_TO_CONTROLLER
#define CHILD_ID 1
MySensor gw;
MyMessage msg(CHILD_ID,V_TRIPPED);
#endif
unsigned long sendInterval = 5000;  // Send park status at maximum every 5 second.
unsigned long lastSend;

int oldParkedStatus=-1;

unsigned long blinkInterval = 100; // blink interval (milliseconds)
unsigned long lastBlinkPeriod;
bool blinkColor = true;

// To make a fading motion on the led ring/tape we only move one pixel/distDebounce time
unsigned long distDebounce = 30;
unsigned long lastDebouncePeriod;
int numLightPixels=0;
int skipZero=0;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting distance sensor");
  pixels.begin(); // This initializes the NeoPixel library.
  Serial.println("Neopixels initialized");
#ifdef SEND_STATUS_TO_CONTROLLER
  gw.begin();
  gw.sendSketchInfo("Parking Sensor", "1.0");
  gw.present(CHILD_ID, S_DOOR, "Parking Status");
#endif
}

void loop() {
  unsigned long now = millis();
 
  int fullDist = sonar.ping_cm();
//  Serial.println(fullDist);
  int displayDist = min(fullDist, MAX_DISTANCE);
  if (displayDist == 0 && skipZero<10) {
    // Try to filter zero readings
    skipZero++;
    return;
  }
  // Check if it is time to alter the leds
  if (now-lastDebouncePeriod > distDebounce) {
    lastDebouncePeriod = now;

    // Update parked status
    int parked = displayDist != 0 && displayDist<PARKED_DISTANCE;
    if (parked != oldParkedStatus && now-lastSend > sendInterval) {
      if (parked)
        Serial.println("Car Parked");
      else
        Serial.println("Car Gone");
#ifdef SEND_STATUS_TO_CONTROLLER
      gw.send(msg.set(parked));
#endif
      oldParkedStatus = parked;
      lastSend = now;
    }

    if (parked && now-lastSend > PARK_OFF_TIMEOUT) {
      // We've been parked for a while now. Turn off all pixels
      for(int i=0;i<NUMPIXELS;i++){
        pixels.setPixelColor(i, pixels.Color(0,0,0));
      }
    } else {
      if (displayDist == 0) {
        // No reading from sensor, assume no object found
        numLightPixels--;
      } else {
        skipZero = 0;
        int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/MAX_DISTANCE);
        if (newLightPixels>numLightPixels) {
          // Fast raise
          numLightPixels += max((newLightPixels - numLightPixels) / 2, 1);
        } else if (newLightPixels<numLightPixels) {
          // Slow decent
          numLightPixels--;
        }
      }
 
      if (numLightPixels>=NUMPIXELS) {
        // Do some intense red blinking
        if (now-lastBlinkPeriod > blinkInterval) {
          blinkColor = !blinkColor;
          lastBlinkPeriod = now;
        }
        for(int i=0;i<numLightPixels;i++){
          pixels.setPixelColor(i, pixels.Color(blinkColor?255*MAX_INTESITY/100:0,0,0));
        }             
      } else {
        for(int i=0;i<numLightPixels;i++){
          int r = 255 * i/NUMPIXELS;
          int g = 255 - r;     
          // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
          pixels.setPixelColor(i, pixels.Color(r*MAX_INTESITY/100,g*MAX_INTESITY/100,0));
        }
        // Turn off the rest
        for(int i=numLightPixels;i<NUMPIXELS;i++){
          pixels.setPixelColor(i, pixels.Color(0,0,0));
        }
      }
    }
    pixels.show(); // This sends the updated pixel color to the hardware.
  }
}



Starti¶ö distance sensor
Neopixels initialized
send: 1-1-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-1 s=255,c=3,t=6,pt=0,l=2,sg=0:M

sensor started, id=1, parent=0, distance=1
send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=14,sg=0,st=ok:Parking Sensor
send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
send: 1-1-0-0 s=1,c=0,t=0,pt=0,l=14,sg=0,st=ok:Parking Status
Car Gone
send: 1-1-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
Car Parked
send: 1-1-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:1
Car Gone
send: 1-1-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
Car Parked
send: 1-1-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:1
Car Gone
send: 1-1-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
« Letzte Änderung: 04 Juni 2016, 15:08:51 von Edi77 »
Master FHEM 6 als VM auf ESX mit Mint/Ubuntu 18.04 LTS mit MAXCube/MAX!/FS20|TabletUI|Flightradar|Tasmota|CCU3 HomematicIP|RPi mit GammaScout,nanoCUL868|MQTT EasyESP 8266|LuftdatenInfo|deCONZ HUEDev|probemon|Siemens Logo|Xiaomi Flower|3D PRINTER RAISE3D

Offline Niko1987

  • Jr. Member
  • **
  • Beiträge: 92
Antw:MySensor Parking Sensor
« Antwort #1 am: 05 Juni 2016, 10:33:50 »
Hallo Edi,

der Sensor würde korrekt senden aber es kommt nicht richtig am Gateway an.
Ich hatte dieses Problem auch mal.
Versuch mal deinen Gateway auf 2.0 Beta zu updaten.
Danach sollte es funktionieren.

Der Sensor muss nicht unbedingt auf dem neuesten Stand sein (zumindest klappt das bei mir)

Viel Erfolg

Gruß

Flo

Offline Edi77

  • Sr. Member
  • ****
  • Beiträge: 527
  • Der Weg ist das Ziel
Antw:MySensor Parking Sensor
« Antwort #2 am: 05 Juni 2016, 14:42:47 »
Hallo Niko,

DANKE für die Antwort, habe hier noch einen ESP 8266 12E liegen den kann ich mal auf 2.0 Beta flashen.
Vielleicht kannst du mir noch kurz und kapp eine Frage beantworten.
Was hat sich von 1.5.4 > 2.0 geändert? Was diese Problem vielleicht verursachen könnte?

 
Master FHEM 6 als VM auf ESX mit Mint/Ubuntu 18.04 LTS mit MAXCube/MAX!/FS20|TabletUI|Flightradar|Tasmota|CCU3 HomematicIP|RPi mit GammaScout,nanoCUL868|MQTT EasyESP 8266|LuftdatenInfo|deCONZ HUEDev|probemon|Siemens Logo|Xiaomi Flower|3D PRINTER RAISE3D

Offline Beta-User

  • Moderator
  • Hero Member
  • ***
  • Beiträge: 16331
Antw:MySensor Parking Sensor
« Antwort #3 am: 05 Juni 2016, 17:28:00 »
Sofern ich Euer Problem richtig verstanden habe

Hallo Edi,

 aber es kommt nicht richtig am Gateway an.

müßte es m.E. korrekt heißen: der ESP hat ein Timing-Problem und kann daher die korrekt gesendeten Informationen nicht richtig auswerten. Die 1.5.4-ESP-Libraries berücksichtigen das noch nicht hinreichend, die 2.0.0 schon. Wegen der Timing-Themen haben auch diverse Leute Probleme gehabt mit Infrarot usw.
Server: HP-T620@Debian 10, aktuelles FHEM + ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn:MySensors, Weekday-&RandomTimer, Twilight,  AttrTemplate {u.a. mqtt2, mysensors, zwave}

Offline Hauswart

  • Developer
  • Sr. Member
  • ****
  • Beiträge: 859
Antw:MySensor Parking Sensor
« Antwort #4 am: 06 Juni 2016, 10:10:31 »
Genau, ich würde auch erst einmal updaten.

Anschliessend müssen wir mal schauen, ob FHEM überhaupt mit Strings in Variablen umgehen kann. Habe ich persönlich noch nie getestet, wobei eh fraglich ist, ob ein String senden Sinn macht oder nicht doch nur lieber 1 (Geparkt) oder 0 (Kein Auto da).
1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

2. Installation:
HM-CFG-USB, Unifi (, SIGNALduino 868, MySensors, SIGNALduino 433)

Offline Edi77

  • Sr. Member
  • ****
  • Beiträge: 527
  • Der Weg ist das Ziel
Antw:MySensor Parking Sensor
« Antwort #5 am: 07 Juni 2016, 22:53:06 »
Hallo,

DANKE, habe es gerade getestet, und ein ESP8266Gateway auf 2.0.0 Beta installiert, und siehe da, es läuft.
tripped1 geht jetzt on/off  ;D
Master FHEM 6 als VM auf ESX mit Mint/Ubuntu 18.04 LTS mit MAXCube/MAX!/FS20|TabletUI|Flightradar|Tasmota|CCU3 HomematicIP|RPi mit GammaScout,nanoCUL868|MQTT EasyESP 8266|LuftdatenInfo|deCONZ HUEDev|probemon|Siemens Logo|Xiaomi Flower|3D PRINTER RAISE3D