Esp8266 gateway with RFM69 433



  • Hi guys!

    I'm new here, and I have no working node from mysensors, so I decided to get start with it. The first step would be to build a gateway, but at this point I already stuck.

    I wannna build the gateway from a Wemos D1 mini, this version:

    https://www.aliexpress.com/item/Wemos-D1-Mini-V3-0-0-WIFI-Internet-of-Things-Development-Board-Based-ESP8266-CH340-CH340G/32863498073.html?spm=a2g0s.9042311.0.0.13a74c4dyadZID

    and RFM69HW. The wireing is based on this:

    https://www.mysensors.org/build/connect_radio#rfm6995-&-esp8266

    The arduino IDE enviorment is working, and I try to compile this 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-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_RADIO_RFM69
    #define MY_RFM69_FREQUENCY RFM69_433MHZ // Set your frequency here
    #define MY_IS_RFM69HW // Omit if your RFM is not "H"
    #define MY_RFM69_IRQ_PIN D1
    #define MY_RFM69_IRQ_NUM MY_RFM69_IRQ_PIN
    #define MY_RFM69_CS_PIN D8 // NSS. Use MY_RFM69_SPI_CS for older versions (before 2.2.0)
    
    #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 "mqtt_user"
    #define MY_MQTT_PASSWORD "xxxxxxxx"
    
    // Set WIFI SSID and password
    #define MY_WIFI_SSID "SSID"
    #define MY_WIFI_PASSWORD "xxxxxxxxx"
    
    // 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, 30, 2
    
    //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 D2  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  D3  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  D4  // 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
    }
    

    The sketch is compiled OK, and the gateway is started, and I see in the router log, that is connected to my wifi, but that's all. It is not connect to my mqtt broker, but it should, and based on the serial log the radio doesnt start eiter...

    serial log is only this:

    MCO:BGN:INIT GW,CP=RRNGE---,REL=255,VER=2.3.1
    119 TSF:LRT:OK
    16:10:32.200 -> 135 TSM:INIT
    16:10:32.200 -> 148 TSF:WUR:MS=0

    After 2 restart out of 10 probe I see the wifi connection in the serial log but not always.

    What should I do? What am doing wrong? I'm a little dissapointed after 3 days of playing....


  • Contest Winner

    @quby Looks to me as if the radio is not correctly connected. Because I'd expect more lines in the serial log. You could check:

    • Whether wiring is correct.
    • Whether the radio can get the power it needs

    In most cases it's either one of these. But no expert on the MQTT gateway. Also share a photo of how you've connected everything. Because people can't help if they can't see what you're ding.



  • 2_1546706672234_IMG_20190105_172531.jpg 1_1546706672234_IMG_20190105_172457.jpg 0_1546706672233_IMG_20190105_172451.jpg

    Hopefully you can see the wireing on the picture. I used as the same wire coloring as on the coloring page!
    I can measure 3,59V between the red and the black wire on the radio chip. The esp board get the power from my computers usb port.



  • I have this setup. Try

    #define MY_RFM69_IRQ_PIN D2
    #define MY_RFM69_IRQ_NUM MY_RFM69_IRQ_PIN
    #define MY_RFM69_CS_PIN D8
    

    Copy the wiring from here (or better still just buy some PCB's)

    https://www.openhardware.io/view/277/ESP8266-RFM69HW-gateway-with-dipole-antenna



  • I tried the same type of connection, but I have a lot of problems because the power is not enough for the esp8266 and rfm69 at the same time!
    You should have a separate power supply for the radio.



  • @canossa That's useful to know, I am finding it to be hit and miss with this setup too. Seem to randomly lose messages going back to my MQTT gateway (most annoying for door triggers!). i'll try adding in an additional power supply to the 3.3v line and see if that helps out with stability.


Log in to reply
 

Suggested Topics

4
Online

11.4k
Users

11.1k
Topics

112.7k
Posts