Skip to main content

Posts

geolocation.getCurrentPosition() only works with HTTPS

Just found out that more recent web browsers requires a SSL-secured (HTTPS) site to host the target script before navigator.geolocation.getCurrentPosition() will work. Otherwise, the following error will be emitted: getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See goo.gl/rStTGz for more details. This creates a problem for the original ESPCLOCK code. Since  WifiManager does not support hosting a HTTPS captive portal, the logic for capturing the user's geolocation (and hence the timezone) no longer works. Back to the drawing board... ESPCLOCK1  /  ESPCLOCK2  /  ESPCLOCK3  /  ESPCLOCK4

Programming the WeMos D1 mini

So I went ahead and ordered the WeMos D1 Mini (now called Lolin D1 Mini). It's a diminutive ESP8266 dev board with reportedly very low deep sleep current draw. To program this board, the CH340 driver needs to be installed in order to access the board via USB. Then select the corresponding board type in Arduino. No code change is necessary. ESPCLOCK1  /  ESPCLOCK2  /  ESPCLOCK3  /  ESPCLOCK4

Hooking up USBasp programmer to the ATTiny85

After putting off the ESPClock project for quite a looooong while, I finally decided to pick up the project again. But the Arduino Uno board had been siphoned off by my eldest son for one of his science projects, so I decided to pick up a cheap  USPasp clone off eBay to help with programming the ATTiny85. First off is to connect the 2x5 ISP header to the ATTiny85. It was a bit confusing at first, but after some research, here are the connections required. I plugged the wires into the 10-pin ISP header, and soldered the other ends to two 1x4 male headers in the correct order. That way, I can just plug the male headers into the breadboard alongside the ATTiny85 quite easily to start programming it without too much fiddling. I had to strengthen the soldering with some hot glue to prevent the wires from breaking off the headers when plugging them in and out repeatedly. Works a treat so far. Then choose "USBasp" as the programmer under the Arduino IDE: I was ...

Experiments with Circadian Rhythm Fasting

I have been doing the Fast Diet for a couple of years now. It works wonderfully, without having to buy any special equipment or supplement, which is fantastic. However, even after all this time, the diet days still need getting some use to. This is especially true when I am on "maintenance" mode, which means you fast once instead of twice a week. Because I am doing it less frequently, the diet day becomes harder because the body takes more time to adjust. Some time back, I came across an article talking about  Circadian Rhythm Fasting , popularized by Dr Jason Fung and many others. Here's a more  recent article on the topic. The main idea is to restrict eating to a small window of the day, effectively fasting for the rest of the time. Like the Fast Diet, it does not require any special equipment or supplement, and is very flexible with the timing. For example, you can choose to start at 7am and end at 3pm, or start at 12pm and end at 6pm. However, the common guideline...

MIUI: Connecting to MJX Bugs B2W

I recently purchased the  MJX Bugs B2W drone, and had a lot of difficulty connecting to the onboard 5GHz WIFI camera from the Bugs Go app. I finally figured out the solution, and it was totally unexpected, so I thought I'd share it here for anyone faced with the same issue. I am using the Redmi Note 4 to connect, and that phone supported 5GHz WIFI, so I had no problem connecting to the drone hotspot. But when I launched the Bugs Go app, I keep getting the "Aircraft not connected" message. I tried a couple of stuff, including resetting the 5GHz channel used by the drone (by pressing on the "Camera" button on the remote controller for about 8 seconds, until you hear 3 beeps). Nothing worked. Then I realized when I connect to the drone hotspot and run Bugs Go, I see this message: It didn't occur to me initally to tap on the message, because I already knew the drone hotspot had no Internet acess. So out of desperation, I tapped on the message: By...

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: void loop () { // Execute loop() every second if ( ! timer1) return ; else timer1 = false ; // Measure supply voltage // Source: http://digistump.com/wiki/digispark/quickref 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 conversio...

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 = "https://maps.googleapis.com/maps/api/timezone/json?location=[loc]&timestamp=[ts]" ; const char * 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 = "https://maps.googleapis.com/maps/api/timezone/json?lo...