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 / ledc_fade_idf_style.ino
Created January 8, 2018 21:13
Example for led control in Arduino IDE using IDF driver component.
#include "driver/ledc.h"
//https://github.com/espressif/esp-idf/blob/master/examples/peripherals/ledc/main/ledc_example_main.c
ledc_timer_config_t ledc_timer;
ledc_channel_config_t ledc_channel;
void setup() {
ledc_timer.bit_num = LEDC_TIMER_13_BIT; // resolution of PWM duty
ledc_timer.freq_hz = 5000; // frequency of PWM signal
@CelliesProjects
CelliesProjects / led_hw_fade.ino
Created March 22, 2018 19:40
Arduino IDE ESP32 ledc hw fade poc/example.
#include "driver/ledc.h"
//https://github.com/espressif/esp-idf/blob/master/components/driver/ledc.c
//https://esp-idf.readthedocs.io/en/v1.0/api/ledc.html#api-reference
/* set 'Core debug level' to INFO or higher */
const uint8_t channel = 0;
const uint8_t numberOfBits = LEDC_TIMER_15_BIT;
const uint8_t ledPin = 2;
const uint32_t frequency = 1000;
const uint32_t fadeTimeSeconds = 86400;
@CelliesProjects
CelliesProjects / check_online_version.ino
Created April 15, 2018 13:18
ESP32 - poc of an sketch that checks the github api to see if a new version is available.
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
const char* ssid = "your-ssid"; // your network SSID (name of wifi network)
const char* password = "your-password"; // your network password
const char* server = "api.github.com"; // Server URL
const String currentVersion = "v1.0.3-6-gff9e74c";
// www.howsmyssl.com root certificate authority, to verify the server
@CelliesProjects
CelliesProjects / ssl_example.ino
Created April 19, 2018 09:52
ESP32 example showing a SSL connection made from the esp32 to an SSL secured site.
#include <HTTPClient.h>
const char* thuis_ca = "-----BEGIN CERTIFICATE-----\n" \
"MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" \
"MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" \
"DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" \
"PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" \
"Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" \
"AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" \
"rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" \
@CelliesProjects
CelliesProjects / aSyncClient.ino
Created April 19, 2018 13:19
ESP32 test gist to get some aSyncClient things clear.
#include <WiFi.h>
#include <AsyncTCP.h> /* https://github.com/me-no-dev/ESPAsyncTCP */
static AsyncClient * aClient = NULL;
/* https://github.com/me-no-dev/ESPAsyncTCP/issues/18 */
void setup() {
// put your setup code here, to run once:
ESP_LOGI( TAG, "Connecting..." );
@CelliesProjects
CelliesProjects / testMoonLightPercentage.ino
Created April 25, 2018 03:37
Test Arduino ESP32 sketch to calculate moon illumination
/* standalone moon phase calculation */
/* code adapted from http://www.voidware.com/phase.c */
/* found at https://www.autoitscript.com/forum/topic/182372-standalone-moon-phase-calculation/ */
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535897932384626433832795
#define RAD (PI/180.0)
#define SMALL_FLOAT (1e-12)
@CelliesProjects
CelliesProjects / moonPhaseLoop.ino
Last active March 13, 2025 16:34
ESP32 sketch to get current moon phase in a loop.
/* standalone moon phase calculation */
/* code adapted from http://www.voidware.com/phase.c */
/* found at https://www.autoitscript.com/forum/topic/182372-standalone-moon-phase-calculation/ */
/* https://www.moongiant.com/ to check calculations */
/* seems it is not related to utc but to local time according to: */
/* https://www.timeanddate.com/moon/phases/netherlands/wageningen */
#include <WiFi.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <FS.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "SPI.h"
#include "SD.h"
@CelliesProjects
CelliesProjects / light_flicker_poc.ino
Created May 4, 2018 12:48
A poc of the ledc pwm flicker caused by accessing the SD card.
/*
* UPLOAD curl -F data=@'filename' IPADDRESS/upload
* UPLOAD: curl -F data=@'/home/cellie/Moon.zip' 192.168.0.194/upload
*/
#include <SPI.h> /* should be installed together with ESP32 Arduino install */
#include <FS.h> /* should be installed together with ESP32 Arduino install */
#include <SD.h> /* should be installed together with ESP32 Arduino install */
#include <SPIFFS.h>
@CelliesProjects
CelliesProjects / classTest.ino
Created May 11, 2018 10:46
ESP32 - A simple class with a member that is a freertos task.
/* http://www.learncpp.com/cpp-tutorial/812-static-member-functions/ */
#include "myClass.h"
void setup() {
xTaskCreatePinnedToCore(
myClass::myFunction, /* Task function. */
"myFunction", /* String with name of task. */
10000, /* Stack size in words. */
NULL, /* Parameter passed as input of the task */