Skip to content

Instantly share code, notes, and snippets.

View chaeplin's full-sized avatar

chaeplin chaeplin

View GitHub Profile
#define TRIAC_PIN 5
#define ZERO_CROSS_PIN 4
#define DEBOUNCE_TIME 9000 //9ms - 10ms is the pulse period
static uint32_t lastPulse = 0;
static uint16_t period = 5000; //5ms - 50% for each half wave
void ICACHE_RAM_ATTR onTimerISR(){
if(GPIP(TRIAC_PIN)){//OUTPUT is HIGH
GPOC = (1 << TRIAC_PIN);//low
@chaeplin
chaeplin / gateway.ino
Created March 27, 2016 14:08
gateway.ino
// from https://raw.githubusercontent.com/royi1000/ardu-info-center/63df56531a5368c9d195c5effe2d307da26e21a6/gateway/gateway.ino
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
#include <DS1307RTC.h>
#include <Time.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
@chaeplin
chaeplin / Energy_Monitor_Real.ino
Created March 22, 2016 16:12 — forked from whatnick/Energy_Monitor_Real.ino
ESP8266 Energy Monitor Real Power
/*
* This sketch sends ads1115 current sensor data via HTTP POST request to thingspeak server.
* It needs the following libraries to work (besides the esp8266 standard libraries supplied with the IDE):
*
* - https://github.com/adafruit/Adafruit_ADS1X15
*
* designed to run directly on esp8266-01 module, to where it can be uploaded using this marvelous piece of software:
*
* https://github.com/esp8266/Arduino
*
@chaeplin
chaeplin / dht_test3.ino
Last active March 4, 2016 17:29
dht_test3.ino
// CPU 80MHZ, FLASH 4M/1M
/*
*** Sample using esp-01, D16 is connected to RST
*** If DHT22 is powered by a gpio( VCC of DHT22 is connected to a gpio) and OUTPUT of DHT22 is connected to D2, boot will fail.
*** Power off ----> D2 is in LOW( == DHT22 is in LOW) ==> SDIO boot mode.
Temperature and humidity values are each read out the results of the last measurement.
For real-time data that need continuous read twice, we recommend repeatedly to read sensors,
and each read sensor interval is greater than 2 seconds to obtain accuratethe data.
@chaeplin
chaeplin / dht_test2.ino
Created March 4, 2016 10:44
dht_test2.ino
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include "PietteTech_DHT.h"
// ap setting
#include "/usr/local/src/ap_setting.h"
extern "C" {
#include "user_interface.h"
}
@chaeplin
chaeplin / dht22_deepsleep.ino
Last active November 10, 2021 22:17
dht22_deepsleep.ino
// CPU 80MHZ, FLASH 4M/1M
/*
*** Sample using esp-01, D16 is connected to RST
*** If DHT22 is powered by a gpio( VCC of DHT22 is connected to a gpio) and OUTPUT of DHT22 is connected to D2, boot will fail.
*** Power off ----> D2 is in LOW( == DHT22 is in LOW) ==> SDIO boot mode.
Temperature and humidity values are each read out the results of the last measurement.
For real-time data that need continuous read twice, we recommend repeatedly to read sensors,
and each read sensor interval is greater than 2 seconds to obtain accuratethe data.
@chaeplin
chaeplin / requestEvent.ino
Created March 1, 2016 11:15
requestEvent.ino
void requestEvent()
{
if ( m % 2 == 0 ) {
I2C_writeAnything(sensor_data);
} else {
I2C_writeAnything(sensor_data_copy);
}
m++;
}
@chaeplin
chaeplin / hx711.ino
Created February 29, 2016 17:44
hx711.ino
#include "HX711.h"
// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
HX711 scale(4, 5, 128); // parameter "gain" is ommited; the default value 128 is used by the library
void setup() {
Serial.begin(115200);
Serial.println("HX711 Demo");
@chaeplin
chaeplin / wifi_test.ino
Created February 16, 2016 15:31
wifi_test.ino
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "/usr/local/src/ap_setting.h"
extern "C" {
#include "user_interface.h"
}
char* topic = "wifitest";
int test_para = 5000;
@chaeplin
chaeplin / struct_data_size.ino
Created February 5, 2016 00:29
struct data_size
typedef struct {
uint32_t _salt;
uint16_t volt;
int16_t data1;
int16_t data2;
uint8_t devid;
} data;
data sensor_data;