Skip to content

Instantly share code, notes, and snippets.

/*
* This sketch shows the WiFi event usage
*
* In this example you can receive and process below events.
* Refer to ESP8266WiFiType.h
*
typedef enum {
WIFI_EVENT_STAMODE_CONNECTED = 0,
WIFI_EVENT_STAMODE_DISCONNECTED,
WIFI_EVENT_STAMODE_AUTHMODE_CHANGE,
/*
Udp NTP Client
Get the time from a Network Time Protocol (NTP) time server
Demonstrates use of UDP sendPacket and ReceivePacket
For more on NTP time servers and the messages needed to communicate with them,
see http://en.wikipedia.org/wiki/Network_Time_Protocol
created 4 Sep 2010
@prasertsakd
prasertsakd / thinkspeak_rest.ino
Created April 14, 2015 06:53
Thinkspeak Post Data
#include <ESP8266WiFi.h>
const char* ssid = "-----------";
const char* password = "-----------";
// ThingSpeak Settings
char thingSpeakAddress[] = "api.thingspeak.com";
String writeAPIKey = "----------------------";
const int updateThingSpeakInterval = 15 * 1000; // Time interval in milliseconds to update ThingSpeak (number of seconds * 1000 = interval)
#define BUILDIN_LED 2
#define ledPIN1 23
#define ledPIN2 22
// ----------------------------------------------------------------------------------
void first_task(void *pvParameter){
/* Configure the IOMUX register for pad BLINK_GPIO (some pads are
muxed to GPIO on reset already, but some default to other
functions and need to be switched to GPIO. Consult the
Technical Reference for a list of pads and their default
const int ledPin = 2; // the number of the LED pin
const int threshold = 40; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
void setup() {
// put your setup code here, to run once:
//pinMode(ledPin, OUTPUT);
Serial.begin(115200);
touchAttachInterrupt(T0 , click , threshold );
#include <PN532.h>
#include "Keyboard.h"
//#define SCK 13
//#define MOSI 11
//#define SS 10
//#define MISO 12
#define SCK 15
#define MOSI 16
#include <stdio.h>
void app_main() {
printf("Hello world\n");
}
@prasertsakd
prasertsakd / flash_mega16u2.bat
Last active March 3, 2017 15:13
for reflash mega16u2 to usbserial use avrdude
@echo off
set arduino_path=c:\arduino-1.6.12
set firmware=Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex
set avrdude.exe=%arduino_path%\hardware\tools\avr\bin\avrdude.exe
set avrdude.conf=%arduino_path%\hardware\tools\avr\etc\avrdude.conf
%avrdude_path% -c usbtiny -p m16u2 -C %avrdude_conf% -F -D -U flash:w:%firmware% -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
@prasertsakd
prasertsakd / check_mega16u2.bat
Last active March 3, 2017 15:37
read chip id and verify
@echo off
set arduino_path=c:\arduino-1.6.12
set avrdude.exe=%arduino_path%\hardware\tools\avr\bin\avrdude.exe
set avrdude.conf=%arduino_path%\hardware\tools\avr\etc\avrdude.conf
%avrdude_path% -c usbtiny -v -p m16u2 -C %avrdude_conf%
##############################################################
# NodeWifi chip has built-in 1MB flash
nodewifi.name=NodeWifi
nodewifi.upload.tool=esptool
nodewifi.upload.speed=115200
nodewifi.upload.resetmethod=nodemcu
nodewifi.upload.maximum_size=434160
nodewifi.upload.maximum_data_size=81920