Go Down

Topic: Will a program for UNO work for Breadboard Arduino? (Read 868 times) previous topic - next topic

bagho

Hello everyone! I'm Bagho from India.

I made a simple project with DHT-11 with an Arduino UNO and an LCD panel. The project worked flawlessly with the UNO.

So I got an ATMega328 chip (Not Atmega328P) chip, burned the bootloader with "Atmega328P on breadboard 8 MHz internal clock" (I had to change the MCU to ATmega328 in the boards.txt to match device signature).

I connected the LCD and DHT to the ATmega328 following the UNO pinouts.

Unfortunately, the DHT doesn't return any value now (nan). I tried with another DHT and different pins; it's all the same. The LCD displays fine whatsoever. Whenever I switch back to the UNO without the program unchanged, the DHT returns proper values.

Is the ATmega328 faulty, or isn't compatible with the bootloader?

Please help. Thank you. :)

Hackscribble

Hi bagho

Quote
The LCD displays fine whatsoever.
If you uploaded the program to the 328 and the LCD works correctly, then the bootloader is OK.

How do you have the DHT11 connected to the 328?  Can you post a diagram (photo of hand drawn diagram is fine).  Please show the physical 328 pin numbers you are using (not the Arduino pin numbers). 

Are you using a 328 in the 28-pin DIL package?

And please post your program.  Use code tags (the </> button on the toolbar above the reply window).

Regards

Ray
Hackscribble.  Writing about making things
hackscribble@outlook.com

larryd

Quote
Please show the physical 328 pin numbers you are using (not the Arduino pin numbers). 
As implied here, it is important to use the correct pins on the actual I.C.

.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

bagho

Thank you so much, Ray, for your reply. :)

Yes, the Atmega328 is using the 28 pin DIP package.


Kindly refer to the rough diagram I have drawn. Sorry if it's a bit messy.  :)




Here's the code:


Code: [Select]


#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN A2   
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(A0, A1, 9, 10, 11, 12);

void setup()

lcd.begin(16, 2);
dht.begin();
}


void loop()

{
int h = dht.readHumidity();
int t = dht.readTemperature();

  lcd.setCursor(0,0);
  lcd.print("Temp=");
  lcd.print(t);
  lcd.print(" *C");
  lcd.setCursor(0,1);
  lcd.print("Humidity=");
  lcd.print(h);
  lcd.print("% ");
  delay(1500);

}


larryd

Can you show us a picture of the wiring?

Do you have decoupling capacitors in your circuit?

See Mr. Gammon's web page for some wiring examples:
http://www.gammon.com.au/breadboard

.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Hackscribble

Thanks, Bagho.

Physical pin 25 = A2, so that looks OK.

I've just realised, looking at the diagram and your first post again, you are running with an internal oscillator at 8MHz.  Are you using the Adafruit DHT library?

If so, I googled "adafruit dht clock speed" and found this ...

http://forum.arduino.cc/index.php?topic=97915.0

Look at the post near the bottom - a patch from Adafruit to their library to run at 8MHz.
Hackscribble.  Writing about making things
hackscribble@outlook.com

bagho

Thank you!

Larry, I wasn't using the decoupling caps. Thanks for pointing that out. I souldered two on the veroboard, still to no avail.

Ray, yes! I am using the Adafruit library! Thank you for pointing the problem out!

I'm trying to connect a crystal, reburn a new bootloader and try again. :)

bagho

Could not get the ATmega328 to work at 16 MHz. I could, with much difficulty (editing the boards.txt) burn the bootloader, but that was it. Couldn't upload it. The IDE seems to want an Atmega 328P. I'm ordering an Arduino Pro Mini now.

Thank you for pointing out the real reason of the codes not working. My project involves using a DS3231 as well, and it was also not functioning at 8 MHz clock.

Now I know why. :)

Paul__B

I'm ordering an Arduino Pro Mini now.
Actually, that makes a lot more sense than "breadboarding" circuits.  Given that "clone" Pro Minis are virtually as cheap as the 328 chips themselves, even before considering the other components and PCB and you automatically get the crystal and two extra Analog pins, it really is hard to invent a reason for "breadboarding".  Even if you do make a PCB, you can just mount the Pro Mini as a sub-assembly.  You can even re-use the space under it!

It is of course, the benefit of mass production.

larryd

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

Go Up