MySensors Library & Examples  2.3.2
GatewayESP32MQTTClient.ino
1 /*
2  * The MySensors Arduino library handles the wireless radio link and protocol
3  * between your home built sensors/actuators and HA controller of choice.
4  * The sensors forms a self healing radio network with optional repeaters. Each
5  * repeater and gateway builds a routing tables in EEPROM which keeps track of the
6  * network topology allowing messages to be routed to nodes.
7  *
8  * Created by Henrik Ekblad <[email protected]>
9  * Copyright (C) 2013-2019 Sensnology AB
10  * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11  *
12  * Documentation: http://www.mysensors.org
13  * Support Forum: http://forum.mysensors.org
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * version 2 as published by the Free Software Foundation.
18  *
19  *******************************
20  *
21  * REVISION HISTORY
22  * Version 1.0 - tekka
23  *
24  * DESCRIPTION
25  * The ESP32 gateway sends data received from sensors to the WiFi link.
26  * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
27  *
28  * Make sure to fill in your ssid and WiFi password below.
29  */
30 
31 // Enable debug prints to serial monitor
32 #define MY_DEBUG
33 
34 // Enables and select radio type (if attached)
35 #define MY_RADIO_RF24
36 //#define MY_RADIO_RFM69
37 //#define MY_RADIO_RFM95
38 
39 #define MY_GATEWAY_MQTT_CLIENT
40 #define MY_GATEWAY_ESP32
41 
42 // Set this node's subscribe and publish topic prefix
43 #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
44 #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
45 
46 // Set MQTT client id
47 #define MY_MQTT_CLIENT_ID "mysensors-1"
48 
49 // Enable these if your MQTT broker requires usenrame/password
50 //#define MY_MQTT_USER "username"
51 //#define MY_MQTT_PASSWORD "password"
52 
53 // Set WIFI SSID and password
54 #define MY_WIFI_SSID "MySSID"
55 #define MY_WIFI_PASSWORD "MyVerySecretPassword"
56 
57 // Set the hostname for the WiFi Client. This is the hostname
58 // passed to the DHCP server if not static.
59 #define MY_HOSTNAME "ESP32_MQTT_GW"
60 
61 // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
62 //#define MY_IP_ADDRESS 192,168,178,87
63 
64 // If using static ip you can define Gateway and Subnet address as well
65 //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
66 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
67 
68 // MQTT broker ip address.
69 #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1, 5
70 
71 // The MQTT broker port to to open
72 #define MY_PORT 1883
73 
74 #include <MySensors.h>
75 
76 void setup()
77 {
78  // Setup locally attached sensors
79 }
80 
82 {
83  // Present locally attached sensors here
84 }
85 
86 void loop()
87 {
88  // Send locally attech sensors data here
89 }
90 
loop
void loop()
Main loop.
Definition: GatewayESP32MQTTClient.ino:86
presentation
void presentation()
Node presentation.
Definition: GatewayESP32MQTTClient.ino:81
setup
void setup()
Called after node initialises but before main loop.
Definition: GatewayESP32MQTTClient.ino:76
MySensors.h
API declaration for MySensors.