Skip to content

Apple, 20 years ago

In 1998:

For $1,299, you came home with a 233MHz PowerPC G3 processor, 32MB of RAM, a 4GB hard drive, a 15-inch built-in monitor, and stereo speakers—all in an amazingly stylish case.

8 ways the iMac changed computing By Benj Edwards (first published in 2008) — “Apple’s most iconic desktop computer.” Popularizing the I’net, USB, floppy disk demise, and a ‘left coast’ industrial design with special appeal to the academia and the elite communities.

Twenty years on, the little box attached to the TV as a media center has nearly 10 times the clock speed, 100 times the RAM, 1000 times the mass storage, 3 – 5 times the screen size (widescreen, even), and one tenth the cost.

Python date and time

Trying to display, store, and calculate date and time values can be a significant challenge. This is why there are 6 Python datetime libraries by Lacey Williams Henschel — “There are a host of libraries that make it simpler to test, convert, and read date and time information in Python.”

“beyond converting strings to more useful Python objects with ease, there are a whole host of libraries with helpful methods and tools that can make it easier to manage testing with time, convert time to different time zones, relay time information in human-readable formats, and more. If this is your first foray into dates and times in Python, take a break and read How to work with dates and time with Python. To understand why dealing with dates and times in programming is hard, read Falsehoods programmers believe about time.

Now the problem is that of shopping for the best solution for your needs. That can be tricky, too.

Sense and Control: so many options

OK. got the Sonoff stuff going OEM. Now for the next step. I’m looking for two major features. (1) FOSS and (2) local without dependencies. Complexity is another factor as I’d rather the component count be in hardware rather than software. It’d also be nice if it was possible to get into customization and modification without needing a major development environment. VSCode and PlatformIO is about the limit for development.

The structure of the forest needs to be kept in mind as the entire ecosystem has to mesh and work together. At the device level there is the firmware. That can be OEM for purpose built devices or it can be ESPeasy, ESPurna, Tasmota or whatever. These may be stand alone but most systems depend upon a message broker often handling MQTT. Then there’s the decision and computation section to gather status and sensor information and send out control messages. Node Red shines big on that. Finally, there’s the User Interface. It can get complicated.

9 Home Automation Open-Source Platforms for Your projects provides an insight into just how many options are out there and gives you an idea of why a decision can be difficult. 6 open source home automation tools by Jason Baker — “Build a smarter home with these open source software solutions.” cites a few more packages and a few more issues.

OpenHab vs Home Assistant vs Domoticz – What fits you best? by David C hits another point. ” in this post we will focus on the three biggest communities. A big community translates into more ideas and more people sharing their knowledge with you.”

Home Assistant seems to be a mover and shaker right now. It is a Python 3 app and the developer has started the move to asyncio as in Python 3.4. It includes an MQTT broker. It’s UI is web based so there is no need for a special app. There are some leads to its use with micropython but that needs more research about what it’d take to get an ESP8266 device as a client with micropython rather than the more common prebuilt FOSS firmware.

When comparing these web based interfaces with ‘big’ apps such as Node-Red or the Jupyter Notebook, the impression is that a good web UI is a major Javascript development effort and the Internet of Things people have their focus elsewhere. That means the application sector is still feeling its way and getting standards and methods ironed out.

What makes Python interesting

Python is different but not too different and that makes it interesting and worthwhile for study. An example is Loop better: A deeper look at iteration in Python by Trey Hunner — “Dive into Python’s for loops to take a look at how they work under the hood and why they work the way they do.” A pre-requisite is some familiarity with “iterators” and “generators” and “dictionaries” as these are fundamental concepts utilized by Python looping constructs. They are reviewed in the article.

Unlike traditional C-style for loops, Python’s for loops don’t have index variables. There’s no index initializing, bounds checking, or index incrementing. Python’s for loops do all the work of looping over our numbers list for us.

So while we do have for loops in Python, we do not have have traditional C-style for loops. The thing that we call a for loop works very differently.

Hunner has a nice comparison and contrast to illustrate his point. The reason for all of this is noted:

There are lots of iterators built into Python, in the standard library, and in third-party Python libraries. These iterators all act like lazy iterables by delaying work until the moment you ask them for their next item.

This has implications in handling large sets of calculated things. Instead of carrying around a huge array or other data object, the one you need is obtained only when you need it for the amount of time you need to do something with it. That is a conceptual step up from basic programming paradigms.

Itead Sonoff for an easy start

USB does fine for a microcontroller power development platform. But what do you do when you want to let some project loose in the wild? That is one of features Itead includes in its Sonoff line. For about the price of an ESP8266 development board (~ $5) you can get an ESP8266 with 1 MB SPI RAM, an LED, a pushbutton, a relay, and a power supply that taps off the 90 to 240 VAC that the device is intended to control all in a nice box. In addition, you get firmware on the chip, a free Android or Apple app, and a service to connect between the chip and the app for control and status. That means you can easily get up and running to see what is possible. Then you can look at doing your own firmware, control network. and software.

Itead says

Our goal is to fuel an innovation revolution with easy to use prototyping modules, low cost development platforms, and even custom made solutions to help you get your great ideas in to fruition in the quickest possible time.

Towards this end, they have made it easy to add a header to their boards so you can attach a serial to USB adapter and upload your own firmware. There are several projects online that require just a small step in difficulty from the Itead supplied system. ESPEasy puts a web page on your Sonoff to configure your ESP8266 device including working with some of the more popular home automation systems. Sonoff-Tasmota needs configuration in its source code but is more focused on Sonoff and MQTT. Others include ESPurna and KmanSonoff, and Jonathan Oxer has Six Sonoff Secrets, a blog post with a few more ideas including upgrading the flash RAM.

You can also run micropython on these things. That is rather cramped with the standard memory chip but the code for many Itead accessories and other peripherals you might want to use for an IoT device are readily available.

It’s not much to invest in either money or time or learning to find out what the Internet of Things is all about.


Sonoff, VSCode, ESP8266, IOT

Another Amazon sale, another opportunity. This time is was a 4 pack of basic Sonoff switches. These are $5 boxes controlling a relay via Wifi meaning an app or Alexa. They run off of, and switch, 90-240 VAC and use an ESP8266 for the smarts and radio. As they are easy to take apart and access the ESP and they are cheap, they make good targets for modification and extension, and learning. One example is the Tasmota project

“Provide ESP8266 based Sonoff by iTead Studio and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing ‘Over the Air’ or OTA firmware updates using Arduino IDE.

What you do is to solder a four or five pin header to the circuit board in order to attach a USB to Serial cable. Then you can run the Arduino IDE to update the firmware. Another option is to use PlatformIO with the VSCode IDE,

VSCode or Visual Studio Code is an interesting study itself. Microsoft released it in 2015 as cross platform FOSS (Wikipedia).  The Tasmota Wiki provides step by step instructions. Other ideas raise the question about what compiler the Tasmota process is using. See 

Programming ESP8266 using Visual Studio Code with Arduino Extension by Yoppy Chia

Install the IDE PlatformIO extension for Visual Studio Code (VSCode): Windows, 32-bit Linux

Installing Visual Studio Code for ESP8266

You can start with just using the Sonoff as-is and follow the instructions to set up the eWeLink app or Alexa Skill. From there, the sky’s the limit. Setting up Tasmota and an MQTT system has good step by step instruction as a paved road. That will set you up for code modification or creation and ESP8266 application development. Then you can start to learn about the Integrated Development Environments. And that just a start.

Sleep tracking

One thing leads to another and fitness trackers for sleep monitoring is no exception. The Simple Dollar post showed up referring to an app that tracks sleep via your phone’s accelerometer and microphone without needing additional hardware: A Simple Tactic for Improving Sleep That 84% of People Miss by  Drew Housman.

The post has some good information about sleep and its health effects as well as a few ideas for sleep monitoring. The app cited is Sleep Cycle alarm clock with free and premium versions. The app website also has some interesting reading.

Wrist Actigraphy and Latest Crazes: Fitness Trackers

It started with a report based on How Much Sleep Do Fitbit Users Really Get? A New Study Finds Out by Danielle Kosecki. That lead to research about Wrist actigraphy. And then Amazon had a sale on the Letscom Fitness Tracker. Actigraphy has been around since the 50’s. The cell phone sensor revolution has put it into the realm of every day, every man use.

A fitness tracker is a stripped down cell phone worn on the wrist. Bluetooth is the usual communications method used to pass data to a cell phone app. The sensors are an accelerometer and a pulse meter. A display, battery, and an SOC round out the package. On the Letscom, the accelerometer is  Kionix KX022 and the SOC is a Nordic nRF51822. From a modern hardware perspective, there isn’t much there. It’s the software and the social and cultural aspects that make the product.

First up on software is the device firmware. It needs to track activity and control and present its measures in a reasonable fashion. It also usually provides wrist watch functions and some Smartphone coordination for alarms and messaging.

The second level is the phone app. Letscom uses VeryFitPro (Google Play). Google has been involved in this area and has Google Fit for an API and some other standardization for sharing on social networks and interactions between devices. It is this sharing that Fitbit may be using with cloud storage to collect data from its users that makes data mining research feasible and useful. The app provides extended data storage and analysis for the fitness tracker as well as serving as a larger display and control and configuration device.

Third level software is where the fun starts. That is where you tap into the data flow for doing your own presentation and analysis. This is not directly supported but there are several websites out there about methods to get fitness tracker data to your own database.

The Letscom costs quite a bit less than the market leading FitBit. It seems well built and both the firmware and the app are well rated and quite usable. Even at the normal $30 Amazon price, it offers a lot for the cost, especially as a starting point on how the development of modern sensors can be used for new products and in reducing costs of medical studies or other quality of life interests.

The problem with science is people

This is a book review. The field is medicine but the concepts apply to any ‘fuzzy’ research (including climate change and weather).

Rigor Mortis: What’s Wrong with Medical Science and How to Fix It by Harriet Hall — “Medical research has been plagued by less-than-rigorous practices and a culture that rewards quantity over quality. In a new book, Richard Harris identifies the problems, proposes solutions, and offers hope.”

“Scientific medicine has made great strides, but much of today’s research is unreliable. As Harris says, “Biomedicine’s entire culture is in need of serious repair.” He has done a stellar job of identifying the problems, possible solutions, and promising efforts that are already underway. Research jobs and tenure in academia should be awarded based on quality, not quantity of papers published. Studies must be replicated before they are relied on to direct future research. We need better incentives: today, it pays to be first to publish; it doesn’t pay to be right. We can do better. We are trying to do better.

Anyone who does research or reads about research studies will profit from reading this book. It’s well-written and accessible, with short chapters and lots of entertaining vignettes.

There are some interesting lists about faults found and issues discovered.


Why Modern Computers Struggle to Match the Input Latency of an Apple IIe By Joel Hruska — “The system with the lowest input latency — the amount of time between when you hit a key and that keystroke appears on the computer — is the Apple IIe, at 30ms.”

There is a table of measurements that included latency, clock speed and computer year. It doesn’t include the TRS-80 nor list CPU so you can’t tell how much latency is based on system design or CPU design or other factors. The table does list the number of transistors in the CPU’s under test. “the color coding shows that chips with higher numbers of transistors tend to be in systems with more latency, and faster systems tend to be older than slower ones.”

An Apple IIe isn’t handling sophisticated multi-tasking commands. It isn’t juggling background threads, or dealing with multiple applications that aren’t designed to be aware (or careful) of one another. It isn’t polling a huge array of devices that range from audio and network controllers to discrete GPUs and storage. The Apple IIe OS doesn’t use a compositing window manager, which adds latency. This article, by Pavel Fatin, is an in-depth breakdown on latency processing and discusses how each much delay each step in a modern system adds, from keyboard scan to final output.

Latency is a big issue in movies as well as people notice when the lip sync gets too far off. Typists learn to touch type and that doesn’t involve latency except that the machine can keep up. Virtual reality, gaming, and graphics can make latency critical for error reduction. The real question is how much is OK and how much is too much. Human’s have latency, too,