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
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
@kakopappa
kakopappa / BMP180.ino
Created September 21, 2023 08:03
BMP180
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp; // Default I2C
void setup() {
Serial.begin(9600);
bool status = bmp.begin();
// Uncomment the following line to enable serial debug output
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
@kakopappa
kakopappa / DHTx.ino
Created September 21, 2023 08:00
DHT11 and DHT22, AM2302, RHT03
#include "DHT.h" // https://github.com/markruys/arduino-DHT Support for DHT11 and DHT22, AM2302, RHT03
#if defined(ESP8266)
#define DHT_PIN D1
#elif defined(ESP32)
#define DHT_PIN 16
#endif
float temperature;
float humidity;
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
@kakopappa
kakopappa / DS18B20.ino
Created September 21, 2023 07:57
DS18B20
#if defined(ESP8266)
#define DS18B20_PIN D5
#elif defined(ESP32)
#define DS18B20_PIN 16
#endif
#include <OneWire.h>
#include <DallasTemperature.h> // Supports DS18B20 or DS1822, DS1820, MAX31820, MAX31850
OneWire oneWire(DS18B20_PIN);
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
@kakopappa
kakopappa / LM335.ino
Created September 21, 2023 07:52
LM335
#if defined(ESP8266)
#define LM_PIN A0
#elif defined(ESP32)
#define LM_PIN 36
#endif
#define ADC_VREF_mV 5000.0 // 5000 is the voltage provided by MCU. If you connect to 3V change to 3000
#define ADC_RESOLUTION 4096.0
void setup() {
@kakopappa
kakopappa / rate-limiting-queue.js
Created August 23, 2023 02:32 — forked from samsonjs/rate-limiting-queue.js
Basic rate limiting queue for node
//// Usage
var queue = createMessageQueue({ messagesPerMinute: 60 })
queue.on('message', function(msg) {
console.log('message: ' + JSON.stringify(msg, null, 2))
})
queue.enqueue({ to: 'avian', from: 'sjs', body: 'cool story bro' })
@kakopappa
kakopappa / install_go_pi.sh
Created June 6, 2023 10:50 — forked from pcgeek86/install_go_pi.sh
Install Go Lang on Raspberry Pi
cd $HOME
FileName='go1.13.4.linux-armv6l.tar.gz'
wget https://dl.google.com/go/$FileName
sudo tar -C /usr/local -xvf $FileName
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc