c_cpp esp8266.mqtt.ble.hm10.ino
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp esp8266.mqtt.ble.hm10.ino相关的知识,希望对你有一定的参考价值。
#define MQTT_DEBUG_MODE
#define WIFI_DEBUG_MODE
#include <WiFiConnector.h>
#include <MqttConnector.h>
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <PubSubClient.h>
MqttConnector *mqtt;
WiFiConnector *wifi;
/* MQTT INFO */
#define MQTT_HOST "rabbit.cmmc.ninja"
#define MQTT_PORT 1883
#define PUBLISH_EVERY 20 *1000 // every 15 seconds
/* comment ทิ้งถ้าไม่ส่ username/password */
#define MQTT_USERNAME "nat:video"
#define MQTT_PASSWORD "video"
/* SENSOR INFO */
#define DEVICE_NAME "MARQ-001"
#define PROJECT "MARQ"
#define AUTHOR "Nat Weerawan"
#define BOARD "esp-mini.v2"
#define SENSOR "HM10"
/* WIFI INFO */
#define SSID "NAT.WRTNODE"
#define PASSPHARSE "devicenetwork"
#include "init_wifi.h"
#include "_publish.h"
#include "_receive.h"
#include "init_mqtt.h"
byte byteRead;
void init_hardware()
{
Serial1.begin(115200);
Serial.begin(115200);
delay(10);
Serial.println();
}
void setup()
{
init_hardware();
init_wifi();
init_mqtt();
}
String text = "";
int flag = 0;
void loop()
{
text = "";
while (Serial.available()) {
flag = 1;
byteRead = Serial.read();
//Serial.print((char)byteRead);
text += (char) byteRead;
delay(10); // proof-of-concept
mqtt->loop(wifi);
}
if (flag == 1) {
flag = 0;
mqtt->sync_pub(text);
Serial.print(text);
}
mqtt->loop(wifi);
}
以上是关于c_cpp esp8266.mqtt.ble.hm10.ino的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp ESP8266GCodeSender
c_cpp esp8266-webserver.ino
c_cpp esp8266.tv.ino
c_cpp esp8266oled.ino
c_cpp sprintf.esp8266.ino
c_cpp ESP8266使用Web服务器或MQTT进行ESP-01继电器控制