Skip to content

Instantly share code, notes, and snippets.

View chaeplin's full-sized avatar

chaeplin chaeplin

View GitHub Profile
@chaeplin
chaeplin / UdpContext.h
Created November 13, 2015 05:18
esp8266-udp.ino
https://github.com/esp8266/Arduino/blob/342c4ae6fb847bfc787f80b89a2bb888d942dc32/libraries/ESP8266WiFi/src/include/UdpContext.h#L308
private:
void _reserve(size_t size)
{
const size_t pbuf_unit_size = 512;
if (!_tx_buf_head)
{
_tx_buf_head = pbuf_alloc(PBUF_TRANSPORT, pbuf_unit_size, PBUF_RAM);
@chaeplin
chaeplin / mqtt_test.ino
Created November 15, 2015 19:06
mqtt_test.ino
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "/usr/local/src/ap_setting.h"
// Update these with values suitable for your network.
char* topic = "/30/Status/MQTT";
char* subtopic = "inTopic";
@chaeplin
chaeplin / ESP8266WiFi.ino
Last active November 17, 2015 18:48
ESP8266WiFi.ino
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "/usr/local/src/ap_setting.h"
// Update these with values suitable for your network.
/*
char* topic = "/30/Status/MQTT";
char* subtopic = "inTopic";
@chaeplin
chaeplin / analogRead.ino
Created November 28, 2015 21:53
esp8266 analogRead
int sampleI;
int Number_of_Samples;
int sumI;
void setup()
{
Serial.begin(115200);
sampleI = 0;
sumI = 0;
Number_of_Samples = 1000;
@chaeplin
chaeplin / Serial.test.ino
Created December 1, 2015 19:27
Serial.test
int testpin1 = 5;
void setup() {
pinMode(testpin1, OUTPUT);
}
void loop() {
Serial.begin(115200);
digitalWrite(testpin1, LOW);
delay(2000);
@chaeplin
chaeplin / receiver.ino
Created December 14, 2015 03:17 — forked from rlogiacco/receiver.ino
nRF24 multiple transmitters
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int senderId;
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
//Contacts from the radio to connect NRF24L01 pinamnam -> Arduino
@chaeplin
chaeplin / ESP8266 Code (RX node)
Created December 18, 2015 00:27 — forked from crcastle/ESP8266 Code (RX node)
Trying to use NRF24L01+ on ESP8266, using the ESP8266 as MCU (i.e. not an Arduino or ATmega328). See https://github.com/esp8266/Arduino for details on initial setup of ESP8266 as Arduino-compatible MCU. The serial output below does not show expected messages: a) the full output shows up all at once then stops dead and b) the values for _salt, vo…
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define DEVICE_ID 2
#define CHANNEL 1 //MAX 127
RF24 radio(15, 15); // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
// Topology
const uint64_t pipes[2] = { 0xFFFFFFFFFFLL, 0xCCCCCCCCCCLL };
@chaeplin
chaeplin / WPA2 -EAP-TLS.ino
Last active January 6, 2022 13:50
WPA2 -EAP-TLS.ino
/*
WPA2-ENT EAP-TLS
based on joostd's code : https://github.com/joostd/esp8266-eduroam
https://github.com/joostd/esp8266-eduroam/blob/master/gen_cert.sh
wifi_station_set_cert_key
Function: Set certificate and private key for connecting to WPA2-ENTERPRISE AP.
Note:
• Connecting to WPA2-ENTERPRISE AP needs more than 26 KB memory, please ensure enough space (system_get_free_heap_size).
@chaeplin
chaeplin / mqtt-tls.ino
Last active January 10, 2022 01:59
mqtt-tls.ino
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "/usr/local/src/ap_setting.h"
#define DEBUG_PRINT 1
@chaeplin
chaeplin / esp8266_rtc_mem_test.ino
Last active March 17, 2017 22:51
esp8266_rtc_mem_test.ino
/*
system_rtc_mem_write
Function:
During deep sleep, only RTC still working, so maybe we need to save some user data in RTC memory.
Only user data area can be used by user.
|<--------system data--------->|<-----------------user data--------------->|
| 256 bytes | 512 bytes |
Note:
RTC memory is 4 bytes aligned for read and write operations. Parameter des_addr means block number(4 bytes per block).