TinuDHT – ATtiny Library for DHT11

Ever wanted to do a project with that cheap DHT11 temperature/humidity sensor and did not want to go the Arduino way but with a simple ATtiny85? You probably know already about  the issues with the existing Arduino based libraries running on the ATtiny microcontrollers, but can’t deal with them. TinuDHT is our answer to this.

TinuDHT is a C library for working with the DHT11 temperature/humidity sensor intended to be used with the Tinusaur but should also work with any other board based on ATtiny85 or similar microcontroller.

DHT11The DHT11 is very basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor for measurements, and sends out the info to the data pin. It is relatively simple to use it, but requires precise timing to retrieve the data correctly. One disadvantage of this sensor is that you can get new data from it no more often than once every 1 or 2 seconds.

The primary problem with the direct use of the Arduino libraries is that the ATtiny85 and Tinusaur in particular do not have enough resource to handle the send/receive process properly, i.e. not enough CPU power, in result of which the timing of the signals that are sent to the sensor and received from it become messed up. In addition those libraries use Arduino specific code and/or C++ specific syntax which makes them incompatible with the plain C language.

TinuDHT library is based on DHT11Lib code. It was adapted for ATtiny, removed Arduino dependencies and timing was adjusted to work well on ATtiny85 at 1 MHz. There are few other changes and optimizations for speed and size.

TinuDHT is written in plain C and does not require any additional libraries to function except those that come with the WinAVR SDK.

Please go to TinuDHT page to see the full document.

The source code of the TinuDHT library is available at https://bitbucket.org/tinusaur/tinudht.

Tinusaur Board DHT11 LCD Battery

Tutorial 002: Fading LED x1

Another beginners tutorial is on the way – this time about a fading in and out LED.

This is simple tutorial that shows how to connect a LED to the ATtiny85 based Tinusaur board and write a program that makes the LED to fade in and out using PWM (pulse-width-modulation) technique.

PWM Diagram

Note: The code in this tutorial does not use the built-in PWM capabilities of the ATtiny microcontrollers, instead it uses direct bit manipulation since this un easier way to understand how it works. Another tutorial should cover the PWM functionality that is built into the microcontroller.

Tinusaur Board with LEDThe Tinusaur board is a standard ATtiny breakout board so this could be applied to almost any other board that has ATtiny microcontroller on it. The code was tested to work with ATtiny13, ATtiny25, ATtiny45 and ATtiny85 but will probably work on any other ATtiny microcontrollers as well.

Please go to Tutorial 002: Fading LED x1 to see the full document.

You can also check the Tinusaur Board – Assembling Guide and the WinAVR – Setup Guide.

 

WinAVR – Setup Guide

WinAVR is a great tool to do development for Atmel AVR micro-controllers on Microsoft Windows platform. It consists of all the necessary C/C++ compiler, linkers and other GCC tools that you need to write, build and program those micro-controllers.

WinAVR: http://winavr.sourceforge.net

WinAVR
WinAVR (pronounced “whenever”) is a suite of executable, open source software development tools for the Atmel AVR series of RISC microprocessors hosted on the Windows platform. It includes the GNU GCC compiler for C and C++.

Here we have put together very short guide how to setup and use WinAVR for programming the Attiny85 micro-controller and the Tinusaur Board in particular.

The guide was tested mostly under Microsoft Windows 8.1 operating system.

The example source code was tested on ATtiny85 micro-controller installed on a Tinusaur project boards and programmed using USBasp ISP programmer.

Please go to WinAVR – Setup Guide page to read the entire document.

 

 

Assembling Guide

This a short guide about how to assemble the Tinusaur Board.

Tinusaur Board

The Tinusaur Board is what the Tinusaur project is built around. It is rather simple PCB with a dozen components on it.

The board is easy to assemble and does not require very special skills or instruments.

IMPORTANT: If you are uncertain about anything please consult with our website, community or someone more knowledgeable in the subject.

Tinusaur PCB design and layout

There are 4 areas that the Tinusaur board could be divided to: A1, A2, A3, A4.

Assembling

Here is the recommended order of soldering the parts:

  1. MCU socket. Note: do not insert the chip yet.
  2. Capacitors C1, C2 and resistor R1.
  3. Headers H1, H2.
  4. External power header – red.
    Battery on/off header – yellow.
  5. ISP header.
  6. Battery holder.
  7. RESET button.

The battery holder and the battery are optional but if you decided to put them on make sure you solder the battery holder before the RESET button.

IMPORTANT:

External power header (JP1, red, the one closer to the 8-pin header H1) is to connect external power. DO NOT put a jumper there – that could damage the board.

Battery On/Of header (JP2, yellow, the one closer to the mount hole) is to connect/disconnect battery to/from the board. DO NOT have this on while the board is connected to the programmer or external power source – there is no circuit to protect the battery from overcharging.

If you’re not going to use an external power source or the battery on the board don’t put any jumper on at all.

Tinusaur Schematics

Board Components

Name

Description

PCB

Tinusaur Board

MCU, Attiny85

Atmel AVR ATtiny85 microcontroller

Socket, DIP-8

DIP-8 socket for MCU

H1, Header

Header 2×4, Female

H2, Header

Header 2×5, Female

ISP, Header

Header 2×5, Male, for ISP

RESET, Button

Tactile push button, for RESET

Power, Header

Header 1×2, Male, red – external power

Battery, Header

Header 1×2, Male, yellow – battery power on/off

Battery, Jumper

Jumper, 2-pin, yellow – for battery power on/off

C1, Capacitor

Capacitor 100uF, Low profile 5×5 mm

C2, Capacitor

Capacitor 100nF, Small

R1, Resistor

Resistor 10K, Small, 1/8W

Battery holder

Battery holder for CR2032

Battery 3V

Battery 3V, CR2032

Note (about external power source): If you’re going to use external power source (JP1, red in color, the one close to the 8-pin header H1) make sure you connect the negative pole (-) to the outer pin of the header and positive (+) to the inner one.

Note (about battery placement): If you’re going to use the battery in the holder make sure you insert it correctly – that is to have the negative (-) downwards (facing the holder) and the positive (+) (the side with the text markings) upwards.

 

This guide as well as other documents are available as PDF at the Guides page. Please note that any updates will be posted there.

The Tinusaur Online Store Opens

Tinusaur Starter

Finally, our online store is up and running.

We received some emails asking if we could offer the boards and the parts for purchasing … so we did it. We have to admit that it took us some time to arrange everything but some of the circumstances were beyond our control.

At the moment we have only one product listed – that’s the Tinusaur Starter.

Go to this tinusaur.storenvy.com/products/6076006-tinusaur-starter link if you’d like to buy it.

Tinusaur Starter Buy at Storenvy

We have put up for sale very small batch of those starter kits as we don’t know what the interest will be. Please note that at the moment we don’t do this as a business and we do not make any profit – the sale only covers our expenses.

More information about the Tinusaur Starter kit is available at the Tinusaur Starter page.

IMPORTANT: This is offered as a kit which means that you have to assemble it yourself.

We chose Storenvy for our shopping site and we think that it was a good choice – it’s easy to setup and use but also provides all the functionality that we need at this stage. You can pay for your orders with PayPal.

 

February: Quick update

Tinusaur Project Milestones

This is quick update for what is happening in the lab.

Tinusaur Proto

And by the way, our project was featured on OSHPark Blog, here’s the link … http://blog.oshpark.com/2014/02/staff-picks-for-the-week-of-2-february-2014/. Very glad to see that people are interested in this project.

As follow up to our first Tutorial 001 we are planing to put another one – Tutorial 002, probably about how to connect a push-button to the board and receive input from it.

Tinusaur Starter: We are making a beginners kit

Tinusaur Starter Kit

To start making things with the Tinusaur you need the board, the parts, a programmer with a cable and couple of LEDs to make your first blinking lights program for ATtiny85 microcontroller.

Tinusaur Starter Kit for Beginners PartsWe’re ordering the PCBs and the parts from the manufacturers and it seems that the total cost for the full package will be 8 to 9 USD. Once we have everything here we’ll run a small test sale to see what’s the interest in the kit. The estimated cost for delivery of the kit to any country in the world is about 2 USD. So the total cost to get it would be 10 to 11 USD – very affordable for everyone.

Here is a list of everything that will be included in the Tinusaur Starter:

Name Description
PCB Tinusaur Board
MCU, Attiny85 Atmel AVR ATtiny85 microcontroller
Socket, DIP-8 DIP-8 socket for MCU
H1, Header Header 2×4, Female
H2, Header Header 2×5, Female
ISP, Header Header 2×5, Male, for ISP
RESET, Button Tactile push button, for RESET
Power, Header Header 1×2, Male, for external power
Battery, Header Header 1×2, Male, for battery power on/off
Battery, Jumper Jumper, 2-pin, for battery power on/off
C1, Capacitor Capacitor 100uF, Low profile 5×5 mm
C2, Capacitor Capacitor 100nF, Small
R1, Resistor Resistor 10K, Small, 1/8W
Battery holder Battery holder for CR2032
Battery 3V Battery 3V, CR2032
LED1 LED, 3mm, red
LED2 LED, 3mm, green
Resistor (LED1) Resistor 330 ohm, Small, 1/8W, for LED
Resistor (LED2) Resistor 330 ohm, Small, 1/8W, for LED
Header (LED1) Header 1×2, Male, for LED
Header (LED2) Header 1×2, Male, for LED
ISP Programmer USB ASP, with 10-pin connector and cable
Packaging Packaging bag, plastic

Check more often Twitter, Facebook, Google+ and The Tinusaur Project site for news about this kit.

Tutorial 001: Blinking LED

Tinusaur Tutorial 001: Blinking LED

UPDATE: New version of this tutorial is available at the Tutorial 001: Blinking LED x1 page.

Tinusaur Tutorial 001: Blinking LEDThis is very simple tutorial how to make a LED blinking.

Since the Tinusaur board is a very standard ATtiny breakout board this could be applied to almost any such other board.

The code was tested to work with ATtiny13, ATtiny25, ATtiny45 and ATtiny85 but will probably work other chips too.

We assume that the Tinusaur board is already assembled, successfully; connected through the ISP programmer to the computer; and development environment . It is not the subject of this tutorial how to assemble the board or how to setup development environment.

The LED should be connected on pin 2 of the ATtiny – this is PB3 – through a resistor, and to the GND.

The LED, marked as D1, is just a standard light emitting diode.

The resistor, marked as R1,  is 270 to 330 ohm.

The most important fragment of the code is this:

	while (1) {
		PORTB |= (1 << LED_PORT);
		_delay_ms(200);
		PORTB &= ~(1 << LED_PORT);
		_delay_ms(400);
	}

What is does is this:

  1. Start an infinite loop.
  2. Set the LED wire signal to “1” – that will make it to light.
  3. Wait a little – 200 milliseconds.
  4. Clear the LED wire signal to “0” – that will turn it off.
  5. Wait a little -400 milliseconds.
  6. Do it again.

Here is the entire source code:

/**
 * The Tinusaur Project
 *
 * Tutorial 001: Blinking LED
 *
 * file: main.c
 * created: 2014-01-04
 *
 **/

#include <avr/io.h>
#include <util/delay.h>

// ====================================
//                ATtiny
//               25/45/85
//              +--------+
//            --+ o  Vcc +------------
//  LED - PB3 --+        +--
//            --+        +--
//  ------------+ GND    +--
//              +--------+
// ====================================

// Define the I/O port to be used for the LED.
// This a number between 0 and 7 that tells which bit to use.
#define LED_PORT PB3

int main(void) {

	// Set the LED port number as output.
	// The DDRB is the data direction for port B.
	// This ...
	//  - shifts the "1" on left to the desired position and ...
	//  - does bitwise "OR" with the value in the port register.
	DDRB |= (1 << LED_PORT);

	// Start infinite loop.
	// (this is how most programs work)
	while (1) {

		// Set the LED bit to "1" - LED will be "on".
		PORTB |= (1 << LED_PORT);

		// Wait a little.
		// The delay function simply does N-number of "empty" loops.
		_delay_ms(200);

		// Set the LED bit to "0" - LED will be "off".
		PORTB &= ~(1 << LED_PORT);

		// Wait a little.
		_delay_ms(400);

		// Do it again ...
	}

	// Return the mandatory for the "main" function value.
	return (0);
}

Copy the code above to your “main.c” file.

The source code could be also found on Bitbucket at this address: https://bitbucket.org/tinusaur/tutorials/src/1f61873ae382/tut001/src/main.c.

The circuit schematics, even though very simple, was drown on 123d.circuits.io and it is available at this address: http://123d.circuits.io/circuits/76781.

 

The Tinusaur Board Designing Principals

In this post are discussed some of principals used while designing this board.

Size and form factor

The goal of making this board is not to have a smaller or the smallest PCB that runs on ATtiny. The goal is to have a board that could be used for prototyping simple projects as well as fitting reasonable small (or large, depending on the view) circuits on an additional shield board.

Headers

There are 2 header – one 2×4 – H1 and another one 2×5 – H2.

The idea is that all the outer pins are GND while all the inner pins are connected directly to the MCU. The longer header H2 has its top-left pin connected to the Vcc like the 2nd-row one on the left. That gives us one more power source wire.

MCU

This board could work with the smaller Atmel AVR ATtiny controllers such as ATtiny 25/45/85, ATtiny13 as well as most of their variations – as long as they are in DIP-8 case.

Programming

The programming is done through the standard 10-pin ISP connector using any compatible AVR ISP programmer. On the diagram below it is marked as PC.

The connector is placed on the board in such a way so it could be chopped off if not needed and make the board little smaller. The programming probe, marked as PP on the diagram below, has holes that could help in the cutting. In case you need to connect the board to a programmer again at later time you can solder some wires to what’s left of the probe.

Board

Technical parameters: 2 layer board of 0.90×1.40 inches (22.96×35.66 mm).

There are 4 mounting holes marked as MH on the diagram below.

Power

During the development the board could be powered through the ISP programmer.

External power source could be connected to the board through a jumper marked as PS on the diagram below.

There is an optional button-cell battery mount on the back of the board, marked as BM on the diagram below. The battery could be switched on and off using the jumper that is marked as BS on the diagram.

Areas

There are 4 areas that a Tinusaur board could be divided to: A1, A2, A3, A4. That is applicable for the actual Tinusaur main board as well as any shield boards one could produce.

A1, the bottom part of the board:

  • this is the area where the RESET button is placed on the main board.
  • for a shield board that area could be used to put some components and produce a simple circuit.

A2, the mid of the board – heads:

  • there are 2 header – one 2×4 and another one 2×5, they are different for a reason.
  • on the main board, between the headers, is placed the MCU.
  • on a shield board, between the headers, could placed a 8-pin chip or other components.

A3, the top part of the board:

  • there are the minimum required components for the MSU to work – 2 capacitors for the power source and one pull-up resistor for the RESET.
  • jumper for external power.
  • jumper to switch on/off battery.

A4, tip of the board:

  • standard ISP programming connector.

Additionally …

A5, the other side of the board:

  • there is optional cell-button battery mount.
Tinusaur Reference Design
Tinusaur Reference Design
Tinusaur Proto v0.1 m2 - Schematics
Tinusaur Proto v0.1 m2 – Schematics

The new prototype PCBs just arrived from OSHPark

Tinusaur PCB
Tinusaur prototype PCBs from OSHPark
Tinusaur prototype PCBs from OSHPark

The new prototype PCBs just arrived from OSHPark – great quality as usual.

I noticed that there are only few things that I may change before call it official: slightly move some components around so they fit better and become easier to solder; add one jumper for switch on/off the optional button cell battery on the bottom of the board; make some pads and holes larger; … and few other things.

The schematics available on 123d.circuits.io website at this address: http://123d.circuits.io/circuits/58269.

Tinusaur prototype schematics
Tinusaur prototype schematics

The board is shared on OSHPark website at this address: http://oshpark.com/shared_projects/bFNU3LQB.

Tinusaur prototype PCB
Tinusaur prototype PCB