Skip to content

Instantly share code, notes, and snippets.

@gresan-gits
gresan-gits / Built_in.h
Created February 3, 2020 09:21
CCS C RC522 RFID
//#use spi(FORCE_HW,master,baud = 10000000, BITS=8,MSB_FIRST, stream = RFID, ENABLE_ACTIVE=0)// uses hardware SPI and gives this stream the name SPI_STREAM
//MF522 Command word
#define PCD_IDLE 0x00 //NO action; Cancel the current command
#define PCD_AUTHENT 0x0E //Authentication Key
#define PCD_RECEIVE 0x08 //Receive Data
#define PCD_TRANSMIT 0x04 //Transmit data
#define PCD_TRANSCEIVE 0x0C //Transmit and receive data,
#define PCD_RESETPHASE 0x0F //Reset
#define PCD_CALCCRC 0x03 //CRC Calculate
// Mifare_One card command word
@gresan-gits
gresan-gits / main.c
Created February 3, 2020 09:46
CCS MPU6050
#include <ex_usb_common.h>
#define MPU_SDA PIN_E0
#define MPU_SCL PIN_E1
#use I2C(master, sda=MPU_SDA, scl=MPU_SCL)
#use TIMER(TIMER=1, TICK=1ms, BITS=16, NOISR)
#define RAD_TO_DEG 180/PI
#define LCD_ENABLE_PIN PIN_D2
#define LCD_RS_PIN PIN_D0
#define LCD_RW_PIN PIN_D1
#define LCD_DATA4 PIN_D4
@gresan-gits
gresan-gits / code.ino
Created February 3, 2020 14:23
IOT ESP 16 Relay
//**************************************************************//
// Name : 16Relay control via MQTT //
// Author : Son Bui-Mualinhkien.vn //
// Date : 23 March, 2016 //
// Version : 1.0 //
// Notes : Code for using a 74HC595 Shift Register //
// : Change Maximum packet size on pubsubclient lib to 512 bytes
// : https://play.google.com/store/apps/details?id=org.ngoinhaso.app.mqtthomecontrol //App UI
//**************************************************************//
@gresan-gits
gresan-gits / code.ino
Created February 10, 2020 09:51
ESP32 PWM
const int ledPin = 16;
const int ledPin2 = 17;
const int ledPin3 = 5;
// setting PWM properties
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;
void setup() {
@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
@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 / 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 / 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 / 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 / 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