Showing posts from March, 2017

ATtiny85 - Using capacitor for backup power to persist clock time to EEPROM

As discussed in the initial design post, the idea is to connect a 0.47F capacitor to the VCC and GND pins of the ATtiny85. Then when we lose power, the capacitor will provide the ATtiny85 with enough juice to store the current clock time to its EEPROM. When we gain power again, the ATtiny85 will read the clock time back from the EEPROM and start over. In this way, we avoid killing the EEPROM of the ATtiny85 with too many write operations.

To that end, I purchased something like this over EBay (2 for $3, so works out to about $1.50 each).

The code to check for supply voltage drop looks like this:

voidloop() { // Execute loop() every secondif (!timer1) return; else timer1 =false; // Measure supply voltage// Source: adc_enable(); ADMUX = _BV(MUX3) | _BV(MUX2); // VCC as reference, band gap voltage (~1.1V) as input _delay_us(250); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversionwhile (bit_is_set(ADCSRA, ADSC)); //…

ESP-12E calling Google Timezone API

The ESP-12E module of the ESPCLOCK V2.0 project is done. All the clock control logic has been shifted to the ATtiny85 module, so the ESP-12E is only in-charged of periodically getting the NTP time, converting to local time, and sending it via I2C to the ATtiny85.

One of the unresolved problems in the original ESPCLOCK project is calling the Google Timezone API via HTTPS. Because Google's HTTPS cert is different for servers in different geographical locations, this presents a problem for the original code:

const String GOOGLE_API_URL ="[loc]&timestamp=[ts]"; constchar* GOOGLE_API_CERT ="AD:B8:13:99:64:F5:75:F5:78:5C:FA:43:19:EA:8F:AF:2B:AE:54:FE"; ... HTTPClient http; http.begin(url.c_str(), GOOGLE_API_CERT); int rc = http.GET();
The solution I used is the one outlined in this comment.

const String GOOGLE_API_URL ="[loc]&timestamp=[t…