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
#if defined(ESP8266)
const int trigPin = 12;
const int echoPin = 14;
#elif defined(ESP32)
const int trigPin = 5;
const int echoPin = 18;
#elif defined(ARDUINO_ARCH_RP2040)
const int trigPin = 15;
const int echoPin = 14;
#endif
#ifndef _WATERLEVELINDICATOR_H_
#define _WATERLEVELINDICATOR_H_
#include <SinricProDevice.h>
#include <Capabilities/RangeController.h>
#include <Capabilities/PushNotification.h>
class WaterLevelIndicator
: public SinricProDevice
, public RangeController<WaterLevelIndicator>
/*
* If you encounter any issues:
* - check the readme.md at https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md
* - ensure all dependent libraries are installed
* - see https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#arduinoide
* - see https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/README.md#dependencies
* - open serial monitor and check whats happening
* - check full user documentation at https://sinricpro.github.io/esp8266-esp32-sdk
* - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one
*/
{
"name": "Capacitive Soil Moisture Sensor",
"description": "Capacitive Soil Moisture Sensor",
"deviceTypeId": "6522320f2b090cc39f39fb32",
"capabilities": [
{
"id": "5ff0b41b994fd31b7d5e8961",
"mode": {
"instanceId": "modeInstance1",
"locale": "en-US",
#ifndef _CAPACITIVESOILMOISTURESENSOR_H_
#define _CAPACITIVESOILMOISTURESENSOR_H_
#include <SinricProDevice.h>
#include <Capabilities/ModeController.h>
#include <Capabilities/RangeController.h>
#include <Capabilities/PushNotification.h>
class CapacitiveSoilMoistureSensor
: public SinricProDevice
// 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>
// Red, green, and blue pins for PWM control
const int ledR = 14;
const int ledG = 12;
const int bluePin = 27;
uint8_t color = 0; // a value from 0 to 255 representing the hue
uint32_t R, G, B; // the Red Green and Blue color components
uint8_t brightness = 255; // 255 is maximum brightness, but can be changed. Might need 256 for common anode to fully turn off.
bool invert = false;
#include <RBDdimmer.h> //https://github.com/RobotDynOfficial/RBDDimmer
const int ZC_PIN = 0;
const int PWM_PIN = 2;
int MIN_POWER = 0;
int MAX_POWER = 80;
int POWER_STEP = 2;
int power = 0;
//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>
const int pwmPin = 16; // 16 corresponds to GPIO16 of ESP32
// setting PWM properties
const int freq = 1000; // 1KHz
const int ledChannel = 0;
const int resolution = 8;
void setup(){
ledcSetup(ledChannel, freq, resolution);
ledcAttachPin(pwmPin, ledChannel);