请选择 进入手机版 | 继续访问电脑版

『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 7995|回复: 14

MYNRF24 网关部分使用介绍及入门

[复制链接]

14

主题

267

帖子

1639

积分

论坛技术达人

积分
1639
金钱
1352
HASS币
40

教程狂人

发表于 2019-1-26 00:55:15 | 显示全部楼层 |阅读模式
本帖最后由 huex 于 2019-1-26 00:55 编辑

MYNRF24 网关介绍部分
@(原创请勿转载!)

2019.1.22更新增加编译后的固件,添加WiFiManager完成web配网MQTT等!二楼固件及刷入工具!


mysensor网关,是主要的数据处理中枢,网关类型也比较多,支持串行数据usb接口,支持以太网接口,支持MQTT,并且额外官方还制作出sam21的高速处理以太网或者usb数据网关,具体参考:https://www.mysensors.org/build/select_gateway

  本次主要介绍MQTT网关,MQTT又可以使用RS485,ESP8266,RJ45 W5100介质,目前我已经前期做过几片wemmos mini d1的pcb,本文主要方便本次PCB用户,由于前期只做了个样数量只有几片,所以本次按顺序无偿赠送给前几位用户,实在抱歉,网关工作不是我目前 的主要目标,后期稳定使用后,我会再去设计一款支持sma天线的网关工作板并提供PCB文件。

脚位链接

pcb模块

  pcb针对wemos mini d1设计,支持nrf24l01+,rfm69,nrf24l01+pla,板载ams1117-3.3脚,默认使用nrf24l01+无需增压转,可以正面添加4.7uf电容一颗
  enter image description here
  拿到pcb板后请注意脚位与你的wemos mini是否一致,由于淘宝nodemcu wemos mini与wemos mini 是出入的
  enter image description here
  enter image description here

务必注意脚位方向,否则损坏NRF24L01模块

网关模块

  请按下图与esp8266链接上。
  enter image description here

网关代码

MQTT网关


/*
 * 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 <mailto:[email protected]>
 * 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   //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"    //MQTT 网关发送主题
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"   //MQTT 网关接收主题

// Set MQTT client id
#define MY_MQTT_CLIENT_ID "mysensors-1"                 //MQTT 网关客户端ID

// Enable these if your MQTT broker requires username/password
#define MY_MQTT_USER "username"                //MQTT 网关用户验证 没有请注释
#define MY_MQTT_PASSWORD "password"                //MQTT 用户密码 同上没有请注释

// Set WIFI SSID and password
#define MY_WIFI_SSID "MySSID"        //wifi名称
#define MY_WIFI_PASSWORD "MyVerySecretPassword"        //wifi密码

//以下是静态设置,建议网关使用固定IP,路由或者以下固定都行
// 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 网关地址
//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 //MQTT 网关端口

//以下是授权信任设置 默认不用更改
// 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 &lt;ESP8266WiFi.h&gt;
#include &lt;MySensors.h&gt;

void setup()
{
    // Setup locally attached sensors
}

void presentation()
{
    // Present locally attached sensors here
}

void loop()
{
    // Send locally attached sensors data here
}

此文件在ardunio 示例里面是存在的,这里重新啰嗦一下

端口网关

  ESP8266还可以充当UDP数据网关,官方有对应的软件可以使用,能详细查看日志和node数据,支持多种功能
  enter image description here
下载链接:
ardunio请打开示例
enter image description here





评分

参与人数 1金钱 +20 HASS币 +20 收起 理由
+ 20 + 20 膜拜大神!

查看全部评分

回复

使用道具 举报

14

主题

267

帖子

1639

积分

论坛技术达人

积分
1639
金钱
1352
HASS币
40

教程狂人

 楼主| 发表于 2019-1-26 00:55:16 | 显示全部楼层
刷机工具: flash.zip (21.83 KB, 下载次数: 10)

固件链接: GatewayESP8266MQTTClient.ino.d1_mini.bin (419.88 KB, 下载次数: 11)
回复

使用道具 举报

2

主题

316

帖子

1620

积分

金牌会员

Rank: 6Rank: 6

积分
1620
金钱
1304
HASS币
0
发表于 2019-1-26 05:43:29 | 显示全部楼层
谢谢楼主分享!!!
回复

使用道具 举报

8

主题

848

帖子

5047

积分

论坛元老

Rank: 8Rank: 8

积分
5047
金钱
4199
HASS币
0
发表于 2019-1-26 07:48:41 | 显示全部楼层
楼主6666666
回复

使用道具 举报

175

主题

2956

帖子

7555

积分

超级版主

我就是六神

Rank: 8Rank: 8

积分
7555
金钱
4574
HASS币
398

活跃会员教程狂人灌水之王

QQ
发表于 2019-1-26 09:08:33 | 显示全部楼层
看天书一样  膜拜楼主~~
回复

使用道具 举报

22

主题

519

帖子

1608

积分

金牌会员

Rank: 6Rank: 6

积分
1608
金钱
1089
HASS币
10
发表于 2019-1-26 15:00:56 | 显示全部楼层
楼主威武啊
回复

使用道具 举报

13

主题

401

帖子

2743

积分

金牌会员

Rank: 6Rank: 6

积分
2743
金钱
2342
HASS币
0
发表于 2019-1-26 16:43:10 | 显示全部楼层
感谢分享,虽然不知道说的是啥
回复

使用道具 举报

8

主题

657

帖子

4141

积分

论坛元老

Rank: 8Rank: 8

积分
4141
金钱
3479
HASS币
0
QQ
发表于 2019-1-26 21:33:44 | 显示全部楼层
学习学习
回复

使用道具 举报

4

主题

103

帖子

1631

积分

金牌会员

Rank: 6Rank: 6

积分
1631
金钱
1523
HASS币
20
发表于 2019-1-26 22:41:14 | 显示全部楼层
谢谢楼主分享,能给个pcb我吗?
回复

使用道具 举报

6

主题

272

帖子

3897

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3897
金钱
3620
HASS币
0
发表于 2019-1-27 08:34:45 | 显示全部楼层
MySensors是一个比较早的“智能开源硬件”项目,相关的硬件DIY可以在openhardware.io发布
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-3-29 01:10 , Processed in 0.090979 second(s), 37 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表