Project Guidance (Huge/Big Datalog, ATmega network I2C)

Hi all,

So I made this topic to give an example what I'm building and make sure I'm doing everything properly
so please feel free to tell me if I'm wrong in some steps and how could I make it better to work.

Ok, so what I'm trying to build is a big dataloger with multiple sensors like, GPS, Barometer, Gyro, Temp and other useful sensors, now as i understand each sensor works on his own frequensy or delay
but I need some sensors to work on a exact delay like 400ms..etc in the other way the GPS works at 1000ms which is a nice delay to give data without errors or extra trash on my datalog.

Because I have several sensors and i wanna make them work on different speeds (delay's) I have multiple
ATmegas but to make a dataloger I need to connect the ATmegas thru I2C, which gonna give me the ability to send the data from each sensor from Slave to Master and I'm thinking to have approx: 4~6 ATmegas connected.

Now the I2C have the ability to connect multiple sensors and (Master/Slaves) but for that I need to give each ATmega an address to communicate to each other, about the sensors (needed or no needed to declair addresses?) I can hook up the sensors on a I2C and call the sensor with the exact library example on a Slave ATmega. After all that each Slave will have their own speeds (delays) and sensors to work as accurate as possible and send data to master to save them on a SD Card.

So as you understand from the above example of what I'm building I'm gonna have almost everything
connected on I2C (SCL, SDA).

I call myself a beginner because I'm in the process of learning and I need to perfectionate my
knowledge from theories in practice.

Questions:

  1. How fast can data be send thru I2C without problems?
  2. Will be a problem if i don't put pullup resistors?
  3. How much data I can transfer and save on ATmega/Dataloger/Master without being slowed
    down or crash because (of low Ram) ?
  4. Do I really need to declair sensors addresses if I only call them in a single ATmega Slave?
  5. I should send the data from Slaves to Master on different delays or they need to be in the same
    time/speed?

This is my 1st big project for myself mostly to understand and learn and which I need to
perfectionate and make it work without problems.

Pleas understand this is not a Homework or asking some other people to do it for me, this is a Topic
which I made to get some help in some steps which I maybe don't understand yet and can make them better.

Thanks,
Domino60

Because I have several sensors and i wanna make them work on different speeds (delay's) I have multiple
ATmegas but to make a dataloger I need to connect the ATmegas thru I2C, which gonna give me the ability to send the data from each sensor from Slave to Master and I'm thinking to have approx: 4~6 ATmegas connected.

This is a complete waste of time and ATmegas. It also makes your project much more complex.

Stop thinking about delays - look at the post on how to do many things at the same time (it at the top of this forum.)

Mark

Some sensors use very specific timing. For example a DHT11, DHT22, DS18B20 (OneWire) and also a NeoPixel RGB led. Those sensors work best when the interrupts are turned off for a short time. That might cause trouble when you for example use interrupts for something very special.

However, in a normal situation, do as holmes4 wrote, use millis() to create software timers and software delays and that will run all together just fine.

It is fun to use I2C between a few Arduino boards. As a beginner, you better don't start with that. It makes things more difficult, because the Slave Arduino uses interrupt handlers. The I2C data is received and transmitted in interrupts, and that requires that you know how to use the variables.

Start small, log just one sensor data to a file. For example the Barometer. If that is working, add other data one by one (GPS, temperature, humidity, light, uv index, date and time (to timestamp the data), battery voltage, rain sensor, Geiger counter, gyro ?, and so on).

holmes4

Stop thinking about delays - look at the post on how to do many things at the same time (it at the top of this forum.)

To do many things at the same time? What exactly do you mean?
Do many things at the same ATmega(?) what about the code space? I've been testing like max 3 sensors on same ATmega and the memory space don't fit all the sensors in one ATmega.

Peter_n

It is fun to use I2C between a few Arduino boards. As a beginner, you better don't start with that. It makes things more difficult, because the Slave Arduino uses interrupt handlers. The I2C data is received and transmitted in interrupts, and that requires that you know how to use the variables.

Start small, log just one sensor data to a file. For example the Barometer. If that is working, add other data one by one (GPS, temperature, humidity, light, uv index, date and time (to timestamp the data), battery voltage, rain sensor, Geiger counter, gyro ?, and so on).

Interrupt handlers? I'm hearing it 1st time, what that exactly does?
If you mean interrupts between data "to recognize" what kind of value is that then yes I didn't worked yet with that but I'm sure I'm gonna work in the future about sending data in I2C and between ATmegas.

About "starting small" I already done testes like plugged a Accelerometer run the code and plugged
2nd sensor barometer, actual data of that 2 (Gyro,Acc, Temp, Pressure, 2nd Temp) and compressed code
and added 3rd sensor which is GPS with extra data (Lat,Lon,Alt,Km/h,Time,Date,Distance,Compas) as you see a lot of data but the GPS needed to work at 1000ms for some reason but in the other way i needed the other 2 sensors to work at lower than 400ms and the main problem was the ATmega space, I should of get off some printf's because the memory storage was full.

So that's the new reasons why I wanna use multiple ATmegas (I'm a beginner almost 1year try to learn stuffs on my free time but mostly I study only theory so It came time to do some stuffs in practice).
I know using multiple ATmegas it's kinda waste of materials and space but that's the only thing I have now to work with and I'm not expert yet in smd soldering.

So to recap.
-There is no enough space on ATmega328p to use multiple sensors and code.
-I wanna use different speeds on my sensors but using on the same ATmega multiple sensors that will take
extra time (400ms 1 sensor), 1400ms + GPS.
-I got about 7 sensors which I wanna use and they don't fit all in the same ATmega (memory)
-I need more data from Gyro, Acc per sec and only 2 times per 10sec from GPS.

Domino60:
,snip. ....I need to perfectionate and make it work without problems.

this is a good thing. it is always good to perfectionate your work.

The Arduino Mega 2560 boards seems to be the board for your project.
Perhaps you can make it fit in the normal ATmega. Do you use the "F()" macro ?

Try the BlinkWithoutDelay : https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
It uses millis() and not delay(). That is the whole trick. The millis() function can be used for software timers and delays and doing multiple things at the same time.

Next step is the attached sketch to the first post of this : Demonstration code for several things at the same time - Project Guidance - Arduino Forum

The millis() function can be used in perhaps 10 different ways.
You probably need to use a seperate software timer with millis() for every sensor.

These two sketches use a single millis() for a 10Hz software timer, and the sketch uses that 10Hz to do all kind of things with different delays: Analog Sensor Setpoint - #49 by Peter_n - Programming Questions - Arduino Forum

To do many things at the same time? What exactly do you mean?

Read the post we keep pointing you at. This is not the first of your threads that people have pointed out that post in.

Mark

holmes4

This is not the first of your threads that people have pointed out that post in.

What post people have pointed in my previous post's? please I'd like you to give me a link with my post which your talking. :slight_smile:
Just to remember and see where exactly is that and what you are talking about.

Peter_n

Try the BlinkWithoutDelay : https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
It uses millis() and not delay(). That is the whole trick. The millis() function can be used for software timers and delays and doing multiple things at the same time.

Next step is the attached sketch to the first post of this : Demonstration code for several things at the same time - Project Guidance - Arduino Forum

The millis() function can be used in perhaps 10 different ways.
You probably need to use a seperate software timer with millis() for every sensor.

These two sketches use a single millis() for a 10Hz software timer, and the sketch uses that 10Hz to do all kind of things with different delays: Analog Sensor Setpoint - #49 by Peter_n - Programming Questions - Arduino Forum

I've seen milis() before in others people codes but to be hones I didn't knew what's that and never used it.
yea it's a nice way to use multiple sensors and actually changed my ideas.
I read all the link you posted and I'm gonna keep in mind that type of using multiple stuffs on different delay/milis. As i seen there is functions which need to be made and almost all run in if statement, doesn't multiple if's slow down the delay (loop) a bit?

The Arduino Mega 2560 boards seems to be the board for your project.
Perhaps you can make it fit in the normal ATmega. Do you use the "F()" macro ?

Mega 2560 it's nice but 90% of the sensors use SCL, SDA. I'm trying to build my own PCB for this project.
"make it fit in the normal ATmega" ? I don't think 7 sensors can git in a single ATmega, there is no enough space for all that code and i wanna use a dataloger too.
"F()" macro?

http://forum.arduino.cc/index.php?topic=110307.0
no i don't and i never used F() macro.

F() macro

i wanna use

Three year-olds "wanna" biscuit.

You want to use a datalogger

AWOL

Thanks for correcting my spelling but I'm not on a interview or i don't write any academic Ref's to take care of my English right now, English is not my native language so most of the people understand what I mean, If you have a hard time to understand me then I'm really sorry :slight_smile:

no i don't and i never used F() macro.

Why not?

Why not?

How could I use F() in my case?
As i see from this post : Arduino Playground - HomePage

F() is used to store data on memory, what I only need is to read the data from the sensors and store them into datalog or use the real time data for some reasons.

How could I use F() in my case?

No idea - I can't see your code.
Just thought I'd ask, but it seems you've thought it through, so that's all cool

No idea - I can't see your code.

This is a project guidance topic, there is no general (specific) code to talk about, only theories and how could something to be used in different kind of ways.

Ideas and basic/general knowledge are shared in this topic to learn and perfectionate the basic idea of how this project gonna be builded.

If you skipped the 1st Topic comment because something else attracted you then I'll be glad you to go back and read what's this topic is about.

I did read the first topic, but between the lines I thought I read several misapprehensions, and just wanted to calibrate your experience and expectations.

Just a few cm from where I'm sitting, I have an I2C 128x64 pixel OLED, RTC, barometer and a separate humidity sensor, displaying temperature, air pressure, date, time and altitude, all updating at different, independent rates and displaying the results.

The code running them occupies about 30-40% of flash, and 20% of the RAM of a Uno.
I aim to get this lower before I add the GPS and SD logging.

Just a few cm from where I'm sitting, I have an I2C 128x64 pixel OLED, RTC, barometer and a separate humidity sensor, displaying temperature, air pressure, date and times and altitude, all updating at different, independent rates and displaying the results.

The code running them occupies about 30-40% of flash, and 20% of the RAM of a Uno.
I aim to get this lower before I add the SD logging.

O_o All that on a single Uno and take only ~40% of space? probably
OLED, RTC, Barometer and Humidity sensor.

I got Barometer, Gyro, Acc, GPS and sd card, displaying and saving in the same time (Pressure, Temperature, Altitude, Gyro, Acc, G-Force, Lat, Lon, Time(hour,min,sec), distance between 2 loc, direction and km/h)

Almost full flash, about Ram probably almost full.

of curse they run at same delay so that a problem for me, finding out in this topic about milis() i will totally change my code.