Skip to content

Instantly share code, notes, and snippets.

@Ajak58a
Ajak58a / ESP32-Wakeup-Alarm.ino
Created November 29, 2023 18:45
ESP32-Wakeup-Alarm
#include <BluetoothSerial.h>
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#include <SPI.h>
#include <Ethernet.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177); // Enter the IP of Ethernet shield
IPAddress myDns(192, 168, 1, 1);
// Initialize the Ethernet client library
EthernetClient client;
#include <SPI.h>
#include <Ethernet.h>
// MAC address for your Ethernet shield (this is a placeholder, replace with your shield's MAC address)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Your network settings (if you want to set a static IP)
IPAddress ip(192, 168, 1, 177); // IP address for the Ethernet shield
IPAddress myDns(192, 168, 1, 1);
@Ajak58a
Ajak58a / ssd1306.py
Created November 7, 2023 16:33
MicroPython SSD1306 OLED driver for ESP8266 and ESP32
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import framebuf
# register definitions
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xA4)
SET_NORM_INV = const(0xA6)
@Ajak58a
Ajak58a / main.py
Created November 7, 2023 16:32
MicroPython SSD1306 OLED driver for ESP8266 and ESP32
from machine import Pin, SoftSPI
import ssd1306
from time import sleep
spi = SoftSPI(baudrate=500000, polarity=1, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
dc = Pin(4) # data/command
rst = Pin(5) # reset
cs = Pin(15) # chip select, some modules do not have a pin for this
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
from micropython import const
import framebuf
# register definitions
SET_CONTRAST = const(0x81)
SET_ENTIRE_ON = const(0xA4)
SET_NORM_INV = const(0xA6)
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
const char* ssid = "replacewithyourSSID";
const char* password = "replacewithyourNetworkPassword";
const char* API_KEY = "replacewithyourWeatherAPIkey";
long sunriseTimeMinutes;
long localTimeMinutes;
@Ajak58a
Ajak58a / Arduino_IFTTT_Email-Notification.ino
Created November 6, 2023 20:00
How to send email notifications from Arudino ESP through IFTTT
#include <ESP8266WiFi.h>
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* server = "maker.ifttt.com";
const char* IFTTT_KEY = "YOUR_IFTTT_KEY";
const char* EVENT_NAME = "send_email_from_arduino";
const int inputPin = 5;
WiFiClient client;
@Ajak58a
Ajak58a / main.py
Created July 17, 2023 19:18
WiFi Manager main
import WiFiManager
from time import sleep
import machine
try:
import usocket as socket
except:
import socket
led = machine.Pin(2, machine.Pin.OUT)
@Ajak58a
Ajak58a / WiFiManager.py
Created July 17, 2023 19:16
WiFi Manager
import network
import socket
import ure
import time
ap_ssid = "WifiManager"
ap_password = "tayfunulu"
ap_authmode = 3 # WPA2
NETWORK_PROFILES = 'wifi.dat'