Skip to content

Instantly share code, notes, and snippets.

@igrr
igrr / esp.ksy
Created November 25, 2021 20:19
Kaitai Struct description of ESP binary image format (starting from ESP32)
# Try it out by opening https://ide.kaitai.io/ and copying this file there
# Based on an article by @angelcarve about ESP8266 binary image parsing with Kaitai Struct:
# https://carvesystems.com/news/parsing-binaries-with-kaitai-struct/
meta:
id: esp
file-extension: bin
endian: le
seq:
@igrr
igrr / esp8266_pubsubclient.ino
Created January 6, 2015 23:44
PubSubClient sample for ESP8266 Arduino
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
const char* ssid = ".................";
const char* password = "................";
char* topic = "esp8266_arduino_out";
char* server = "iot.eclipse.org";
@igrr
igrr / ulp_isr_example_main.c
Last active January 26, 2024 09:47
ESP32 ULP ISR example
#include <stdio.h>
#include <unistd.h>
#include "soc/rtc_cntl_reg.h"
#include "esp32/ulp.h"
#include "driver/rtc_cntl.h"
#include "esp_log.h"
#include "ulp_main.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
I (437) example: Opening file
I (457) example: File written
I (467) example: Renaming file
I (467) example: Reading file
I (467) example: Read from file: 'Hello SU04G!'
This line will be written into the log file, not to UART
@igrr
igrr / sleep_from_wake_stub_example.c
Last active November 25, 2023 21:27
ESP32 ESP-IDF example illustrating how to go back to sleep from deep sleep wake stub
/*
* This sample illustrates how to go back to deep sleep from the
* deep sleep wake stub.
*
* Consider the use case of counting pulses from an external sensor,
* where the pulses arrive at a relatively slow rate.
*
* ESP32 is configured to go into deep sleep mode, and wake up from
* a GPIO pin connected to the external pulse source.
* Once the pulse arrives, ESP32 wakes up from deep sleep and runs
@igrr
igrr / AboutPage.h
Created October 6, 2015 12:29
Custom ESP8266WebServer RequestHandler sample
#ifndef ABOUT_PAGE_H
#define ABOUT_PAGE_H
#include <ESP8266WebServer.h>
class AboutPage : public RequestHandler {
public:
AboutPage(const char* uri = "about")
: _uri(uri)
{
@igrr
igrr / ota_server.py
Created June 11, 2015 15:31
ESP8266 Arduino OTA test script
#!/usr/bin/python
#
# this script will push an OTA update to the ESP
#
# use it like: python ota_server.py <ESP_IP_address> <sketch.bin>
#
# on the ESP side you need code like this: https://gist.github.com/igrr/43d5c52328e955bb6b09 to handle the update
#
import socket
@igrr
igrr / esp32s3-psram-alloc-exec.c
Created July 10, 2023 17:18
Copy a function into PSRAM on ESP32-S3 and execute it
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <string.h>
#include "esp_err.h"
#include "esp_log.h"
@igrr
igrr / newlib-esp32-configure.sh
Last active July 3, 2023 17:19
These are the steps to build newlib used in ESP32 ROM and ESP-IDF
git clone https://github.com/espressif/newlib-esp32.git &&
cd newlib-esp32 && \
./configure \
--with-newlib \
--enable-multilib \
--disable-newlib-io-c99-formats \
--disable-newlib-supplied-syscalls \
--enable-newlib-nano-formatted-io \
--enable-newlib-reent-small \
--enable-target-optspace \
@igrr
igrr / esp32s2beta_dedicated_gpio_example_main.c
Created January 13, 2020 05:06
ESP32-S2 (beta) dedicated GPIO example
/* ESP32-S2 (beta) "dedicated GPIO" peripheral example */
#include <stdio.h>
#include "sdkconfig.h"
#include "soc/system_reg.h"
#include "esp32s2beta/rom/gpio.h"
#include "soc/gpio_sig_map.h"
#include "driver/gpio.h"
/* The header file is not yet in IDF; however this is the only register we need. */