Monitoring a switch, in Toit

The purpose of this trivial sample is to better understand how to write power efficient code in Toit. Warning, as is, it is not power efficient. For a device to be able to operate without a battery change for a year, requires careful consideration of the power consumption of sensors, peripherals, power supply, processor and radio used. Modern processors, with a multitude of subsystems, have various sleep states with some combination of features and power....

August 24, 2021

Power profiling the ESP32, running Toit

Updated 2021-09-14, see below The temperature-humidity sensor that I wrote about here only has a battery life of several days on a 1200 mAh LiPo battery, making any usage longer than a test impractical. As originally configured, the data acquisition application ran every 15 minutes and the “Max offline” time was 17 minutes. To understand the power consumption, the Nordic Semiconductor Power Profiler Kit II (PPK II) was connected to the breadboard, as shown in the photo:...

August 16, 2021

Serial interface to DYP-AO1 ultrasonic sensor, with Toit

An inexpensive way to measure longer distances is with an ultrasonic sensor, fitted with a horn, such as the DYP-A01. Range is nominated at 0.28-7.5m and the sensor has serial and PWM outputs. The serial connection is used in this sample, at 9600 baud. The sample app runs periodically, to range the distance and exit. Triggering of a measurement is possible, by driving the sensor RX line, but not implemented here....

August 15, 2021

Measuring the Heat Index, with Toit

I live in Phoenix and they like to say “it’s a dry heat” when it is 117F (47C). However, less is said during the monsoon season (officially Jun 15 – Sep 30), when it might only be get to 105F but with high humidity. As I write this, it is 104F with a 30% relative humidity. According to the National Oceanic and Atmospheric Administration (NOAA), that is dangerous. Why? Because humans use evaporative cooling (sweat) to cool, and sweating becomes less efficient as the humidity climbs....

August 1, 2021

First device driver in Toit

Toit is a language for embedded development on microcontrollers, targeting the ESP32. Like CircuitPython or TinyGo, language libraries provide access to microcontroller peripherals and developers are insulated from the OS. Toit goes significantly further, by addressing device onboarding/lifecycle, monitoring and fleet management, with both a command line and web console interfaces. Programming on the device is in the Toit language, including drivers for devices connected over SPI or I2C, as described in the Write a driver guide....

May 28, 2021

Wren as a CoAP handler

The Try Wren page allows you to execute Wren scripts directly in your browser, reducing the barrier to try language features and syntax, to zero. To emulate this simplicity in the IoT environment, the Constrained Application Protocol (CoAP) was leveraged to provide a lightweight RESTful protocol to a target board, the Adafruit Feather nRF52840 Express. From the CoAP website, “The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things....

November 9, 2020

Wren on a nRF52840 ... does it fit?

Writing software for a microcontroller is significantly different than writing for other desktop, mobile, web or server platforms. There is large choice in chip vendor, chip architectures and operating systems with usually severe resource constraints. Likely because of this, there is no well developed application model, like there is say on mobile with iOS and Android. This leads to developers being responsible for the full software stack. Several approaches have been taken to reduce the developer burden, including Arduino and CircuitPython, where for supported set of boards you can program in derivatives of Processing or Python languages....

November 5, 2020