Skip to content

Instantly share code, notes, and snippets.

View kakopappa's full-sized avatar
🏠
Working from home

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@kakopappa
kakopappa / encryption.py
Created October 17, 2024 04:25
XSalsa20-Poly1305 Encryption Example
import nacl.utils
from nacl.public import PrivateKey, Box
from nacl.secret import SecretBox
import nacl.bindings
def generate_keypair():
private_key = PrivateKey.generate()
public_key = private_key.public_key
return private_key, public_key
@kakopappa
kakopappa / cat-feeder-esp32.ino
Created August 21, 2024 01:18
cat-feeder-esp32.ino
#include "freeRTOS\freeRTOS.h"
#include "freeRTOS\task.h"
#include <ESP32Servo.h>
#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
@kakopappa
kakopappa / sinricpro-tv.ino
Last active May 31, 2024 06:12
sinricpro-tv
// #define ENABLE_DEBUG
#define SINRICPRO_NOSSL
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
@kakopappa
kakopappa / ChangeWiFI.ino
Created May 5, 2024 04:41
How to change the WIFI
#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#if defined(ESP8266)
{
"name": "Water Level Indicator",
"description": "Water Level Indicator",
"deviceTypeId": "621b9648f728ec974aac62f2",
"capabilities": [
{
"id": "5ff0b45f994fd31b7d5e89c2",
"range": {
"instanceId": "rangeInstance1",
"locale": "en-US",
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#ifdef ESP8266
@kakopappa
kakopappa / FOR_i.ino
Created November 26, 2023 14:12
Simplified for loop for Arduino
#define FOR_i(from, to) for(int i = (from); i < (to); i++)
FOR_i(1, 4) {
// do something
}
#ifndef _GASSENSOR_H_
#define _GASSENSOR_H_
#include <SinricProDevice.h>
#include <Capabilities/ModeController.h>
#include <Capabilities/PushNotification.h>
class GasSensor
: public SinricProDevice
, public ModeController<GasSensor>
{
"name": "Gas Sensor",
"description": "Gas Sensor",
"deviceTypeId": "654d7ef928f14e9ac82ad57d",
"capabilities": [
{
"id": "5ff0b41b994fd31b7d5e8961",
"mode": {
"instanceId": "modeInstance1",
"locale": "en-US",
#if defined(ESP8266)
const int adcPin = A0;
#elif defined(ESP32)
const int adcPin = 34;
#elif defined(ARDUINO_ARCH_RP2040)
const int adcPin = 26;
#endif
int sensorVal;