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 / BME280.ino
Created September 21, 2023 08:04
BME280
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // Default I2C
void setup() {
Serial.begin(9600);
#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() {