Avoiding Exercise With An ESP8266 And Blynk

[Mike Diamond] was tired of climbing down (and back up) 40 stairs to check his mailbox. He decided to create a mailbox alert using the ESP8266 to connect to his WiFi. The idea was simple: have the ESP8266 monitor when the mailbox flap opened using a magnet and a reed switch. As always, though, the devil is in the details. [Mike] got things working with a little help and shares not only the finished design but how he got there.

To handle the sending of e-mail, [Mike] used the Blynk app. You often think of Blynk as a way to build user interfaces on an Android or iOS device that can control an Arduino. In this case, though, [Mike] used the library with the ESP8266 and had it send e-mail on his behalf.

Continue reading “Avoiding Exercise With An ESP8266 And Blynk”

What’s Special About Fifty Ohms?

If you’ve worked with radios or other high-frequency circuits, you’ve probably noticed the prevalence of 50 ohm coax. Sure, you sometimes see 75 ohm coax, but overwhelmingly, RF circuits work at 50 ohms.

[Microwaves 101] has an interesting article about how this became the ubiquitous match. Apparently in the 1930s, radio transmitters were pushing towards higher power levels. You generally think that thicker wires have less loss. For coax cable carrying RF though, it’s a bit more complicated.

First, RF signals exhibit the skin effect–they don’t travel in the center of the conductor. Second, the dielectric material (that is, the insulator between the inner and outer conductors) plays a role. The impedance is also a function of the dielectric material and the diameter of the center conductor.

Continue reading “What’s Special About Fifty Ohms?”

Open Source Solar

What’s the size of a standard euro-palette, goes together in 15 minutes, and can charge 120 mobile phones at one time? At least one correct answer is Sunzilla, the open source solar power generator. The device does use some proprietary components, but the entire design is open source. It contains solar panels, of course, as well as storage capacity and an inverter.

You can see a video about the project below. The design is modular so you can pick and choose what you want. It also is portable, stackable, and easy to transport. The team claims they generate 900W of solar power and can store 4 kWh. Because of the storage device, the peak power out is 1600W and the output is 230V 50Hz AC.

Continue reading “Open Source Solar”

Capacitors Are Simple, Right?

It is easy to dismiss passive components like resistors and capacitors as a boring subject. [James Lewis] of KEMET Capacitors would disagree. He gave a talk about capacitor tech that is both approachable and in-depth.

Like every other component we use, we always think of them as perfect. But just like wires have resistance and inductance that we often ignore, capacitors have different imperfect characteristics that you need to be aware of.

Ceramic capacitors, for example, lose capacitance over time. Different ceramic material have different temperature sensitivity. Aluminum capacitors don’t last forever. Voltage applied to a capacitor can change its value as much as 50%.

[James] also talks about polymer electrolytics and super capacitors. His burning question: Is there any truth to the old guideline that you should derate capacitors by 50%? Want to know what he thinks? Watch the video below. Speaking of burning, he tackles the touchy subject of tantalum capacitors. The image at the top is a test Kemet ran on their own parts at reverse polarity well beyond spec. All of them are blown but only some look burnt. That’s a mystery well worth watching the talk.

Continue reading “Capacitors Are Simple, Right?”

Join The GUI Generation: QTCreator

More and more projects require a software component these days. With everything being networked, it is getting harder to avoid having to provide software for a desktop or phone environment as well as the code in your embedded device.

If you’ve done a lot of embedded systems work, you probably already know C and C++. If so, it is pretty easy to grab up a C compiler and write a command-line application that does what you want. The problem is that today’s users have varying degrees of fear about the command line ranging from discomfort to sheer terror. On a mobile device, they probably don’t even know how to get to a command line. I’ve been waiting for years for the WIMP (Windows/Icon/Mouse/Pointer) fad to fade away, but even I have to admit that it is probably here for the foreseeable future.

qtrigolSo what’s the alternative? There are actually quite a few. However, I wanted to talk about one that is free, has a wide range of deployment options, uses C++, and is easy to pick up: Qt. Specifically, creating programs with QtCreator (see right). Yes, there are other options, and you can develop Qt programs in a number of ways.

You might think Qt isn’t free. There was a time that it was free for open source projects, but not for commercial projects. However, recent licensing changes (as of version 4.5) have made it more like using gcc. You can elect to use the LGPL which means it is easy to use the Qt shared libraries with closed software. You might also think that a lot of strange constructs that “extend” C++ in unusual ways. The truth is, it does, but with QtCreator, you probably won’t need to know anything about that since the tool will set up most, if not all, of that for you.

Background

If you ever used Visual Basic or something similar, you will feel right at home with QtCreator. You can place buttons and text edit boxes and other widgets on a form and then back them up with code. Buttons create signals when you push them. There are lots of signals like text changed or widgets (controls) being created or destroyed.

To handle a signal, an object provides a slot. There is a meta-compiler that preprocesses your C++ code to get all the signal and slot stuff converted into regular C++. Here’s the good news: you don’t really care. In QtCreator you can write code to handle a button push and exactly how that happens isn’t really much of a worry.

QtCreator has kits that can target different platforms and — in general — the code is reasonably portable between platforms. If you do want to do mobile development for Android or iOS, be sure that you understand the limitations before you start so you can avoid future pitfalls.

You Need Class

Like many similar frameworks, Qt uses an application class (QtApplication) that represents a do-nothing application. Your job is to customize a subclass and have it do what you want. You add widgets and you can even add more screens, if you like. You can connect signals to existing slots or new slots.

There are many classes available, and the online documentation is quite good. Depending on which version of Qt you are using, you’ll need to find the right page (or ask QtCreator to find it for you). However, just to whet your appetite, here’s the Qt5 reference page. From there you can find classes for GUI widgets, strings, network sockets, database queries, and even serial ports.

I could do an entire tutorial on using QtCreator, but it would be a duplication of effort. There’s already a great getting started one provided. You’ll find there is plenty of documentation.

Portability

How do you enumerate serial ports? It depends on the platform, right? In Qt, the platform-specific part is hidden from you. For example, here’s a bit of code that fills in a combo box with the available serial port:

MainWindow::MainWindow(QWidget *parent) :
 QMainWindow(parent),
 ui(new Ui::MainWindow)
{
 ui->setupUi(this);
// initialize list of serial ports
 ports = QSerialPortInfo::availablePorts();
// fill in combo box
 for (int i=0; i<ports.length(); i++) 
 {
   ui->comport->addItem(ports[i].portName(), QVariant(i));
 }
}

The QSerialPortInfo object provides an array of serial port objects. The ui->comport is a combo box and the addItem method lets me put a display string and a data item in for each selection. In this case, the display is the portName of the port and the extra data is just the index in the array (as a variant, which could be different types of data, not just a number). When you select a port, the index lets the program look up the port to, for example, open it.

When the combo box changes, a currentIndexChanged signal will occur. Here’s the slot handler for that:

void MainWindow::on_comport_currentIndexChanged(int index)
{
 QString out;
 // get selected index
 int sel=ui->comport->currentData().toInt();
// build up HTML info string in out
 out="<h1>Serial Port Info</h1>";
 ui->output->clear();
 out += ports[sel].portName() + " " + ports[sel].description() + "
";
 out += ports[sel].systemLocation() + "
";
 if (ports[sel].hasVendorIdentifier() && ports[sel].hasProductIdentifier())
 out += ports[sel].manufacturer() + " ("+ QString::number(ports[sel].vendorIdentifier(),16) + ":" + QString::number(ports[sel].productIdentifier(),16) + ")";
 // and put it on the screen
 ui->output->setText(out);
}

In this case, the result is information about the serial port. You can see the resulting output, below. The QString is Qt’s string class and, obviously, the text display widget understands some HTML.

qtserial

Not Just for GUIs

You can develop console applications using Qt, but then many of the provided classes don’t make sense. There’s even a Qt for Embedded (essentially Linux with no GUI). You can find guides for Raspberry Pi and BeagleBoard.

On the mobile side, you can target Android, iOS, and even Blackberry, along with others. Like anything, it probably won’t just be “push a button” and a ported application will fall out. But it still should cut down on development time and cost compared to rewriting a mobile app from scratch.

And the Winner Is…

I’m sure if you want some alternatives, our comment section is about to fill up with recommendations. Some of them are probably good. But it strikes me that not everyone has the same needs and background. The best tool for you might not work as well for me. I find Qt useful and productive.

Even if Qt isn’t your tool of choice, it still can be handy to have in your tool bag. You never know when you will need a quick and dirty cross-platform application.

Retrotechtacular: DC To DC Conversion By Vibrator

Electricity comes in two basic forms: Alternating Current (AC) and Direct Current (DC). DC is handy to use and is easy to analyze. However, AC has some useful properties too. In particular, AC current can operate a transformer which can step it up or down easily. Power is conserved, of course (well, actually, you get less power because of losses in the transformer).

You can’t do that trick with pure DC. You can reduce a voltage, although that typically wastes power in heat (for example, a voltage divider or linear regulator). You can’t readily increase a DC voltage unless you convert it into some sort of AC first.

This was a particularly bad problem in the era of tubes–especially tubes in car radios. The car’s voltage was probably 12V but the tube’s plates might take hundreds of volts. What do you do? Some old car radios used what is called a dynamotor. This is just a motor and a generator in one box. You could spin the motor with 12V and have the generator produce a different voltage (even a DC voltage).

Continue reading “Retrotechtacular: DC To DC Conversion By Vibrator”

The (Copper) Crystal Method

One of the staples of kitchen chemistry for kids is making sugar crystals or rock candy. Why not? It is educational and it tastes good, too. [Science with Screens] has a different kind of crystal in mind: copper crystals. You can see the result in the video below.

To grow pure metal crystals, he used copper wire and copper sulfate. He also used a special regulated power supply to create a low voltage to control the current used to form the crystal. The current needed to be no more than 10mA, and an LM317 holds the voltage constant. However, that regulator only goes as low as 1.25V, so diodes cut a volt off the output.

Continue reading “The (Copper) Crystal Method”