Arduino Data Logger: Serial Monitor Alternatives

Forget the serial monitor, here's 5 other ways to do Arduino data logging

arduino data logger options

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

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.

Continue Reading »

The latest AddOhms looks at why you need a pull-up resistor when using push-buttons. This video goes into what happens when you leave a pin floating, what a floating pin means, and how the pull-up actually works. You can get more information about the video on the AddOhms Episode page.

This is the 2nd time I’ve made a video on pull-ups. Despite being a single resistor, it can be a difficult topic for new hardware designers to understand. The pull-up video was the first video tutorial I ever made. In fact, the YouTube version uses YouTube’s “stabilization” algorithm, which gives the video a very warped feel.

AddOhms #15 shows improvements in skill over the past couple of years!

Question: What’s another topic that I need to cover in an AddOhms Tutorial? You can leave a comment by clicking here.

Microcontroller state machine with enum tutorial


Flag variables are great, and totally not evil, when you just have two states: ON or OFF. What about when you have multiple states? Is there an option better than creating multiple flag variables?

The C-language has a declaration type just for this purpose. It is called an enumeration, or enum.

Setting up a state machine with enum is a surprisingly simple. Arduino and embedded programmers should use them!

All you need to do is create descriptive tag names, and let the compiler assign them an integer value. Unlike a #define which is just a macro replacement, the compiler treats an enum as your personal variable type.

This behavior comes in handy when you’re creating states for a state machine. I show how to create a simple state machine with enum, to blink an LED with millis(), in this post.

Continue Reading »

Flag variables are not evil (for Microcontrollers)

Non-embedded programs shield your ears: flag variables are good

Fun With Flag Variables

Getting programming questions answered on the internet can be problematic. Programmers love to have opinions, stick to those ideas, and express them to you even when their opinion has nothing to do with your question(s).

Not only am I going to explain how to use flag variables in your code, I am going to encourage their use—which most programmers avoid.

However, this advice comes with two caveats.

  1. This information only applies to limited resource environments like an Arduino, LaunchPad or PIC.
  2. Use flag variables very carefully when you do use them.

The following flag variable usage examples are Arduino-centric but apply to any microcontroller platform, including the Energia project for TI Launchpads.

Continue Reading »

Pushbutton and Flashing LED tutorial with millis()

push button, led, millis, bread board

How to blink (or flash) a LED without delay() and detect button pushes

One of the limitations of the delay() function is that nothing else can really be done. This presents a problem when you want to flash a LED while waiting for a pushbutton to be pressed.

Flashing the LED with millis() and using a flag variable to find if the LED should be flashing solves this problem.

Consider this another example to my virtual millis() cookbook.

This code (below) should work with both Arduino (AVR) and Energia (supported boards), but to be honest, I haven’t had a chance to test it on my MSP430 yet.

Continue Reading »

An Open Source IDE for TI’s line of MSP430-based boards. Based on the same software as the Arduino project, Energia brings easy of use to an awesome family of microcontrollers.

Energia and MSP430: Arduino Alternative

Does Energia stack up as one of the Arduino alternatives?

Energia - An Arduino Alternative

With all the recent noise around Arduino LLC and Arduino SRL, I felt like I needed a break from Arduino. So I decided to come back to a platform I set aside a while ago: TI’s MSP430.

Previously I wrote it off because of the Windows-centric software. In fact, I made my first “review” video based on it. (I’m a Mac / Linux guy.)

In this post, I’m looking at an open source IDE that’s available called Energia. It makes using the MSP430 series boards a snap.  And, by the way, makes for a great Arduino alternative.

Continue Reading »