Skip to content

Instantly share code, notes, and snippets.

@gresan-gits
gresan-gits / Websocket.ino
Last active March 8, 2020 07:03
ESPAsyncWebserver
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
const char* ssid = "Xuong May Gia Si";//"yourNetworkName";
const char* password = "123456789";// "yourNetworkPassword";
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
@gresan-gits
gresan-gits / ESP32MQTT.ino
Last active February 3, 2021 14:55
lwMQTT testing on ESP32 with Arduino
#include <WiFi.h>
#include <MQTT.h>
const char ssid[] = "ssid";
const char password[] = "pass";
WiFiClient net;
MQTTClient client;
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
@gresan-gits
gresan-gits / Function.ino
Created April 14, 2020 15:42
RAK811 RUI v3.0.0.12.H.T
String prepairData() {
int temperatureAdc = analogRead(SENSOR);
byte adcH = (temperatureAdc & 0xFF00) >> 8;
byte adcL = (temperatureAdc & 0x00FF);
byte inputstate = digitalRead(INP);
DebugSerial.print("<Adc:");
DebugSerial.print(temperatureAdc);
DebugSerial.print(">");
DebugSerial.print("<input:");