Building A Simple Python API for Internet of Things Gadgets

It’s no secret that I rather enjoy connecting things to the Internet for fun and profit. One of the tricks I’ve learned along the way is to spin up simple APIs that can be used when prototyping a project. It’s easy to do, and simple to understand so I’m happy to share what has worked for me, using Web2Py as the example (with guest appearances from ESP8266 and NodeMCU).

Barring the times I’m just being silly, there are two reasons I might do this. Most commonly I’ll need to collect data from a device, typically to be stored for later analysis but occasionally to trigger some action on a server in the cloud. Less commonly, I’ll need a device to change its behavior based on instructions received via the Internet.

Etherscan is an example of an API that saves me a lot of work, letting me pull data from Ethereum using a variety of devices.

In the former case, my first option has always been to use IoT frameworks like Thingsboard or Ubidots to receive and display data. They have the advantage of being easy to use, and have rich features. They can even react to data and send instruction back to devices. In the latter case, I usually find myself using an application programming interface (API) – some service open on the Internet that my device can easily request data from, for example the weather, blockchain transactions, or new email notifications.

Occasionally, I end up with a type of data that requires processing or is not well structured for storage on these services, or else I need a device to request data that is private or that no one is presently offering. Most commonly, I need to change some parameter in a few connected devices without the trouble of finding them, opening all the cases, and reprogramming them all.

At these times it’s useful to be able to build simple, short-lived services that fill in these gaps during prototyping. Far from being a secure or consumer-ready product, we just need something we can try out to see if an idea is worth developing further. There are many valid ways to do this, but my first choice is Web2Py, a relatively easy to use open-source framework for developing web applications in Python. It supports both Python 2.7 and 3.0, although we’ll be using Python 3 today.

Continue reading “Building A Simple Python API for Internet of Things Gadgets”

The Woeful World of Worldwide E-Waste

How large is the cache of discarded electronics in your home? They were once expensive and cherished items, but now they’re a question-mark for responsible disposal. I’m going to dig into this problem — which goes far beyond your collection of dead smartphones — as well as the issues of where this stuff ends up versus where it should end up. I’m even going to demystify the WEEE mark (that crossed out trashcan icon you’ve been noticing on your gadgets), talk about how much jumbo jets weigh, and touch on circular economies, in the pursuit of better understanding of the waste streams modern gadgets generate.

Our lives are encountering an increasing number of “how do I dispose of this [X]” moments, where X is piles of old batteries, LCDs, desktop towers, etc. This leads to relationship-testing piles of garbage potential in a garage or the bottom of a closet. Sometimes that old gear gets sold or donated. Sometimes there’s a handy e-waste campaign that swings through the neighborhood to scoop that pile up, and sometimes it eventually ends up in the trash wrapped in that dirty feeling that we did something wrong. We’ve all been there; it’s easy to discover that responsible disposal of our old electronics can be hard.

Fun fact: the average person who lives in the US generates 20 kg of e-waste annually (or about 44 freedom pounds). That’s not unique, in the UK it’s about 23 kg (that’s 23 in common kilograms), 24 kg for Denmark, and on and on. That’s quite a lot for an individual human, right? What makes up that much waste for one person? For that matter, what sorts of waste is tracked in the bogus sounding e-waste statistics you see bleated out in pleading Facebook posts? Unsurprisingly there are some common definitions. And the Very Serious People people at the World Economic Forum who bring you the definitions have some solutions to consider too.

We spend a lot of time figuring out how to build this stuff. Are we spending enough time planning for what to do with the gear once it falls out of favor? Let’s get to the bottom of this rubbish.
Continue reading “The Woeful World of Worldwide E-Waste”

Naomi Wu On The Sino:Bit, 3D Printers, And Open Source Hardware In China

Many readers will be familiar with [Naomi Wu], the prolific hardware hacker who has shown us so much of the epicentre of Chinese tech in her native Shenzhen through a lens that most outsiders would struggle to achieve. We’ve seen her touring factories and electronics marts, building a load of interesting projects, and achieving the first open source hardware certifications in China.

We’ve seen a lot of [Naomi] speaking to us in English as an audience outside her country, so it is extremely interesting to see her latest video posting in which she makes her case for open source hardware in Chinese to a Chinese audience (Chinese audio with English subtitles). She’s speaking at the recent China open source conference, and her description starts with “**THIS IS VERY BORING UNLESS YOU ARE INTO OPEN SOURCE**”, which we think is a little unfair as it should appeal to anyone with an interest in the Chinese tech business.

In the talk she takes us through the potential benefits of open source to Chinese business by using her projects as case studies. In particular she concentrates on how the arguments for open source in a commercial arena have to be made differently for a Chinese business to those used in the rest of the world. Using the analogy of a college dorm hotpot party, she outlines the importance of a community in open-source development, then we get a blow-by blow account of her work with Elecrow and Creality on the Sino:bit (a single-board computer targeting education in China) and the 3D printers.

The software support for the Sino:bit in particular demonstrates the added value of open source to a business, with significant tutorial and curriculum material coming from Adafruit Industries, Hindi language and character set support from developers in India, and a Chinese developer painstakingly transcribing all the Chinese character set for the device. That last step alone would have cost a non open-source developer a significant sum.

During her talk we are shown the commercial benefits to all three devices, for example one of the Creality 3D printers rapidly becoming Amazon’s top seller despite an array of knock-off machines appearing. We’ve embedded the video below the break, and we think it should be required viewing for anyone with an interest in open source or the Chinese tech industry.

Once you have seen the video you might find [Naomi’s] guide to buying on Taobao to be of interest, as well as her explanation of the Chinese cultural attitude to engineers while introducing us to the historical master craftsman, [Lu Ban].

Continue reading “Naomi Wu On The Sino:Bit, 3D Printers, And Open Source Hardware In China”

Single Board Computer Plays Nice with NVIDIA GPU

It’s about convenience when it comes to single board computers. The trade-off of raw compute power for size means the bulk of them end up being ARM based, but there are a few exceptions like the x86 based Udoo Ultra. The embedded Intel 405 GPU on the Udoo Ultra is better than most in the category, but that won’t begin to play much of anything outside of a browser window. Not satisfied with “standard” [Matteo] put together his build combining an Udoo x86 Ultra with a NVIDIA 1060 GPU. It seems ridiculous to have an expansion card almost three times longer than the entire computer its attached to, but since when did being ridiculous stop anyone in the pursuit of a few more polygons?

M.2 adapter board trim comparison
M.2 to PCIe adapter board (Top) Trimmed adapter board (Bottom)

Since the Udoo Ultra doesn’t feature a PCIe slot [Matteo] slotted in a M.2 to PCIe adapter board. There are two PCIe lines accessible by the Udoo Ultra’s M.2 port although trimming the adapter board was required in order to fit. The PCIe female slot was cut open to allow the 1060 GPU to slide in. All of the throughput of the 1060 GPU wouldn’t be utilized given the Udoo Ultra’s limitations anyway.

Windows 10 was the OS chosen for the machine so that all those NVIDIA drivers could be installed, and there’s also the added benefit of being able to sneak in a little Trackmania Turbo too. So to accompany the build, [Matteo] created a graphics comparison video to show the remarkable improvement over the embedded graphics chip. You can see the Time Spy benchmark results in the video below.

Continue reading “Single Board Computer Plays Nice with NVIDIA GPU”

Inductance in PCB Layout: The Good, the Bad, and the Fugly

When current flows through a conductor it becomes an inductor, when there is an inductor there is an electromagnetic field (EM). This can cause a variety of issues during PCB layout if you don’t plan properly, and sometimes we get burned even when we think we have planned for unwanted inductance and the effects that come with them.

When doing high speed logic we need to be able to deliver sudden changes in current to the devices if we want to have proper switching times and logic levels. Unfortunately inductance is usually not a friend in these circumstances as it resists those sudden changes in current. If the high speed devices are driving capacitive loads, which themselves are resisting changes in voltage, even more instantaneous current is needed.

Simply put, inductors resist a change of current, and can act as a low pass filter when in series with the signal or power supply flow. Inductors do this by storing energy in the flux surrounding the conductor. Alternatively capacitors resist a change in voltage (again by storing energy) and can act as a high pass filter when in series with the signal. This makes them a valuable tool in the fight against unwanted inductance in power supply distribution.

In the video below, and the remainder of this article, I’m going to dive into the concept of inductance and how it affects our design choices when laying out circuit boards.

Continue reading “Inductance in PCB Layout: The Good, the Bad, and the Fugly”

DIY Tiny Dyno

The geared DC motor has become the bread-and-butter of the modern-day beginner project. Unfortunately, with the advent of vast online catalogs peddling a wide assortment of these mechanical marvels, validating the claim that one DC motor will outperform the others is a challenge.

Such is the dilemma that our own [Gerrit Coetzee] faced as he set out to buy these geared motors in bulk. In his initial teardown, he quickly compares the change in design, from the original which possess the two-part clutch that extends on overloading, to the clones with the feature disabled altogether.

He then goes on to research methods of measuring the motor’s output where he discovers the Prony Brake which leads to the Rope Brake Dynamometer. This is where things get interesting and [Gerrit Coetzee] goes on to hack his own version of the machine. The idea is to have a rope wound to the wheel that is powered by the motor. With one end of the cord attached to a spring scale and the other end to a suspended weight, the motor speed affects the force on the spring scale. This change in force measured by the scale can be used to calculate the power output by the motor.

[Gerrit Coetzee] goes on to replace the weight with springs and the scale with an electronic load cell while using a stepper motor to stretch the cord thereby adding the requisite tension to the string. We thought this was a very elegant solution where the entire experiment could be controlled electronically.

This is a work in progress through the writeup is an excellent example of how to tailor a traditional experiment to the modern times. We have seen similar investigations for larger salvaged motors and dynamometers with lots of sensors.

Nuclear Synchroscope Gets New Life

The Synchroscope is an interesting power plant instrument which doubles up as two devices in one. If the generator frequency is not matched with the grid frequency, the rotation direction of the synchroscope pointer indicates if the frequency (generator speed) needs to be increased or decreased. When it stops rotating, the pointer angle indicates the phase difference between the generator and the grid. When [badjer1] [Chris Muncy] got his hands on an old synchroscope which had seen better days at a nuclear power plant control room, he decided to use it as the enclosure for a long-pending plan to build a Nixie Tube project. The result — an Arduino Nixie Clock and Weather Station — is a retro-modern looking instrument which indicates time, temperature, pressure and humidity and the synchroscope pointer now indicates atmospheric pressure.

Rather than replicating existing designs, he decided to build his project from scratch, learning new techniques and tricks while improving his design as he progressed. [badjer1] is a Fortran old-timer, so kudos to him for taking a plunge into the Arduino ecosystem. Other than the funky enclosure, most of the electronics are assembled from off-the-shelf modules. The synchroscope was not large enough to accommodate the electronics, so [badjer1] had to split it into two halves, and add a clear acrylic box in the middle to house it all. He stuck in a few LEDs inside the enclosure for added visual effect. Probably his biggest challenge, other than the mechanical assembly, was making sure he got the cutouts for the Nixie tubes on the display panel right. One wrong move and he would have ended up with a piece of aluminum junk and a missing face panel.

Being new to Arduino, he was careful with breaking up his code into manageable chunks, and peppering it with lots of comments, for his own, and everyone else’s, benefit. The electronics and hardware assembly are also equally well detailed, should anyone else want to attempt to replicate his build. There is still room for improvement, especially with the sensor mounting, but for now, [badjer1] seems pretty happy with the result. Check out the demo video after the break.

Thanks for the tip, [Chris Muncy].

Continue reading “Nuclear Synchroscope Gets New Life”