[
  {
    "path": "Code/Hardware_Test_Code.ino",
    "content": "/*********************************************************************\n Thanks to Adafruit for the great oled display library. It's the best one for a 96x16 type\n Install the GFX, SSD1306 and LIS3DH libraries from the IDE\n Install the Adafruit Sensor Library from: https://github.com/adafruit/Adafruit_Sensor\n \n Using the Arduino IDE choose Tools/Board: ESP32 Dev Module\n On Rev1 hardware line 85 = lis.begin(0x18))\n On Rev4 hardware lis.begin(0x19))\n *********************************************************************/\n\n\n#include <WiFi.h>\n#include <Wire.h>\n#include \"time.h\"\n#include <Adafruit_GFX.h>\n#include <Adafruit_SSD1306.h>\n#include <Adafruit_LIS3DH.h>\n#include <Adafruit_Sensor.h>\n\n//I've messed up the led names and see they do not match the schematic\n#define BLUE_LED 23  \n#define RED_LED 5  \n#define GREEN_LED 18\n\n#define LOGO_HEIGHT   16\n#define LOGO_WIDTH    96\n\n//Doesnt work\nstatic const unsigned char PROGMEM logo_bmp[] =\n{\n};\n\n\nAdafruit_SSD1306 display(96, 16, &Wire, 26);\nAdafruit_LIS3DH lis = Adafruit_LIS3DH();\n\nconst char* ssid       = \"SSID\";\nconst char* password   = \"PASSWORD\";\n\nconst char* ntpServer = \"pool.ntp.org\";\nconst long  gmtOffset_sec = -14400;\nconst int   daylightOffset_sec = 3600;\nRTC_DATA_ATTR int bootCount = 0;\n\nstruct tm timeinfo;\n\nvoid setup()\n{\n  Serial.begin(9600);\n  delay(1000);\n\n  pinMode(RED_LED, OUTPUT);\n  pinMode(GREEN_LED, OUTPUT);\n  pinMode(BLUE_LED, OUTPUT);\n\n  digitalWrite(RED_LED, HIGH);   //Keep off\n  digitalWrite(GREEN_LED, HIGH); //Keep off\n  digitalWrite(BLUE_LED, HIGH);  //Keep off\n\n  Wire.begin(13,14);  //ESP32 Pico D4 pins\n  display.setRotation(2);\n\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); \n  \n  //connect to WiFi\n  Serial.printf(\"Connecting to %s \", ssid);\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n      delay(500);\n      Serial.print(\".\");\n  }\n  Serial.println(\" CONNECTED\");\n  digitalWrite(GREEN_LED, LOW);\n  delay(150);\n  digitalWrite(GREEN_LED, HIGH);\n\n  display.display();\n  delay(2000);\n  display.clearDisplay();\n  \n  //init and get the time\n  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);\n\n  Serial.println(\"LIS3DH test!\");\n  \n  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address\n    Serial.println(\"Couldnt start\");\n    while (1);\n  }\n  Serial.println(\"LIS3DH found!\");\n  \n  lis.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!\n  Serial.print(\"Range = \"); Serial.print(2 << lis.getRange());  \n  Serial.println(\"G\");\n \n}\n\nvoid loop()\n{\n  //testdrawbitmap();  //No worky\n\n  if (touchRead(T0) < 50)\n  {\n  digitalWrite(BLUE_LED, LOW);\n  }\n  else\n  {\n  digitalWrite(BLUE_LED, HIGH);\n  }\n\n  lis.read(); \n  sensors_event_t event; \n  lis.getEvent(&event);\n  \n  display.setTextSize(1);\n  display.setTextColor(WHITE);\n  display.setCursor(0,8);  //over,down\n  display.print(event.acceleration.x);\n  display.print(\" \");\n  display.print(event.acceleration.y);\n   display.print(\" \");\n  display.print(event.acceleration.z);\n\n  if(!getLocalTime(&timeinfo))\n  {\n    Serial.println(\"Failed to obtain time\");\n    return;\n  }\n  Serial.println(&timeinfo, \"%A, %B %d %Y %H:%M:%S\");\n\n  display.setTextSize(1);\n  display.setTextColor(WHITE);\n  display.setCursor(0,0);  //over,down\n  display.print(&timeinfo, \"%H:%M:%S\");\n  display.display();\n  display.clearDisplay();\n}\n\n//Doesnt Work\nvoid testdrawbitmap(void) {\n  display.clearDisplay();\n\n  display.drawBitmap(\n    (display.width()  - LOGO_WIDTH ) / 2,\n    (display.height() - LOGO_HEIGHT) / 2,\n    logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);\n  display.display();\n  delay(1000);\n}\n"
  },
  {
    "path": "Code/Low_Power_Time.ino",
    "content": "/*\nThe ESP32 Coin Cell Board uses Tools/Board/ESP32 Dev Module\nSimple Deep Sleep with Timer Wake Up Displaying Time every 10 minutes\n\nUsing the Arduino IDE choose Tools/Board: ESP32 Dev Module\n=====================================\n\nThis code is under Public Domain License.\n\nOriginal Author:\nPranav Cherukupalli <cherukupallip@gmail.com>\n*/\n\n#include <WiFi.h>\n#include <Wire.h>\n#include \"time.h\"\n#include <Adafruit_GFX.h>\n#include <Adafruit_SSD1306.h>\n#include <Adafruit_LIS3DH.h>\n#include <Adafruit_Sensor.h>\n\n#define uS_TO_S_FACTOR 1000000   /* Conversion factor for micro seconds to seconds */\n#define TIME_TO_SLEEP  60        /* Time ESP32 will go to sleep (in seconds) 600 = 10 minutes */  \n#define OLED_RESET 26             /*ESP32 Pico D4 */\n\n#define RED_LED 23  //lights Green\n#define GREEN_LED 18  //lights Red\n#define BLUE_LED 5\n\n//#define SCREEN_HEIGHT 16\n//#define SCREEN_WIDTH  96\n\n#define LOGO_HEIGHT   16\n#define LOGO_WIDTH    96 \n\nstatic const unsigned char PROGMEM logo_bmp[] =\n{ \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x03, 0xf3, 0xff, 0x18, 0xe0, 0x1e, 0x01, 0x80, 0x1e, 0x03, 0xb8, 0x00, \n    0x01, 0x94, 0x59, 0xac, 0xb0, 0x32, 0x00, 0x00, 0x32, 0x01, 0x98, 0x00, \n    0x01, 0x87, 0x19, 0x8c, 0x30, 0x60, 0x33, 0xb4, 0x60, 0x31, 0x98, 0x00, \n    0x01, 0xe3, 0xdf, 0x18, 0x60, 0x60, 0x69, 0x9a, 0x60, 0x69, 0x98, 0x00, \n    0x01, 0x80, 0xd8, 0x0c, 0x40, 0x60, 0x69, 0x9a, 0x60, 0x79, 0x98, 0x00, \n    0x01, 0x94, 0x58, 0x2c, 0x90, 0x26, 0x69, 0x9a, 0x26, 0x61, 0x98, 0x00, \n    0x03, 0xf7, 0xbc, 0x18, 0xf0, 0x1c, 0x33, 0xfb, 0x1c, 0x3b, 0xfc, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n   \n};\n\nAdafruit_SSD1306 display(96, 16, &Wire, 26);\n\nconst char* ssid       = \"SSID\";\nconst char* password   = \"PASSWORD\";\n\nconst char* ntpServer = \"pool.ntp.org\";\nconst long  gmtOffset_sec = -14400;\nconst int   daylightOffset_sec = 3600;\n\nRTC_DATA_ATTR int bootCount = 0;\n\n\nstruct tm timeinfo;\n\nvoid setup()\n{\n  Serial.begin(9600);\n  delay(1000); \n\n  pinMode(OLED_RESET, OUTPUT);\n \n  pinMode(RED_LED, OUTPUT);\n  pinMode(GREEN_LED, OUTPUT);\n  pinMode(BLUE_LED, OUTPUT);\n \n  digitalWrite(OLED_RESET, HIGH);   //Keep Oled High = 0.21mA, OLED_RESET LOW draws lots of current\n\n  digitalWrite(RED_LED, HIGH);   //Keep Led off\n  digitalWrite(GREEN_LED, HIGH); //Keep Led off\n  digitalWrite(BLUE_LED, HIGH);  //Keep Led off\n\n  Wire.begin(13,14);  //ESP32 Pico D4 pins\n  display.setRotation(2);\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); \n\n   //connect to WiFi\n  Serial.printf(\"Connecting to %s \", ssid);\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n      delay(500);\n      Serial.print(\".\");\n  }\n  Serial.println(\" CONNECTED\");\n  digitalWrite(GREEN_LED, LOW);\n  delay(150);\n  digitalWrite(GREEN_LED, HIGH);\n  \n  testdrawbitmap();\n  //display.display();\n  delay(2000);\n  display.clearDisplay();\n\n  //init and get the time\n  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);\n\n  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);\n  Serial.println(\"Setup ESP32 to sleep for every \" + String(TIME_TO_SLEEP) +\n  \" Seconds\");\n}\n\nvoid loop()\n{\n   struct tm timeinfo;\n  if(!getLocalTime(&timeinfo))\n  {\n    Serial.println(\"Failed to obtain time\");\n    return;\n  }\n\n  digitalWrite(RED_LED, LOW);  //LED on\n  delay(100);\n  digitalWrite(RED_LED, HIGH);\n  delay(100);\n\n  digitalWrite(GREEN_LED, LOW);  //LED on\n  delay(100);\n  digitalWrite(GREEN_LED, HIGH);\n  delay(100);\n\n  digitalWrite(BLUE_LED, LOW);\n  delay(100);\n  digitalWrite(BLUE_LED, HIGH);\n  delay(100);\n\n  display.ssd1306_command(SSD1306_DISPLAYON);\n  \n  display.setTextSize(1);\n  display.setTextColor(WHITE);\n  display.setCursor(0,0);  //over,down\n  Serial.println(&timeinfo, \"%A, %B %d %Y %H:%M:%S\");\n  display.println(\"NTP Time:\");\n  display.println(&timeinfo, \"%H:%M:%S\");\n  display.display();\n  delay(2000);\n  display.clearDisplay();\n\n  display.ssd1306_command(SSD1306_DISPLAYOFF);\n\n  Serial.println(\"Going to sleep now\");\n  esp_deep_sleep_start();\n}\n\nvoid testdrawbitmap(void)\n{\n  display.clearDisplay();\n\n  display.drawBitmap(\n    (display.width()  - LOGO_WIDTH ) / 2,\n    (display.height() - LOGO_HEIGHT) / 2,\n    logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);\n  display.display();\n  delay(2000);\n  display.clearDisplay();\n}\n"
  },
  {
    "path": "Code/Rev4_Hardware_Test.ino",
    "content": " /*********************************************************************\n The ESP32 Coin Cell Board uses Tools/Board/ESP32 Dev Module\n\n Thanks to Adafruit for the great oled display library. It's the best one for a 96x16 type\n Install the GFX, SSD1306, LIS3DH and ClosedCube HDC1080, libraries from the IDE\n Install the Adafruit Sensor Library from: https://github.com/adafruit/Adafruit_Sensor\n *********************************************************************/\n\n #include <Wire.h>\n #include <WiFi.h>\n #include \"time.h\"\n #include <Adafruit_GFX.h>\n #include <Adafruit_SSD1306.h>\n #include <Adafruit_LIS3DH.h>\n #include <Adafruit_Sensor.h>\n #include \"ClosedCube_HDC1080.h\"\n\n Adafruit_SSD1306 display(96, 16, &Wire, 26);\n Adafruit_LIS3DH lis = Adafruit_LIS3DH();\n ClosedCube_HDC1080 hdc1080;\n\n #define ACCEL_PWR 34\n #define OLED_RESET 26\n #define BLUE_LED 23  \n #define RED_LED 5  \n #define GREEN_LED 18\n #define LOGO16_GLCD_HEIGHT 16\n #define LOGO16_GLCD_WIDTH  96  //was 16\n\n const char* ssid       = \"SSID\";  \n const char* password   = \"PASSWORD\";  \n\n int threshold = 40;\n bool touch1detected = false;\n bool touch2detected = false;\n int wifi_connected;\n\n void gotTouch1()\n {\n touch1detected = true;\n }\n\nvoid gotTouch2(){\n touch2detected = true;\n}\n\nvoid callback()\n{\n //placeholder callback function\n}\n\nvoid setup() \n{\n Serial.begin(115200);\n delay(1000); // give me time to bring up serial monitor\n \n pinMode(ACCEL_PWR, OUTPUT);\n \n pinMode(OLED_RESET, OUTPUT);\n pinMode(RED_LED, OUTPUT);\n pinMode(GREEN_LED, OUTPUT);\n pinMode(BLUE_LED, OUTPUT);\n \n digitalWrite(ACCEL_PWR, HIGH);\n digitalWrite(OLED_RESET, HIGH);\n digitalWrite(RED_LED, HIGH);   //Keep off\n digitalWrite(GREEN_LED, HIGH); //Keep off\n digitalWrite(BLUE_LED, HIGH);  //Keep off\n\n Wire.begin(13,14);             //ESP32 i2c pins\n display.setRotation(2);\n display.begin(SSD1306_SWITCHCAPVCC, 0x3C);\n hdc1080.begin(0x40);\n \n blinkRGB();\n\n display.clearDisplay();  \n\n //Now connect to WiFi\n Serial.printf(\"Connecting to %s \", ssid);\n WiFi.begin(ssid, password);\n  \n display.ssd1306_command(SSD1306_DISPLAYON);\n display.setTextSize(1);\n display.setTextColor(WHITE);\n \n int counter = 0; \n while (WiFi.status() != WL_CONNECTED) //if not connected to wifi\n {\n   Serial.print(\".\"); \n   display.clearDisplay();\n   display.setCursor(10,0);\n   display.print(\"Connecting\");\n   display.setCursor(10,9);\n   display.print(\"to wifi: \");\n   display.print(counter);\n   display.display();\n   delay(1500);\n   counter++;\n\n   if (counter > 5)\n   {\n    display.clearDisplay();\n    display.setCursor(15,0);\n    display.println(\"No WiFi\");\n    Serial.println(\"No WiFi\");\n    display.display();\n    delay(500);\n    break;\n   }\n\n   if (WiFi.status() == WL_CONNECTED)  //if it connects to wifi\n   {\n    display.clearDisplay();\n    display.setCursor(10,0);\n    display.print(\"Connected!\");\n    display.display();\n    digitalWrite(GREEN_LED, LOW);\n    delay(1000);\n    digitalWrite(GREEN_LED, HIGH);\n    delay(1500);\n    display.clearDisplay();\n\n    display.setCursor(0,0);\n    IPAddress myIP = WiFi.softAPIP();\n    display.println(myIP);\n    display.print(\"RSSI:\");\n    display.print(WiFi.RSSI());\n    delay(1000);  \n   }\n }\n  \n  display.display();\n  delay(1000);\n   \n  Serial.println(\"LIS3DH test!\");\n  \n  if (! lis.begin(0x19)) \n  {  \n    Serial.println(\"Couldnt start\");\n    while (1);\n  }\n  Serial.println(\"LIS3DH found!\");\n  \n  lis.setRange(LIS3DH_RANGE_4_G);   // 2, 4, 8 or 16 G!\n  Serial.print(\"Range = \"); Serial.print(2 << lis.getRange());  \n  Serial.println(\"G\");\n  \n  touchAttachInterrupt(T0, gotTouch1, threshold);\n  touchAttachInterrupt(T7, gotTouch2, threshold);\n  \n  delay(2000);\n  display.clearDisplay(); \n}\n\nvoid loop()\n{\n  lis.read(); \n  sensors_event_t event; \n  lis.getEvent(&event);\n\n  display.ssd1306_command(SSD1306_DISPLAYON);\n  display.setTextSize(1);\n  display.setTextColor(WHITE);\n\n  display.setCursor(0,0);  //over,down\n  display.print(hdc1080.readTemperature());\n  display.print((char)247); // degree symbol \n  display.print(\"C  \");\n  display.print(hdc1080.readHumidity());\n  display.print(\"%\");\n  \n  display.setCursor(0,9);  //over,down\n  display.print(event.acceleration.x);\n  display.print(\" \");\n  display.print(event.acceleration.y);\n  display.print(\" \");\n  display.print(event.acceleration.z);\n\n  while(touch1detected)\n  {\n    Serial.println(\"Touch 0 detected\");\n    //display.clearDisplay();\n    display.setCursor(0,0);;\n    display.print(\"Left Touch\");\n    digitalWrite(RED_LED, LOW);    //On\n    delay(50);\n    digitalWrite(RED_LED, HIGH);   //Off\n    delay(50);\n    touch1detected = false;\n    \n    display.display();\n    delay(50);\n    display.clearDisplay();\n  }\n  while(touch2detected)\n  {\n    Serial.println(\"Touch 2 detected\");\n    display.setCursor(0,0);;\n    display.print(\"Right Touch\");\n    digitalWrite(BLUE_LED, LOW); \n    delay(50);\n    digitalWrite(BLUE_LED, HIGH);\n    delay(50);\n    touch2detected = false;\n    \n    display.display();\n    delay(50);\n    display.clearDisplay();\n  }\n\n  display.display();\n  delay(150);\n  display.clearDisplay();\n}\n\nvoid blinkRGB(void)\n{\n  digitalWrite(RED_LED, LOW);   //led on\n  delay(150);\n  digitalWrite(RED_LED, HIGH);   //led off\n  delay(150);\n  digitalWrite(GREEN_LED, LOW); \n  delay(150);\n  digitalWrite(GREEN_LED, HIGH);\n  delay(150);\n  digitalWrite(BLUE_LED, LOW); \n  delay(150);\n  digitalWrite(BLUE_LED, HIGH);\n  delay(150);\n}\n"
  },
  {
    "path": "Code/Touch_Wakeup_Time.ino",
    "content": "/*\nThe ESP32 Coin Cell Board uses Tools/Board/ESP32 Dev Module\nSimple Deep Sleep with Timer Wake Up Displaying Time every 15 minutes\nThanks to Adafruit and Espressif for the library filed\nBoards: ESP32 Dev Module\n*/\n\n#include <WiFi.h>\n#include <Wire.h>\n#include \"time.h\"\n#include <Adafruit_GFX.h>\n#include <Adafruit_SSD1306.h>\n#include <Adafruit_Sensor.h>\n \n#define OLED_RESET 26    \n\n#define Threshold 40 \n\n#define BLUE_LED 23  \n#define RED_LED 5  \n#define GREEN_LED 18\n\n#define LOGO_HEIGHT   16\n#define LOGO_WIDTH    96  \n\nstatic const unsigned char PROGMEM logo_bmp[] =\n{ \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x03, 0xf3, 0xff, 0x18, 0xe0, 0x1e, 0x01, 0x80, 0x1e, 0x03, 0xb8, 0x00, \n    0x01, 0x94, 0x59, 0xac, 0xb0, 0x32, 0x00, 0x00, 0x32, 0x01, 0x98, 0x00, \n    0x01, 0x87, 0x19, 0x8c, 0x30, 0x60, 0x33, 0xb4, 0x60, 0x31, 0x98, 0x00, \n    0x01, 0xe3, 0xdf, 0x18, 0x60, 0x60, 0x69, 0x9a, 0x60, 0x69, 0x98, 0x00, \n    0x01, 0x80, 0xd8, 0x0c, 0x40, 0x60, 0x69, 0x9a, 0x60, 0x79, 0x98, 0x00, \n    0x01, 0x94, 0x58, 0x2c, 0x90, 0x26, 0x69, 0x9a, 0x26, 0x61, 0x98, 0x00, \n    0x03, 0xf7, 0xbc, 0x18, 0xf0, 0x1c, 0x33, 0xfb, 0x1c, 0x3b, 0xfc, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n   \n};\n \nAdafruit_SSD1306 display(96, 16, &Wire, 26);\n//touch_pad_t touchPin;\n\nconst char* ssid       = \"SSID\";\nconst char* password   = \"PASSWORD\";\n\nconst char* ntpServer = \"pool.ntp.org\";\nconst long  gmtOffset_sec = -14400;\nconst int   daylightOffset_sec = 3600;\n\nRTC_DATA_ATTR int bootCount = 0;\n\nstruct tm timeinfo;\n\nvoid callback()\n{\n  //placeholder callback function\n}\n\nvoid setup()\n{\n  Serial.begin(9600);\n  delay(1000); \n\n  pinMode(OLED_RESET, OUTPUT);\n  pinMode(RED_LED, OUTPUT);\n  pinMode(GREEN_LED, OUTPUT);\n  pinMode(BLUE_LED, OUTPUT);\n  \n  digitalWrite(OLED_RESET, HIGH);   //Keep Oled High = 0.21mA, OLED_RESET LOW draws lots of current\n  digitalWrite(RED_LED, HIGH);   //Keep off\n  digitalWrite(GREEN_LED, HIGH); //Keep off\n  digitalWrite(BLUE_LED, HIGH);  //Keep off\n\n  blinkRGB();\n\n  Wire.begin(13,14);  \n  display.setRotation(2);\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);\n  \n  //connect to WiFi\n  Serial.printf(\"Connecting to %s \", ssid);\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n      delay(500);\n      Serial.print(\".\");\n  }\n  Serial.println(\" CONNECTED\");\n  digitalWrite(GREEN_LED, LOW);\n  delay(150);\n  digitalWrite(GREEN_LED, HIGH);\n  \n  //testdrawbitmap();\n\n  delay(2000);\n  display.clearDisplay();\n  \n  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);   //init and get the time\n\n  touchAttachInterrupt(T0, callback, Threshold);\n  esp_sleep_enable_touchpad_wakeup();   //Configure Touchpad as wakeup source\n}\n\nvoid loop()\n{\n  if(!getLocalTime(&timeinfo))\n  {\n    Serial.println(\"Failed to obtain time\");\n    return;\n  }\n  Serial.println(&timeinfo, \"%A, %B %d %Y %H:%M:%S\");\n  blinkRGB();\n  display.ssd1306_command(SSD1306_DISPLAYON);\n  display.setTextSize(1);\n  display.setTextColor(WHITE);\n  display.setCursor(0,0);  //over,down\n  display.print(&timeinfo, \"%H:%M:%S\");\n  display.display();\n  //delay(2000);\n  display.clearDisplay();\n  display.ssd1306_command(SSD1306_DISPLAYOFF);\n \n  Serial.println(\"Going to sleep now\");\n  esp_deep_sleep_start();\n}\n\n\nvoid testdrawbitmap(void)\n{\n  display.clearDisplay();\n\n  display.drawBitmap(\n    (display.width()  - LOGO_WIDTH ) / 2,\n    (display.height() - LOGO_HEIGHT) / 2,\n    logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);\n  display.display();\n  delay(2000);\n  display.clearDisplay();\n}\n\nvoid blinkRGB(void)\n{\n  digitalWrite(RED_LED, LOW);   //On\n  delay(50);\n  digitalWrite(RED_LED, HIGH);   //Off\n  delay(50);\n  digitalWrite(GREEN_LED, LOW); \n  delay(50);\n  digitalWrite(GREEN_LED, HIGH);\n  delay(50);\n  digitalWrite(BLUE_LED, LOW); \n  delay(50);\n  digitalWrite(BLUE_LED, HIGH);\n}\n"
  },
  {
    "path": "README.md",
    "content": "# ESP32_CoinCell\n\nVideo of it in action is at: https://youtu.be/IdSCKr7fLYc\n\nRev1 soon to be Rev4: https://www.tindie.com/products/miker/esp32-coincell/\n\nThis is an ESP32 Pico D4 project with an accelerometer and 0.69\" oled display powered by a rechargeable LIR2450 coin cell. I was not made for any specific purpose and was really more of a design challenge to try and made it as small as possible and my first attempt at running something at low power. It can be powered off of a battery or USB cable. If a battery is inserted and USB cable is plugged in it will charge the battery and power the board. Current consumption is around 0.30uA when sleeping but up to 85mA running. Runtime testing is still in the works but battery life is only 5 minutes when the display is on and constantly connected to wifi. Connecting to wifi and turning on the display every 10 minutes appears to last 10 hours or so. Revision 1 started off at 200uA in sleep mode. Revisions after that used a switching power supply and setting registers in the accelerometer but they all ended in fail. This revision 4 with a much better LDO and powering the accelerometer off of the ESP32 has finally got the sleep current to 30uA. The design files and parts list is provided if you would like to assemble your own. If you can come up with a specific use for this hardware or have any questions then just let me know at @mikerankin or by email at 0miker0@gmail.com\n\nMain components used in this desgin are:\n\n-ESP32 Pico D4 (wifi/bluetooth processor)\n\n-LIR2450 (3.7V battery) or optional external battery using the microJST connector\n\n-HT7833 (500mA LDO power supply)\n\n-SL4054ST25P (LiPo battery charger)\n\n-LIS3DHTR (accelerometer) now powered off an ESP32 GPIO pin\n\n-CP2102N (USB interface chip)\n\n-ER-OLED0.69-1W (96x16 oled dsiplay)\n\nThe full parts list and schematic is in the PCB directory\n\nThe bare PCB was provided by JLCPCB and most of the parts by LCSC.\n\n![Rev4](https://user-images.githubusercontent.com/4991664/56325424-85181b80-6148-11e9-81cc-3ab20f2d0517.jpg)\n"
  }
]