Skip to content

Instantly share code, notes, and snippets.

@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:");
#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 / 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;
@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 / ESP32_Async_Web_Server.ino
Created March 4, 2020 04:49
ESP32 AsyncWebserver
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include "SPIFFS.h"
// Replace with your network credentials
const char* ssid = "Xuong May Tran Bam";
const char* password = "123456789";
// Set LED GPIO
@gresan-gits
gresan-gits / Print.ino
Last active March 3, 2020 04:55
AsyncWebserverRespnse
AsyncResponseStream *response = request->beginResponseStream("text/html");
response->addHeader("Server","ESP Async Web Server");
response->printf("<!DOCTYPE html><html><head><title>Webpage at %s</title></head><body>", request->url().c_str());
response->print("<h2>Hello ");
response->print(request->client()->remoteIP());
response->print("</h2>");
response->print("<h3>General</h3>");
response->print("<ul>");
@gresan-gits
gresan-gits / DemoHTTPGET.ino
Last active March 1, 2020 05:39
AsyncWebserver
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPass";
AsyncWebServer server(80);
void setup(){
Serial.begin(115200);
@gresan-gits
gresan-gits / led.html
Last active February 26, 2020 05:01
ESP32 Webcontrol
<!DOCTYPE html> <html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>LED Control</title>
<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}
body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}
.button {display: block;width: 80px;background-color: #3498db;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}
.button-on {background-color: #3498db;}
.button-on:active {background-color: #2980b9;}
.button-off {background-color: #34495e;}
.button-off:active {background-color: #2c3e50;}
@gresan-gits
gresan-gits / code.ino
Created February 16, 2020 09:50
ESP32 GET IP
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Xuong May Tran Bam";
const char* password = "123456789";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
@gresan-gits
gresan-gits / code.ino
Created February 14, 2020 10:23
ESP32 ADC Arduino
#include "esp_system.h"
#include "esp_adc_cal.h"
#include "driver/adc.h"
#define ADC_BAT_PIN 34
#define NO_OF_SAMPLES 64 //Multisampling
#define REF_VOLTAGE 1100
#define LIN_COEFF_A_SCALE 65536