Arduino Mini328 with Mini USB Adapter

Hi all,

I’m new to Arduino programming, but could not find any solution for my current problem on this forum.

Let me start by summing up what I have:
Arduino Mini USB Adapter
Arduino Mini328
ADXL345

I have connected the USB Adapter to the Arduino as follows:

USB Adapter     Arduino
Tx                  Tx
Rx                  Rx
Ground            Ground
+5V                 +5V

There is a LED connected from the Arduio’s digital pin 13 to Ground for feedback.
No other power supply is used. The connections have been double-checked. This setup is connected to a Mac running OS X Lion.

To start, I used the Basic → Blink program. The Arduino Mini does not have auto-reset (found that out the hard way…). So, before I upload a program, I reset the Arduino by pulling the Reset pin to Ground.

This is a snippet of the resulting log:

avrdude: Recv: . [10] 
################################## | 100% 0.05s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

It seems to start uploading, but at some point stops because the Device signature is bad. avrdude suggest to use the -F flag, and so I did.
Uploading on a terminal (copying the avrdude call from the log, and adding the -F flag) works. The blink program runs nicely.

But when adding some more code, the Arduino seemed to not function anymore. I’ve reduced the problem to this:

#include <Wire.h>

int testWire = 0; // If set to 1, the program will not reach the end of setup()

int m_Address = 0x1D; // ADX345's address
int statusPin = 13;

void setup() {
  Wire.begin();
  
  pinMode(statusPin, OUTPUT);
      
    if (testWire) {
    	Wire.beginTransmission(m_Address);
	Wire.endTransmission();
    }
    
    digitalWrite(statusPin, HIGH);
}

void loop() {}

The LED will only light up if testWire is set to 0. This means that when Wire.beginTransmission is called, the Arduino stops executing code.

What can be the cause of these two problems?

Thank you for your help!

if testWire is 0, this part gets skipped:

if (testWire) {
Wire.beginTransmission(m_Address);
Wire.endTransmission();
}

When testWire is 1, that part runs - so you start out sending the device its address, and then nothing more, so the I2C bus probably gets hung waiting for the response from the device. Do you have 4.7K pullup resistors on the SCL & SDA lines?

Hi,

I think you will need to hook it up like this:

USB Adapter     Arduino
Tx                  Rx
Rx                  Tx
Ground            Ground
+5V                 +5V

Also, if your mini USB adapter has a DTR line available, connect it to the Mini's Reset line through a 0.1uF capacitor. This will do the reset for you.

But if you are using Arduino 1.0, you will likely still have a problem. Arduino 1.0 assumes an optiboot based bootloader if you choose Arduino Mini w/ATmega328 board type, so if you have an older Mini328, try the connection I suggest above and choose Duemilanove as the board type.

CrossRoads:
When testWire is 1, that part runs - so you start out sending the device its address, and then nothing more, so the I2C bus probably gets hung waiting for the response from the device.

I did not connect the ADXL345 yet, I wanted to test the components one by one..
But I did not realize that that "Wire.beginTransmission()" is a blocking operation.

Thank's for your help CrossRoads.

BillO:
Also, if your mini USB adapter has a DTR line available, connect it to the Mini's Reset line through a 0.1uF capacitor. This will do the reset for you.

I soldered a pin to the DTR port of the Mini USB. Then added a 1uF capacitor (could not find a 0.1uF one) between the DTR and the Arduino reset pin. Now the auto-reset works smoothly!

Thanks a lot! Having to reset with every attempt became a nuisance!
Maybe some description of this setup could be added to the Mini USB Adapter info page..?

BTW, for anyone who is working with the ADXL345: I made an error connecting the SDO to Ground instead of V3+. Some webpages tell you to do that because they use analog inputs. But if you want to use I2C, then connect SDO to V3+. https://www.loveelectronics.co.uk/Tutorials/12/adxl345-accelerometer-arduino-tutorial

One problem remains, and that is the "avrdude: Device signature = 0x000000" message which is shown when uploading from the Arduino IDE. There is a workaround: uploading with a -F flag from the terminal using avrdude directly.

In what direction should I look for fixing this completely?

To make a more practical workaround, I would want the Arduino IDE to use the -F flag. Can this be configured / modified?

Don't know about the -F thing. Have not had to deal with that.