Integration von MySensors in FHEM geplant?

Begonnen von fh555, 06 September 2014, 00:40:58

Vorheriges Thema - Nächstes Thema

Peter_64

@MrTom
da ich auch die Probleme habe bei Analog werten bekomme ich die langen Zahlen, möchte ich das ebenfalls wie Du testen. Die Version 1.6.0 beta, ist das eine ältere Version IDE Arduino? Hast evtl. den link dazu?
Gruß

Hauswart

Er meint die MySensors Development (mittlerweile 2.0.0beta) Sketche.
1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

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

gloob

Hat jemand zufällig eine Beispielintegration in FHEM für ein MySensor Device, welches Daten von FHEM an MySensor schickt?
Ich scheitere aktuell schon an einem einfachen RelayActuator.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

Hauswart

1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

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

gloob

Es funktioniert bei mir jetzt alles. Es hat sich herausgestellt, dass die RX Leitung von meinem Raspberry zum Gateway irgendwie nicht funktioniert hat. Empfangen war also kein Problem, nur das Senden ging überhaupt nicht.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

Jarnsen

Hallo,

ich habe 2 Probleme
1.) einen DHT22 eingebunden. Leider wird die Temperatur in Fahrenheit angezeigt. Eine umstellung des Device auf config M führt nicht zum Erfolg. Habe den Standartsketch von MySensors genommen.

/**
* 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 CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
unsigned long SLEEP_TIME = 30000; // 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);


void setup() 
{
  gw.begin();
  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);

  // Send the Sketch Version Information to the Gateway
  gw.sendSketchInfo("Humidity", "1.0");

  // 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);
 
  metric = gw.getConfig().isMetric;
}

void loop()     

  delay(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);
  }

  gw.sleep(SLEEP_TIME); //sleep a bit
}



(http://up.picr.de/24486012la.jpg)



2.) DS18b20 ebenfalls mit Standartsketch Zeigt kein TempReading an. Auch meine Versuche einen anzulegen scheiterten.

/**
* 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;
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);

  // Startup and initialize MySensors library. Set callback for incoming messages.
  gw.begin();

  // Send the sketch version information to the gateway and Controller
  gw.sendSketchInfo("Temperature Sensor", "1.1");

  // 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()     
{     
  // 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);
}


(http://up.picr.de/24486013qb.jpg)



habe eine SerialGateway

hoffe ihr könnt helfen
1 x RPi2,
1 x nanoCUL433, 1 x nanoCUL868, 1 x SIGNALduino433
Sonos/SonosSpeak, Homebridge, 2 x Enigma2, 10 x Nobily Rollläden, 3 x Intertechno Steckdosen
Pushover, Abfallerinnerung, MySensors, 7 x Max!

SvenJust

Hallo,

Zitat von: Jarnsen am 04 Februar 2016, 17:50:54
2.) DS18b20 ebenfalls mit Standartsketch Zeigt kein TempReading an. Auch meine Versuche einen anzulegen scheiterten.

Du kannst das mapReading-Attribut auch manuell anlegen.
attr Temp mapReading_T0 0 temperature

Das Reading sollte dann beim nächsten Update des Wertes erscheinen. Genau kannst Du bei weiteren Temperatursensoren an dem Device vorgehen.

VG
Sven
FTUI, Raspberry PI/SSD, CUL CC1101, HMLAN, 10x HM-LC-Bl1PBU-FM, HM-LC-Sw4-WM (KWL Pluggit P300), HM-WDS30-OT2-SM (Sonnensensor), HM-Sec-SCo, LW-12 Wifi LED, CUL Selbstbau nanoCUL 433 (IT), Arduino (S0-Stromverbrauch), OW DS2480 (OWX_ASYNC) 8x DS18B20, MQTT (Fröling P4), MYSENSORS (Roto Rollläden)

Kuzl

Zitat von: Jarnsen am 04 Februar 2016, 17:50:54
1.) einen DHT22 eingebunden. Leider wird die Temperatur in Fahrenheit angezeigt. Eine umstellung des Device auf config M führt nicht zum Erfolg. Habe den Standartsketch von MySensors genommen.

Versuch mal diese Zeile auszukommentieren.
Evtl. ist das Gateway auf Metric bzw. schickt das dem Sketch.


  metric = gw.getConfig().isMetric;


Wenn das nicht geht nimm doch einfach die Umrechnung raus, wirst du eh nie brauchen.

Gruß,
Kuzl

Jarnsen

#638
@ Kuzl


// metric = gw.getConfig().isMetric;


das war die Lösung..

@ SvenJust

Danke für das Beispiel

attr Temp mapReading_T0 0 temperature

jetzt weiß ich zumindest wie ich mehrer TempSensoren an einem Device betreiben kann. Das war Allerdings nicht die Lösung bei mir. Die Lösung war ein Widerstand den ich vergessen hatte zwische VCC und D3. Hatte zwar keinen 4k7 zur Hand sondern nur 330Ohm aber der geht auch und das Reading wurde automatisch hinzugefügt.


Danke Jarnsen

1 x RPi2,
1 x nanoCUL433, 1 x nanoCUL868, 1 x SIGNALduino433
Sonos/SonosSpeak, Homebridge, 2 x Enigma2, 10 x Nobily Rollläden, 3 x Intertechno Steckdosen
Pushover, Abfallerinnerung, MySensors, 7 x Max!

Jarnsen

hallo nochmal,

ich wollte jetzt ne Batterie prozentabfrage einrichten. Habe nen Block aus 4 x AAA in Reihe geschalten also ca 6V.

Jetzt habe ich gelesen GitHub und Pimatic das der Arduino mit ATHMEGA 328 intern die V misst. Ich habe den Sketch soweit angepasst und die Libary eingefügt. Leider bringts beim überprüfen immernoch Fehler.

/**
* 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>
#include <readVcc.h>

#define MIN_V
#define MAX_V
#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;
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);

  // Startup and initialize MySensors library. Set callback for incoming messages.
  gw.begin();

  // Send the sketch version information to the gateway and Controller
  gw.sendSketchInfo("Temperature Sensor", "1.1");

  // 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);

     // Define voltages
int MIN_V = 2400; // empty voltage (0%)
int MAX_V = 6000; // full voltage (100%)
int oldBatteryPcnt;

  }
}


void loop()     
{     
  // 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;

      // Measure battery
  float batteryV = readVcc();
  int batteryPcnt = (((batteryV - MIN_V) / (MAX_V - MIN_V)) * 100 );
  if (batteryPcnt > 100) {
    batteryPcnt = 100;

    if (batteryPcnt != oldBatteryPcnt) {
    gw.sendBatteryLevel(batteryPcnt); // Send battery percentage
    oldBatteryPcnt = batteryPcnt;
  }
  }
    }
  }
  gw.sleep(SLEEP_TIME);
}


ich hoffe mal wieder auf eure Hilfe, Gruß Jarnsen
1 x RPi2,
1 x nanoCUL433, 1 x nanoCUL868, 1 x SIGNALduino433
Sonos/SonosSpeak, Homebridge, 2 x Enigma2, 10 x Nobily Rollläden, 3 x Intertechno Steckdosen
Pushover, Abfallerinnerung, MySensors, 7 x Max!

Hauswart

1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

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

Edi77

#641
Hallo,

Ich lese mich gerade auch zu dem Thema mySensors ein, und zuerst will ich mit das Gateway bauen.
Ich bevorzuge das LAN Gateway, wobei der NodeMCU auch interessant ist, aber schwer zu bekommen.
Oder hat da jemand eine Bezugsquelle?

Meine Frage zum nrf24l01+ ist, da dies ja mit 3 - 3,6V betrieben werden kann ist ja für den Nano oder UNO oder Mega ja kein Problem.
Weiter unten steht im Datenblatt VIH = max 5.25V, VIL = 0.3V VDD, VOH = VDD (3,3V), VOL = 0.3V
Bei VOH frage ich mich nun ob man zwischen Nano/Uno nicht doch ein Level Shifting dazwischen dem nrf24l01+ machen sollte ???
Dann sieht man öfters NRF24L01 + PA + LNA und es sind 2 ICs auf der Platine, mit Antennenanschluss.
Ein Antennenanschluss würde ich ja bevorzugen, aber warum sind da 2ICs drauf?
http://www.dx.com/p/nrf24l01-pa-lna-wireless-module-w-antenna-black-3-0-3-6v-222913#.VsSP6WeFNoI
Als Netzwerk wollte ich dann ein W5100 nehmen.
Spricht da was dagegen?

Und wenn ich ein nrf24l01+ mit dem Arduino Mini verbinden möchte brauche ich wohl sowas hier ? Damit 5V > 3.3V
http://www.dx.com/p/socket-adapter-plate-board-converter-8-pin-nrf24l01-wireless-transceive-module-for-51-car-kit-etc-421945#.VsSNO2eFNoI
Master FHEM 6 als VM auf ESX Ubuntu 20.04 LTS mit MAXCube/MAX!/FS20|TabletUI|Flightradar|Tasmota|TTN Lora|CCU3 HomematicIP|RPi mit GammaScout|MQTT EasyESP 8266|LuftdatenInfo|deCONZ HUEDev|probemon|Siemens Logo|P4D|3D PRINTER RAISE3D

Omega

Hallo,
ich habe aktuell 2 FHEM Instanzen und teste z.Zt. mit mehreren Gateways.
Ein Sensor hat ja nur ein IODevice. Das führt dazu, dass das davon nicht betroffene Gateway laufend Meldungen ausgibt wie

MYSENSORS: ignoring set-msg from unknown radioId 104, childId 4 for V_HUM

Die schreiben mir das Log voll und machen alles etwas unübersichtlich.

Ich wünsche  ;D ;D mir an dieser Stelle ein Attribut beim Gateway, dass Messages vom Sensor (Sensoren) gezielt ignoriert werden können, z.B. sowas wie

attr <gateway> ignoreRadioIDs 103,104

Das hätte den Vorteil, dass Meldungen von unbekannten Sensoren weiterhin im Log landen, bei bekannten Sensoren aber unterdrückt werden.

Leider kann ich das nicht selber umsetzen aber vielleicht findet die Idee ja ein paar Unterstützer.

Danke
Holger
NUC6i3SYH (FHEM 5.8 in VM)
Homematic: HMLAN, HMUSB, HM-Sec-SD, HM-CC-RT-DN, HM-TC-IT, ... + diverse weitere
LaCrosseGateway, ESPEasy
ZWave

ntruchsess

#643
Warum sollte man das geziehlt ignorieren? Ober andersrum gefragt: Was hat man davon, dass nicht geziehlt ignorierte messages dann doch geloggt werden?
Alle unbekannten Devices kann man heute schon ignorieren - setze dafür einfach am gateway das Attribut 'verbose' auf 2.

Ansonsten wäre es natürlich sinnvoller die Gateways (und die Ihnen zugeordneten Sensoren) auf unterschiedlichen Funkkanälen laufen zu lassen. Geht leider nicht über ein Fhem-attribut, das muss man vor dem Flashen in der MySensors-library im Sourcecode konfigurieren
while (!asleep()) {sheep++};

Hauswart

@Norbert Du hast noch nen offenen PR auf Github  8)
1. Installation:
KNX, Tasmota (KNX), Sonos, Unifi

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