Getting started issue



  • Hi I have the below setup

    One NodeMCU with Gateway + MQTT

    I think its working can anyone tell me, if all ok?
    • I am able to receive MQTT from the gateway with the version number as payload
    • I can see below logs and then gateway go to some kind of idle mode I think
    • It looks like MQTT is ok but I see no indication for NRF is up and running…

    
    2475 GWT:TPC:CONNECTING...
    3003 GWT:TPC:CONNECTING...
    ip:192.168.1.31,mask:255.255.255.0,gw:192.168.1.1
    3531 GWT:TPC:CONNECTING...
    3559 GWT:TPC:IP=192.168.1.31
    3589 MCO:BGN:STP
    3608 MCO:BGN:INIT OK,TSP=1
    3636 GWT:TPC:IP=192.168.1.31
    3667 GWT:RMQ:MQTT RECONNECT
    3751 GWT:RMQ:MQTT CONNECTED
    3781 GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT
    pm open,type:2 0
    
    

    I have many devices that I have tried to configure as senores, but not a lot of luck
    Only good thing I can see that I am getting msgs from new nodes in MQTT (gateway)
    But each msg comes with different chilled ID and at the end 3/0/3
    Also, the msg payload is empty

    can anyone tell me if my gateway is ok?
    so I can move forward



  • msg from one of the sensors

    108525 TSM:ID
    108525 TSM:ID:REQ
    108529 TSF:MSG:SEND,255-255-0-0,s=237,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
    110538 !TSM:ID:FAIL
    110540 TSM:FAIL:CNT=6
    110542 TSM:FAIL:DIS
    110544 TSF:TDI:TSL
    

    looks like no good but, when I connect it the gateway responses like something is trying to connect or connected
    also child ID is different so i am not able to understand



  • Hi @Gad Ofir,

    Though I'm not familiar with MySensors and MQTT, this protocol reminds me of my first steps with MySensors when I forgot to assign static IDs for my Nodes and the Controller (e.g. MyController https://www.mycontroller.org/#/home) wasn't up and running. You didn't mention which controller you are using - it should be capable of assigning IDs to nodes.

    Copying your sensorlog to the logparser (https://www.mysensors.org/build/parser) shows the lack of an answer to a Request for ID.

    I short circuited the whole ID-process by assigning "hard" IDs in the sketch (e.g.

    #define MY_NODE_ID 100
    

    This should bypass ID-Requests.

    I am not familiar with the exact protocol in the newer MySensors versions so I can't explain the origin of the mentioned ID 237 (???).

    In my environment a Node startup looks like:

    __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.0
    
    16 MCO:BGN:INIT REPEATER,CP=RNNRA---,VER=2.3.0
    26 MCO:BGN:BFR
    27 TSM:INIT
    28 TSF:WUR:MS=0
    35 TSM:INIT:TSP OK
    37 TSM:INIT:STATID=4
    39 TSF:SID:OK,ID=4
    40 TSM:FPAR
    77 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    796 TSF:MSG:READ,0-0-4,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    801 TSF:MSG:FPAR OK,ID=0,D=1
    871 TSF:MSG:READ,7-7-4,s=255,c=3,t=8,pt=1,l=1,sg=0:1
    2084 TSM:FPAR:OK
    2085 TSM:ID
    2086 TSM:ID:OK
    2088 TSM:UPL
    2094 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2110 TSF:MSG:READ,0-0-4,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2115 TSF:MSG:PONG RECV,HP=1
    2117 TSM:UPL:OK
    2119 TSM:READY:ID=4,PAR=0,DIS=1
    

    so there is no request for ID.



  • Thanks, i will try to change this #define MY_NODE_ID 100
    on my gateway

    i am using ESP12 NodeMCU 1.0 rev with nRF24L01 for gateway and sketch ESP + MQTT
    for Sketch i am using ESP8266MQTTGateway

    i am not using any controller , i planed to use MQTT to get the messages , is that ok?

    i have openhab running on my Home but i was planning to use node red only for this



  • i don't see such def MY_NODE_ID 100 on the gateway sketch or the sensor
    maybe i missed something here?

    1. flash the gateway with ESP8266MQTTGateway.ino (only this?)
      do i need to change the sketch here?
      i put Wifi and MQTT

    2. flash the sensor with some sketch (for example PIR)
      did not do any change

    do i need to modify the sketches more?
    do i have the right gateway sketch? or do i need to add somthing there

    /*
     * 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-2018 Sensnology AB
     * Full contributor list: https://github.com/mysensors/MySensors/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
     * The ESP8266 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
     * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
     *
     * LED purposes:
     * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch
     * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or receive crc error
     *
     * See https://www.mysensors.org/build/connect_radio for wiring instructions.
     *
     * If you are using a "barebone" ESP8266, see
     * https://www.mysensors.org/build/esp8266_gateway#wiring-for-barebone-esp8266
     *
     * Inclusion mode button:
     * - Connect GPIO5 (=D1) via switch to GND ('inclusion switch')
     *
     * Hardware SHA204 signing is currently not supported!
     *
     * Make sure to fill in your ssid and WiFi password below for ssid & pass.
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
    #define MY_BAUD_RATE 9600
    
    // Enables and select radio type (if attached)
    #define MY_RADIO_RF24
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    #define MY_GATEWAY_MQTT_CLIENT
    #define MY_GATEWAY_ESP8266
    
    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    
    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    // Enable these if your MQTT broker requires username/password
    //#define MY_MQTT_USER "username"
    //#define MY_MQTT_PASSWORD "password"
    
    // Set WIFI SSID and password
    #define MY_WIFI_SSID "MySSID"
    #define MY_WIFI_PASSWORD "MyVerySecretPassword"
    
    // Set the hostname for the WiFi Client. This is the hostname
    // it will pass to the DHCP server if not static.
    // #define MY_HOSTNAME "mqtt-sensor-gateway"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    //#define MY_IP_ADDRESS 192,168,178,87
    
    // If using static ip you can define Gateway and Subnet address as well
    //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
    //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // MQTT broker ip address.
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
    
    //MQTT broker if using URL instead of ip address.
    // #define MY_CONTROLLER_URL_ADDRESS "test.mosquitto.org"
    
    // The MQTT broker port to to open
    #define MY_PORT 1883
    
    // Enable inclusion mode
    //#define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    //#define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN D1
    
    // Set blinking period
    //#define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Flash leds on rx/tx/err
    //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
    
    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors here
    }
    
    void loop()
    {
    	// Send locally attached sensors data here
    }
    


  • Hi Gad Ofir,

    The Node ID is supplied in the Node Sketch, so you have to modify your PIR sketch (slightly) as shown above.
    The drawback of "hard" coded IDs is - you have to compile every sketch for every node individually and you have to keep track of the used IDs to avoid conflicts. For me (about 20 Sensors) it is manageable.

    About a year ago i tried OpenHab (2.2 I think). There was a kind of plugin for MySensors and it worked very well. So there is a nice way to bypass MQTT.

    I didn't continue OpenHab because it was a slight overkill for my purpose in comparison to MyController which does the trick completely. By the way - MyController seems to work with MQTT too, but I haven't tried it (yet).



  • i will give it a try ... Openhab is great!

    so what you are saying i must have a controller in the system to have Nodes IDs assigned to my sensors?
    i am trying to understand the flow here please elaborate

    so i need to have a

    1. working Openhab with binding (this will assign node id to the sensor )
    2. working gateway (with only changes i have done above)
    3. working sensor and not touch anything and the controller will do the work?

    sorry, i am having a little trouble understanding the logic here?
    thanks for your patience really



  • Hi Gad Ofir ,
    You are correct. So far I remember OpenHab assigns IDs. (but if you got a spare Arduino or STM it will not hurt to have one Node with a fixed, known ID -- just for testing purposes).

    Your list 1.-3. is correct.

    I don't know exactly but from my point of view the logic behind this behavior could be pretty simple: somewhere a list of Nodes has to be kept and the usual Arduino gateways are busy with managing traffic as well as chronically short of RAM and EEPROM. For small networks capacity may be sufficient, but believe me -- MySensors networks tend to grow rapidly. So at last you need an administration Software (aka controller (like OpenHab)) and this may administer the IDs according to its needs instead of keeping and synchronizing double lists.



  • it's late I will give this all a fresh try tomorrow, also i have IDE issues
    not sure if related... I will start from fresh, Compile the gateway and sensor and will see

    1. WARNING: Category 'Input' in library SerialSensors is not valid. Setting to 'Uncategorized'

    2. Invalid version '1.04' for library in: C:\Users\gadof01\Documents\Arduino\libraries\UIPEthernet1

    3. avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x08

    thanks for all the help!



  • Hi gad-ofir,

    1. Warnings may be ignored (for a short time).

    2. What are you doing with UIPEthernet1? Any ENC28J60 chip in Your environment? If so - may be you should use UIPEthernet instead (current version 2.0.6). Beside this - this message is a warning, too.

    3. Check the usual suspects (wrong board? -> if Arduino Nano try "old bootloader", wrong COM port? check Hardwaremanager),

    Both Messages give a hint to an improvable IDE. Maybe an update to the actual version could help.

    Good luck 🙂



  • ordered some new Arduino boards, i will try to go exactly with the guides ...

    not sure why i am getting empty payload, it seems that all is ok on the GW side

    1. i am able to get MQTT msg when it connects
    2. i am able to get MQTT msg from GW when i connect the sensor

    the issue is that i am getting empty payload, and also different IDs for each msg

    also I was not able to set a working controller as i have only MQTT gateway with NodeMCU
    do you know if i can connect to OH? from docs it says you can only connect the serial and the ethernet



  • I am using OpenHAB 2.3 and in my experience OH does not assign node ID to the sensor at presentation.
    You will have to assign node ID manually in each sensor sketch by defining as an example:
    #define MY_NODE_ID 24

    In my setup I connect from the sensor to an MQTT-GW that talks to the MQTT broker.
    Then OH subscribes to the same broker and receives messages. Most people use mosquitto as a local broker, often on the same machine that runs OH.

    OH recently released 2.4 where the MQTT binding is substantially updated so I recommend you read up on that before changing.



  • Hi gad-ofir,

    In addition to OH-Documentation you may find some hints in

    https://forum.mysensors.org/topic/4415/my-final-setup-to-get-mysensors-and-openhab-communicating-via-mqtt

    Part of this thread is dealing with "empty" payloads.


Log in to reply
 

Suggested Topics

11
Online

11.4k
Users

11.1k
Topics

112.7k
Posts