Skip to content

Instantly share code, notes, and snippets.

View CelliesProjects's full-sized avatar
🖥️
Busy coding...

Cellie CelliesProjects

🖥️
Busy coding...
View GitHub Profile
@CelliesProjects
CelliesProjects / TTGO-TM-Lovyan.ino
Last active September 17, 2023 17:11
LovyanGFX working on TTGO-TM-ESP32
#include <Arduino.h>
// #define LGFX_USE_V1
#include <LovyanGFX.hpp>
// This is the hardware:
// https://github.com/LilyGO/TTGO-TM-ESP32
// LGFX for TTGO T-Display
class LGFX : public lgfx::LGFX_Device
@CelliesProjects
CelliesProjects / isr_in_class.ino
Last active May 15, 2021 12:56
esp32 - simple poc demonstrating a timer interupt driven ISR living in a class
/* simple poc demonstrating a timer interupt driven ISR living in a class */
class foo {
public:
bool start_isr();
private:
static void _timer_isr();
hw_timer_t * exampleTimer;
@CelliesProjects
CelliesProjects / esp32_netif_isup.ino
Created April 18, 2021 14:41
A esp32 check to see if any network interface up.
#include <tcpip_adapter.h>
static bool netif_isup() {
for (int i = TCPIP_ADAPTER_IF_STA; i < TCPIP_ADAPTER_IF_MAX; i++)
if (tcpip_adapter_is_netif_up((tcpip_adapter_if_t)i)) return true;
return false;
}
#include <WiFi.h>
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#
// https://github.com/espressif/esp-idf/blob/master/examples/protocols/sntp/main/sntp_example_main.c
const char* WIFI_NETWORK = "xxx";
const char* WIFI_PASSWORD = "xxx";
const char* NTP_POOL = "nl.pool.ntp.org";
@CelliesProjects
CelliesProjects / reboot_through_asyncwebserver.ino
Created January 15, 2021 13:30
poc code to show how to reboot your esp over http with me-no-dev ASyncWebserver.
server.on("/hw-reset", HTTP_GET, [](AsyncWebServerRequest *request){
request->onDisconnect([](){
#ifdef ESP32
ESP.restart();
#elif defined(ESP8266)
ESP.reset();
#endif
});
request->send(200, "text/plain","Restarting ...");
});
@CelliesProjects
CelliesProjects / serial2ws.ino
Last active November 7, 2020 14:16
A simple Serial to WebSocket bridge - poc for reading DSMR conforming smart meters.
/*
This is a serial to websocket server for application with a DSMR 5.x. conform 'Dutch Smart Meter'.
This sketch reads messages (terminated by a newline) from a smart meter connected on Serial
and echos these messages to clients connected on websocket '/ws'.
All non utf8 chararacters in the messages are dropped.
*/
@CelliesProjects
CelliesProjects / static_ip_setup.ino
Created March 10, 2020 14:18
Static IP on ESP32 Arduino
// Load Wi-Fi library
#include <WiFi.h>
// Replace with your network credentials
const char* ssid = "";
const char* password = "";
void setup(){
IPAddress local_IP(192, 168, 0, 60); /* THIS SHOULD BE OUTSIDE YOUR ROUTERS DHCP RANGE! */
@CelliesProjects
CelliesProjects / SetClockOnPin.ino
Created December 4, 2019 20:12
ESP32 - Example setting a clock signal (50% duty cycle) on a pin.
#include "driver/ledc.h"
static void enable_out_clock(uint8_t pin,double freq) {
periph_module_enable(PERIPH_LEDC_MODULE);
ledc_timer_bit_t bit_num = (ledc_timer_bit_t) 1; // 3 normally
int duty = pow(2, (int) bit_num) / 2;
ledc_timer_config_t timer_conf;
timer_conf.bit_num = bit_num;
timer_conf.freq_hz = freq;
@CelliesProjects
CelliesProjects / M5BalaMotorCode.ino
Created November 28, 2019 17:42
POC to drive M5 Balancer Robot I2C base with motors.
#include <Wire.h>
#define M5GO_WHEEL_ADDR 0x56
#define MOTOR_CTRL_ADDR 0x00
#define ENCODER_ADDR 0x04
#define DEAD_ZONE 5
void setMotor(int16_t pwm0, int16_t pwm1) {
Wire.beginTransmission(M5GO_WHEEL_ADDR);
Wire.write(MOTOR_CTRL_ADDR); // Motor ctrl reg addr
@CelliesProjects
CelliesProjects / detect_WM8978.ino
Created November 22, 2019 22:19
Simple poc to show how to detect a i2c wm8978 codec in esp32 arduino.
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.begin( 21, 22, 400000 );
Wire.beginTransmission( 0X1A );
uint8_t error = Wire.endTransmission();
if ( error ) ESP_LOGI( TAG, "No codec found." );
}