12 Results

mqtt

Search

The Pi Cap adds capacitive touch buttons to your Raspberry Pi. Bare Conductive was kind enough to send me one. I do not have a project in mind right now, so here are my first impressions.

What is the Pi Cap?

Arduino tends to call daughter cards shields, while the Raspberry Pi community calls them hats. The Pi Cap is a hat. It plugs into the GPIO header of a Raspberry Pi and provides 13 capacitive touch pads. There is a traditional push button, an LED, and a prototyping area. While the Pi Cap does consume all of the GPIO pins, several are broken out near the GPIO header.

The Arduino serial monitor is usable when you want to watch data from an Arduino. However, it does not have a built-in method for saving the data. Here are some ideas if you want to build an Arduino data logger with or without a PC.

Important note on Arduino Data Logger examples

With all of these examples, please remember that whenever you open the Arduino’s serial port, the board will reset. So if your log file shows “Initializing SD card…” with a few data lines in between, it is because there is a reset happening.


Initializing SD card…initialized.
Temp: 34, Time: 03:24:44
Temp: 33, Time: 03:24:45
Temp: 34, Time: 03:24:46
Tem

Initializing SD card…initialized.
Temp: 34, Time: 03:24:50
Temp: 34, Time: 03:24:51
Temp: 33, Time: 03:24:52
Temp: 34, Time: 03:24:53

In that code you can see data logging started and then restarted. What happened is that after programming, the board starts logging. Then when you open the Serial Monitor, the data logger restarts.

To solve this issue, either disable auto-reset, add a 3-4 second delay at the start of setup(), wait for a character to be received, or wait for a button press. That will give you time to open the Serial Monitor.

Sending simple serial commands to an Arduino is the easiest way to communicate between an Arduino and a computer. The computer could be a PC, a Raspberry Pi, or any device that communicates with serial.

By sending and “decoding” a single character it is easy to add a simple debug menu or even serial menu. Plus, it is easy to extend.

Single Character vs. Full Words

The mistake I see many people make is that they try to send full-text strings as serial commands. For example, to turn on a LED, I have seen (silly) commands like “RED LED ON” or “RED LED OFF.” While you could use something like strcmp(), as I showed on the Multiple MQTT Topics example, that tends to be overkill for most serial commands.

Humans like words, computers like binary. Just send one character over serial.


switch (variable) {
  case 'a':
	// A Stuff

  case 'b':
  case 'c':
	// B and C Stuff
  break;
}

While many want to call 2016 the worst year ever, I feel that is an entirely undeserved title. It certainly could have been a better year, but it wasn’t the worst that I can remember. For the engineering community, both professional and hobbyist, it seems to have been a fantastic year. My gauge for this feeling is the activity on baldengineer.com. In 2016, I saw almost half a million sessions contributing over 1.2 million page views. (That’s 98% more people looking at 313% more tutorials compared to 2015.)

Here’s a breakdown of the most visited pages (tutorials) on the site.

Overall Top 5 Tutorials for 2016

First up is a simple list with the most views, across all content.

  1. MQTT Tutorial for Raspberry Pi, Arduino, and ESP8266
  2. Raspberry Pi GUI Tutorial
  3. millis() Tutorial: Arduino Multitasking
  4. Arduino, how do you reset mills()?
  5. Top 4 transistors for your kit

Getting back to my IoT projects, I decided to pick up a temperature sensor. While looking through the Adafruit breakout boards, I found they offered nine different digital temperature sensors! This list is in addition to the analog TMP36 temperature sensor, so that’s ten. I needed an Adafruit Temperature Sensor comparison.

With so many options, I quickly found myself getting lost between the various modules. The 10 I found all measured temperature and provided an I2C interface. Except for the MCP9808 board, they all made at least one other type of measurement. The MCP9808 is the cheapest digital temperature sensor breakout that Adafruit offers, and also the most accurate.

I couldn’t find a comparison in my quick search, so I built my own comparison table. Here’s my chart for an Adafruit Temperature Sensor comparison of their breakout boards.