Looking for a simple guide MySensors+Domoticz (Raspi as controller with NRF)



  • Hi to all!
    I'm not real new to the Raspberry and Arduino. I did try last year to build a total self made web controller with Raspberry 2 as central and Arduino as slave / reading temperature.
    Now I want to follow the route with MySensors + Domoticz.

    But I cannot find a "simple" guide.

    My goal:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    
    • Arduino with a NRF and a DHT22 sensor that sends data to the Raspberry.

    I cannot understand how setup Raspberry as GATEWAY + CONTROLLER toghether.

    Summary:

    NRF compiled with "Serial gateway" method. It is now /ttyPI (if I remember right, how I can find it?).

    In domoticz, In select I have only MySensorUSB and MySensorLAN . If I select the USB, in second select I have only the AMA20 (?)

    Thank you very much


  • Mod

    @sineverba I haven't tried this setup myself yet, but I did have some issues with Domoticz not updating available serial ports if they come available with Domoticz running. Try refreshing the page, or even restarting Domoticz.
    If that doesn't work you could also try running the Pi gateway as Ethernet gateway and connect Domoticz to localhost.


  • Mod

    @sineverba When I set up my Domoticz installation, Domoticz was very picky about the how the tty was named. I had to follow this part of the instruction:

    For some controllers a more recognisable name needs to be used: e.g. /dev/ttyUSB020 (check if this is free).

    See if running configure with --my-serial-pty=/dev/ttyUSB020 (in addition to all the other parameters you used last time) and then running make and try sudo ./bin/mysgw -d again.



  • @mfalkvidd said in Looking for a simple guide MySensors+Domoticz (Raspi as controller with NRF):

    @sineverba When I set up my Domoticz installation, Domoticz was very picky about the how the tty was named. I had to follow this part of the instruction:

    For some controllers a more recognisable name needs to be used: e.g. /dev/ttyUSB020 (check if this is free).

    See if running configure with --my-serial-pty=/dev/ttyUSB020 (in addition to all the other parameters you used last time) and then running make and try sudo ./bin/mysgw -d again.

    Thank you. But I need to select which transport? Serial? Another thing, what i need to see / find on Domoticz if all is OK? Can you post me a screenshot of hardware section ?

    Thank you


  • Mod

    @sineverba I use serial. Ethernet should work as well.

    Here is what mine looks like. I am still running the old MySensors 1.4 gateway software though.
    0_1497771527761_IMG_1737.PNG



  • Ok,
    I did made some progress!
    Let's do a summary.

    1. Fresh install of last Raspbian from official site

    2. Did setup on Arduino for NRF + on PI for NRF with examples in TMRH20 library on github. They work very well, send and receiving data correctly.

    3. Setup with guide for 1.x version (this: https://forum.mysensors.org/topic/2437/step-by-step-procedure-to-connect-the-nrf24l01-to-the-gpio-pins-and-use-the-raspberry-as-a-serial-gateway-mysensors-1-x )

    4. No error, all OK, I did install domoticz (via "easy" mode)

    5. Now, in domoticz I see the USB Gateway (I remember, I have NRF direct attached on GPIO, arduino is on other side of the room, no physical USB) and I did add:

    alt text

    1. I did upload sketch on arduino, an example sketch of MySensor library (CO2) or UV sensors (no sensor attached, only sketch + radio).

    This is the sketch (note custom define of 2 PINS):

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    
    #define MY_RF24_CE_PIN 7
    #define MY_RF24_CS_PIN 8
    
    #include <MySensors.h>
    
    #define UV_SENSOR_ANALOG_PIN 0
    
    #define CHILD_ID_UV 0
    
    unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
    
    MyMessage uvMsg(CHILD_ID_UV, V_UV);
    
    unsigned long lastSend =0;
    float uvIndex;
    float lastUV = -1;
    uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
    
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("UV Sensor", "1.2");
    
    	// Register all sensors to gateway (they will be created as child devices)
    	present(CHILD_ID_UV, S_UV);
    }
    
    void loop()
    {
    	unsigned long currentTime = millis();
    
    	uint16_t uv = analogRead(UV_SENSOR_ANALOG_PIN);// Get UV value
    	if (uv>1170) {
    		uv=1170;
    	}
    
    	//Serial.print("UV Analog reading: ");
    	//Serial.println(uv);
    
    	int i;
    	for (i = 0; i < 12; i++) {
    		if (uv <= uvIndexValue[i]) {
    			uvIndex = i;
    			break;
    		}
    	}
    
    	//calculate 1 decimal if possible
    	if (i>0) {
    		float vRange=uvIndexValue[i]-uvIndexValue[i-1];
    		float vCalc=uv-uvIndexValue[i-1];
    		uvIndex+=(1.0/vRange)*vCalc-1.0;
    	}
    
    	//Serial.print("UVI: ");
    	//Serial.println(uvIndex,2);
    
    	//Send value to gateway if changed, or at least every 5 minutes
    	if ((uvIndex != lastUV)||(currentTime-lastSend >= 5UL*60UL*1000UL)) {
    		lastSend=currentTime;
    		send(uvMsg.set(uvIndex,2));
    		lastUV = uvIndex;
    	}
    
    	sleep(SLEEP_TIME);
    }
    

    I have this in monitor serial of arduino:

    139291 TSMTSF:MSG:SEND,105-105-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    11 TSM:INIT:TSP OK
    13 TSF:SID:OK,ID=105
    14 TSM:FPAR
    51 TSF:MSG:SEND,105-105-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    893 TSF:MSG:READ,0-0-105,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    899 TSF:MSG:FPAR OK,ID=0,D=1
    2058 TSM:FPAR:OK
    2059 TSM:ID
    2060 TSM:ID:OK
    2062 TSM:UPL
    2065 TSF:MSG:SEND,105-105-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    4072 TSM:UPL
    4074 TSF:MSG:SEND,105-105-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    6082 TSM:UPL
    6084 TSF:MSG:SEND,105-105-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    

    (without custom definition of pin, of course, I have simply fail, 'cause I did attach pin differently)

    It seems to me that Arduino sends in right way and have an answer from PI (?)

    But this is the log of domoticz...

    2017-06-18 15:29:59.327 Domoticz V3.5877 (c)2012-2016 GizMoCuz
    2017-06-18 15:29:59.333 Build Hash: 15b013c, Date: 2016-11-10 15:44:33
    2017-06-18 15:29:59.333 System: Raspberry Pi
    2017-06-18 15:29:59.334 Startup Path: /home/pi/domoticz/
    2017-06-18 15:29:59.964 Active notification subsystems: http (1/12)
    2017-06-18 15:30:00.001 WebServer(HTTP) started on address: :: with port 8080
    2017-06-18 15:30:00.036 WebServer(SSL) started on address: :: with port 443
    2017-06-18 15:30:00.043 Proxymanager started.
    2017-06-18 15:30:00.054 Starting shared server on: :::6144
    2017-06-18 15:30:00.056 RxQueue: queue worker started...
    2017-06-18 15:30:00.056 TCPServer: shared server started...
    2017-06-18 15:30:02.130 EventSystem: reset all events...
    2017-06-18 15:30:02.135 EventSystem: reset all device statuses...
    2017-06-18 15:30:02.137 EventSystem: Started
    2017-06-18 15:30:03.131 MySensors: Using serial port: /dev/ttyUSB20
    2017-06-18 15:30:35.783 Incoming connection from: 192.168.1.201
    

    And in child spaces are empty :(

    alt text

    Maybe I did not do other steps? I repeat, the NRF works together (as tested from NRF24 library)...

    Thank you guys!

    PS:

    With domoticz live and Arduino sending, I did a

    sudo ./PiGateway
    

    This is the answer:

    pi@raspberrypi:~/Raspberry $ sudo ./PiGateway
    Starting Gateway...
    ================ SPI Configuration ================
    CSN Pin          = CE0 (PI Hardware Driven)
    CE Pin           = Custom GPIO25
    Clock Speed      = 8 Mhz
    ================ NRF Configuration ================
    STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
    RX_ADDR_P0-1     = 0xa8a8e1fc69 0xa8a8e1fc00
    RX_ADDR_P2-5     = 0xff 0xc4 0xc5 0xc6
    TX_ADDR          = 0xa8a8e1fc69
    RX_PW_P0-6       = 0x20 0x20 0x20 0x00 0x00 0x00
    EN_AA            = 0x3b
    EN_RXADDR        = 0x06
    RF_CH            = 0x4c
    RF_SETUP         = 0x23
    CONFIG           = 0x0e
    DYNPD/FEATURE    = 0x3f 0x06
    Data Rate        = 250KBPS
    Model            = nRF24L01+
    CRC Length       = 16 bits
    PA Power         = PA_LOW
    [CALLBACK]0;0;3;0;14;Gateway startup complete.
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-105-105 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-0 s=255,c=3,t=24,pt=1,l=1:1
    [CALLBACK]105;255;3;0;24;1
    read: 105-105-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-105-105 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    

  • Mod

    @sineverba looks like you are using a MySensors 1.x gateway with a MySensors 2.1.1 node. That will not work. Gateway and sensor need to be the same major version. Use the 2.x gateway instructions instead.



  • @mfalkvidd yes, I'm using node 2 and mysensor 1 gateway.

    Unfortunately I don't get on work 2.0 gateway..... :( :( :(

    Next week I will restart with a fresh Raspbian, maybe I will solve my initial issues...

    Thank you very much!


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.