Posts

Reading LittleFS file into buffer for sending

 Reading LittleFS file into buffer for sending to another ESP32 via ESP Now. Created dummy file 1321 bytes long with "sensor" information in the form like this:     uint8_t sensorData1[] = "[ 00 12:05:12:06:01 22 33 44 \n"; Red stuff above is timestamp to later get in real time from DS3231.  Blue stuff is dummy sensor information, two ascii chars representing 00 to 99. Black stuff is just formatting chars and spaces. The following program reads in about 43 lines of sensor information as above and puts it into LittleFS file called sensorReadings.txt. This file then gets cut up into 200 byte chunks (via sendBuf[200] ) and gets sent to dummy sender file called sendNowBuf(). No actual sending takes place, so next sub-project is to send the 200 byte chunks one by one via ESPNow to second ESP32. //41 From Arduino Examples/mnt/c/Users/Dell/Documents/Arduino/Working202411/LITTLEFS_test2/LITTLEFS_test2.ino #include <Arduino.h> #include "FS.h" #include <Li...

LittleFS

 LittleFS start. Revisiting little fs. Got the code below to work:  //06 From Arduino Examples #include <Arduino.h> #include "FS.h" #include <LittleFS.h> /* You only need to format LittleFS the first time you run a    test or else use the LITTLEFS plugin to create a partition    https://github.com/lorol/arduino-esp32littlefs-plugi    If you test two partitions, you need to use a custom    partition.csv file, see in the sketch folder */ //#define TWOPART #define FORMAT_LITTLEFS_IF_FAILED true void listDir ( fs::FS & fs , const char * dirname , uint8_t levels) {   Serial . printf ( "Listing directory: %s\r\n" , dirname ) ;   File root = fs . open ( dirname ) ;   if ( !root ) {     Serial . println ( "- failed to open directory" ) ;     return ;   }   if ( ! root . isDirectory ()) {     Serial . println ( " gg- not a directory" ) ;     return ; ...

GPIO pins etc

Image
 GPIO pins etc

ESP32 buttons and bouncing

 ESP32 buttons and bouncing Rigged up button to GPIO 21 to explore, button presses, debouncing and interrupts. Following worked. /*  * This ESP32 code is created by esp32io.com Worked 7/11/24  *  * This ESP32 code is released in the public domain  *  * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-button-debounce  */ #include <ezButton.h> #define DEBOUNCE_TIME 50 // the debounce time in millisecond, increase this time if it still chatters ezButton button ( 21 ) ; // create ezButton object that attach to pin GPIO21 void setup () {   Serial . begin ( 9600 ) ;   button . setDebounceTime ( DEBOUNCE_TIME ) ; // set debounce time to 50 milliseconds } void loop () {   button . loop () ; // MUST call the loop() function first   if ( button . isPressed ())     Serial . println ( "The button is pressed" ) ;   if ( button . isReleased ())     Serial . pri...

RTC with ESP32

Image
 RTC with ESP32 Copied RTC code from this site  . Worked ok; see below: 27 Worked OK without battery, but seems to get time from OS when compiling. Does not keep running with power off and seems to revert to previous time when compiled. That's ok. x  Time string  Time string is 2023-1-21 3:5:36  now working with "sprintf".  Time string is 2023-1-21 3:5:36 Time string is 2023-1-21 3:5:36 Time string is 2023-1-21 3:5:36 (Plus other stuff gets printed.) /* * This ESP32 code is created by esp32io.com * * This ESP32 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-rtc Sat Nov 2 12:51:10 NZDT 2024 playing 01 */ #include <RTClib.h> #include <stdio.h> RTC_DS3231 rtc; char daysOfWeek[7][12] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; char buffer[100];...