Pages: [1] 2 3   Go Down
Author Topic: How to know if a Arduino has enough memory for a project  (Read 1871 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm doing some home automation stuff and sensor reading with some Arduinos.
I bought a Nano for the bathroom and now I'm scared that the 32 KB are not enough.
I chose the Nano cause it's easy to integrate him into the PCB.

I have just the code i posted here now on it: http://arduino.cc/forum/index.php/topic,141240.msg1105074.html#msg1105074
So 14 KB are already gone.

But i want to see life data of my sensors on the web page, save data to the SD-Card and upload them to
the servers database.

This is what was planned:
D2 S0-Interface Electricity Meter Bathroom Underfloor heating
D3 S0-Interface Electricity Meter
D5 One Wire BUS (1 DS18B20)
D6 Flow Sensor Bathroom Sink Cold
D7 Flow Sensor Bathroom Sink Hot
D8 Flow Sensor Shower
D9 Flow Sensor Toilette

A0 (14) Reed Switch Bathroom Window
A1 (15) Push Switch 1 (Shower On)
A2 (16) Push Switch 2 (Shower Off)
A3 (17) Push Switch 3 (Bathroom On)
A4 (18) Push Switch 4 (Bathroom Off)
A5 (19) Push Switch 5 (Bathroom On)
A6 (20) Push Switch 6 (Bathroom Off)

The push switch stuff is send trough my Windows server with MQTT to another Arduino and
later i also want to change the code so that i can dime the lights.
Looks like 32 KB is not enough and i need a Mega?

PS:
Is it a good idea to start one thread for the whole project instead of spreading the stuff
where i need help and have problems over the forum? Cause this way all the code is
in one place and i do not need to copy it around and always need to explain what the
rest of the code does that has nothing to do with a particular thread.
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 83
Posts: 3389
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you know it does compile and it doesn't upload, then it doesn't have enough memory.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PS:
Is it a good idea to start one thread for the whole project instead of spreading the stuff
where i need help and have problems over the forum? Cause this way all the code is
in one place and i do not need to copy it around and always need to explain what the
rest of the code does that has nothing to do with a particular thread.

Well, from my own personal experience, posting your entire project in one thread results in people not reading it and just asking you questions that are answered in your post to begin with. But, on the other hand, if you post only snippets, people will ask you to describe your entire project.

Unfortunately, that's just the way it goes on forums. *I* prefer to have (and read) it all in a single thread. If I am interested or I think I can help, I bother to read the entire thing. If I am not or can't, then I don't.

You also run into the fact that people may not keep coming back to your thread to see that you've asked new questions when it is all in one place.

So, I don't really have an answer. Only my preference. If there is a better way, I would love to hear it, because I have asked the same question myself. What I do in some cases is post a thread about my entire project as a whole, and then post other threads asking specific questions. When people ask me to describe the project, I refer them to the other thread.
« Last Edit: February 06, 2013, 11:17:45 am by Retroplayer » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

in order to save memory... make the function compress...
Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 64
Posts: 2100
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends what your coding skills are like really, memory ( SRAM ) is an important issue, but 32kb to an experienced coder is quite significant.
It doesn't help if 3rd party code takes up a large chunk of flash, but you can utilise many devices efficiently if planned out optimally.

There are also ways to see the static memory usage, ( 'avr-nm.exe -S' will give some info. )
Logged


UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12518
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know what the interface to your electricity meter will be like, but everything else you're doing seems fairly straight forward. I doubt that program space will be a problem. RAM is a separate issue, and you would need to know how much RAM your Nano variant has and what data structures your sketch will need in order to estimate the RAM requirements.

Given a project of this complexity it would be sensible to implement it in small steps, adding functionality as you go. With that approach you can be confident that the early versions will fit in the available program and RAM space, and measure how much they're actually using as the sketch evolves to see whether you're approaching a problem.

I suggest that the best way to get help is to only post when you have a specific problem or question that you want help with, and provide as much detail as is necessary to understand that problem or question. Anything involving software will almost always involve posting your whole sketch, but you can help a lot by doing some work in advance to reproduce the problem or question in isolation in a much smaller and simpler sketch. This will help your own understanding of the problem too, and quite likely you'll find that the act of reproducing the problem in a minimal environment reveals a false assumption or mistake in your understanding which enables you to solve the problem on your own.
 
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://playground.arduino.cc/Code/AvailableMemory
Logged


Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2166
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Get the Mega. It's not much more expensive.

You can do an awful lot with the Uno provided that it is a lot of the same job. You are doing different jobs. That changes things immediately  and the problems are beyond your control. Different things to be done require different libraries, and that is where the memory goes.

I can see two new libraries coming over the hill, SD and RTC. My stuff is sent to cosm for live view on the internet. In my case the cosm library was the straw that broke the camel's back, and I was obliged to move to Mega 2560.

I think it would be fair to say that, if you want to have a proper system sending  data the to internet, a Uno will not suffice. It may be that some smart operators can squeeze it all in by stripping down the libraries. I have no idea about that, but I'm sure you can come to your own conclusions about the merits of such an approach.
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Get the Mega. It's not much more expensive.

I actually bought my Mega2560 on ebay for $17 shipped. Less than I paid for my Uno. It probably isn't "official" even though they even screen-printed it all official, but it has been working fine.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

I can see two new libraries coming over the hill, SD and RTC.


I failed to notice the SD lib was mentioned, right in the OP. I tested it once that it takes about 1.5 KB SRAM.
Logged


Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2166
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I did say  
Quote
coming over the hill.
And when it arrives, you can be fairly sure that the code that uses it is soon to follow. It's a minor stretch of the intellect, sometimes known as forward planning. If you buy a Uno for the purposes stated and then come to regret it, remember where you heard it first.
« Last Edit: February 07, 2013, 01:28:49 am by Nick_Pyner » Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2166
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Get the Mega. It's not much more expensive.

I actually bought my Mega2560 on ebay for $17 shipped. Less than I paid for my Uno. It probably isn't "official" even though they even screen-printed it all official, but it has been working fine.

Yes, Retro. I paid about $70 for my store-bought EtherTen. My Mega with Ethernet+SD shield was about $27, I think. I don't regret getting the EtherTen, but it's the sort of thing you only do once. I think type-for-type a Mega is typically about $10 more than  a Uno, and that seems reasonable. The only advantage a Uno has is its size, and I imagine it will be squeezed from both ends and die a natural death - rather like the VIC-20.
« Last Edit: February 07, 2013, 01:41:27 am by Nick_Pyner » Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think so. UNO has it place and will keep its place. A carefully planned project such as on I carried out, did accomplish a lot with the SD card, RTC, and a few other things and extensive menu interface, all on an UNO. I'm not saying anyone else can easily pull this off.  smiley-wink
Logged


North Queensland, Australia
Online Online
Edison Member
*
Karma: 64
Posts: 2100
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The only advantage a Uno has is its size, and I imagine it will be squeezed from both ends and die a natural death

As liudr said, the Uno ( 328, 168 chips ) certainly have their place. Code will actually execute faster on an UNO, you pay a price for the convenience the 2560 provides.
Logged


Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2166
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The faster execution has not been evident in practice, and I doubt the OP will see it either. Convenience is hardly the word for it. The difference between being able to do the job and not being able to do the job is not a matter of convenience, it's a matter of having the right tool.

And, despite liudr's self-aggrandisement, I submit that the Uno is the wrong tool for the job or, even if it is OK now, it will be wrong soon enough. 

So, in the light of the OP having no more gold stars than I do, and the minor extra cost, he/she would be wiser not to bother with a Uno.
Logged

Pages: [1] 2 3   Go Up
Jump to: