Tag Archives: microSD

Adafruit builds a smart (Yún) measuring cup

Adafruit’s Tony DiCola has put together a detailed tutorial explaining how to build a smart measuring cup that displays the volume of liquid in a real time on a web page. The brains behind the smart measuring cup? An Atmel-powered Arduino Yún (ATmega32u4) and an eTape liquid level sensor.

Additional project components include:

  • Female to male hookup wires
  • Graduated cylinder or other container to hold liquids
MicroSD card for storing scripts and data

“The Yun is the perfect platform for this project because it can read sensor data with it’s ATmega microcontroller and serve a web application (written in python and Flask) using it’s Linux-based processor,” DiCola explained.

“No longer will you need to squint and guess while measuring liquids; the smart measuring cup’s web page clearly shows the measured volume and even converts between units or tares measurements like a digital scale!”

As DiCola notes, the assembly of the hardware is relatively simple as the eTape liquid sensor is actually a resistive sensor, just like a photocell.

“Attach one of the middle two leads to ground on the Arduino. Attach the other middle lead to an analog input such as analog 0 on the Arduino,” said DiCola.

“Finally, attach the 560 ohm resistor that comes with the sensor between the analog 0 and 5 volt pins on the Arduino. The outer two pins on the sensor will be unused (they’re for temperature compensation in a bridge configuration).”

Next up? Attach the liquid sensor to a container. First, DiCola recommends placing the sensor against a wall of the container. Then, ensure the sensor is hanging vertically without bends or crimps.

“Only the top portion of the sensor above the MAX line can be attached to the container,” he emphasized.

“The rest of the sensor must be allowed to hang freely so liquid can touch both the front and back of the sensor. [A binder] clip works well as a temporary means of affixing the sensor. For something more permanent consider taping or gluing the top of the sensor to the container (remember only glue or tape the sensor above the MAX line!). Use a food safe adhesive such as silicone sealant if necessary.”

After attaching the sensor, Makers can run an Arduino calibration sketch to report the volume of measured liquid. Last, but certainly not least, the Arduino Yún should be configured to display the measured volume on a web page that updates in real time.

“This project is an example of how to use an eTape liquid level sensor to build a smart web-enabled measuring cup,” DiCola concluded. “You can use the code from this guide to help get any sensor data onto a web page using an Arduino Yún.”

With some tweaking, future project uses could include:

  • Logging volume or liquid level data to a cloud service such as Google Docs or Amazon DynamoDB.
  • Putting a water level sensor in your home’s sump pump and send an SMS message when water is rising dangerously high.
  • Making a web application to help you mix drinks and other concoctions with the liquid sensor.

As we’ve previously discussed on Bits & Pieces, the Atmel-powered Yún has been used in a wide variety of Maker projects that we’ve recently covered, including an electricity monitormesh extender platformFoursquare soap bubble machine, a Gmail (alert) lampwater heater regulator and a security camera.

Interested in learning more about building a smart measuring cup? You can check out Tony DiCola’s detailed tutorial on Adafruit’s Learning System here.


This SD card logger library fits on an ATmega8

David Gironi has designed an SD card logger library – with log rotation – that neatly fits on an ATmega8 microcontroller (MCU). Precise date and time are obtained via a DS1307 chip.

“This library implements an SD card data logger that runs on [an] ATmega,” Gironi explained in a recent blog post.

“It has a small footprint, so it can be loaded on an ATmega8, leaving space for user code; [while also] supporting SD and microSD cards formatted with FAT16.”

According to Gironi, the “Petit FAT File System Module” by ChaN is used to facilitate write capabilities to the SD card.

“We had to format the card we would like to use with FAT16 and then load it with a predefined number of empty files of a know dimension,” Gironi continued.

“Once we have files on the card, we can write on those files. You can create empty files by using the python helper provided in code.”

Configuring file dimension and number is executed on the firmware side, although the file dimension cannot be greater than 2^16 bytes as a uint16_t type variable is used to store this information. Similarly, the max number of files is limited to 256, because a uint8_t variable is employed.

“Given the number of files used by the logger and every file size, we just have to record the last written position and the file number we are using to implements the log rotation,” added Gironi. “When a file is filled up with logged data, it skips to the next one, if the file is the last one, we go back to first.”

Interested in learning more? You can check out the project on David Gironi’s official page here.