Skip to content

Instantly share code, notes, and snippets.

@marshalab
marshalab / gist:4070633c1c29096a0f86efcb10840f0e
Last active February 11, 2026 08:00
esp32 detector - flash psram i2c oled
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <WiFi.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int history[SCREEN_WIDTH];
@marshalab
marshalab / openbot_071mod_marshallab.ino
Created January 23, 2025 16:16
OpenBot v0.71 mod for work esp v3 - 23.01.2025 marshallab
// Required App Version: 0.7.0
// ---------------------------------------------------------------------------
// This Arduino Nano sketch accompanies the OpenBot Android application.
//
// The sketch has the following functionalities:
// - receive control commands and sensor config from Android application (USB serial)
// - produce low-level controls (PWM) for the vehicle
// - toggle left and right indicator signals
// - wheel odometry based on optical speed sensors
// - estimate battery voltage via voltage divider
@marshalab
marshalab / esp32_pcnt_example5.ino
Last active September 8, 2023 05:31
Flow metr example esp32 PCNT !!! 1 channels counter. Need Arduino esp32 version 2.0.12, older not work... My work Freq up to 3,4 MHz on input !!!
#include "driver/pcnt.h" /* Include the required header file, Its working Arduion IDE 2.0*/
#include "soc/pcnt_struct.h" //!add
/* For detailed reference please follow the documentations in following Link:-
Link:- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/pcnt.html
*/
#define PCNT_UNIT_UsedA PCNT_UNIT_0 /* Select the Pulse Count 0 as the unit..*/
#define PCNT_H_LIM_VAL 20000 /* Set the max limit to trigger the interrupt*/
#define PCNT_INPUT_SIG_IOA 32 /* Pulse Input selected as GPIO 4 */
@marshalab
marshalab / esp32_pcnt_example31.ino
Last active September 7, 2023 17:34
Its work example esp32 PCNT !!! 1 channels counter. Need Arduino esp32 version 2.0.12, older not work...
#include "driver/pcnt.h" /* Include the required header file, Its working Arduion IDE 2.0*/
#include "soc/pcnt_struct.h" //!add
/* For detailed reference please follow the documentations in following Link:-
Link:- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/pcnt.html
*/
#define PCNT_UNIT_UsedA PCNT_UNIT_1 /* Select the Pulse Count 0 as the unit..*/
#define PCNT_H_LIM_VAL 1 /* Set the max limit to trigger the interrupt*/
@marshalab
marshalab / esp32_pcnt_example4.ino
Created September 7, 2023 13:29
Example esp32 PCNT - work but strange rusult
// BLOG Eletrogate
// ESP32 Frequency Meter
// ESP32 DevKit 38 pins + LCD
// https://blog.eletrogate.com/esp32-frequencimetro-de-precisao
// Rui Viana and Gustavo Murta august/2020
#include "stdio.h" // Library STDIO
#include "driver/ledc.h" // Library ESP32 LEDC
#include "driver/pcnt.h" // Library ESP32 PCNT
#include "soc/pcnt_struct.h"
@marshalab
marshalab / esp32_pcnt_example3.ino
Created September 7, 2023 13:11
Its work example esp32 PCNT ! 2 channels counter.
#include "driver/pcnt.h" /* Include the required header file, Its working Arduion IDE 2.0*/
#include "soc/pcnt_struct.h" //!add
/* For detailed reference please follow the documentations in following Link:-
Link:- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/pcnt.html
*/
#define PCNT_UNIT_UsedA PCNT_UNIT_1 /* Select the Pulse Count 0 as the unit..*/
#define PCNT_UNIT_UsedB PCNT_UNIT_0 /* Select the Pulse Count 1 as the unit..*/
@marshalab
marshalab / esp32_pcnt_example2.ino
Created September 7, 2023 13:06
example esp32 PCNT. Not work to me. 0 freq
#include "Arduino.h"
#include <driver/pcnt.h>
#define ARDUINO_RUNNING_CORE 1
void TaskReadPulses(void *pvParameters) // This is a task.
{
(void)pvParameters;
pcnt_config_t pcntCh1 = {
@marshalab
marshalab / esp32_pcnt_example1.ino
Created September 7, 2023 12:53
Work example esp32 PCNT - in Arduino set Tool/Core debug level = INFO
#include "driver/pcnt.h"
#define PCNT_H_LIM_VAL 10
#define PCNT_L_LIM_VAL -10
#define PCNT_THRESH1_VAL 5
#define PCNT_THRESH0_VAL -5
#define PCNT_INPUT_SIG_IO 34 // Pulse Input GPIO
#define PCNT_INPUT_CTRL_IO 5 // Control GPIO HIGH=count up, LOW=count down
#define LEDC_OUTPUT_IO 5 // Output GPIO of a sample 1 Hz pulse generator
//ch32v003_ArduinoTest.ino
#include <Arduino.h>
/* PC1 as blinky LED, change here as needed */
#define LED1 C1
#define LED2 C2
void setup() {
pinMode(LED1, OUTPUT);
// Arduino_Speed_Tests.ino
// Arduino Speed Test Benchmarking Program
// Original Program Credit: Arduino.cc
// Modified By: Dan Watson
// synchannel.blogspot.com
// 1-29-2015
// This sketch is the speed test portion of the Arduino Show Info program
// http://playground.arduino.cc/Main/ShowInfo