Go Down

Topic: Arduino Mega 2560 and Shield Ethernet Wiznet W5100 (Read 3363 times) previous topic - next topic

Zarak225

Apr 20, 2020, 08:16 pm Last Edit: Apr 20, 2020, 08:26 pm by Zarak225
Hi, I'm a programmer and beginner on Arduino in Brazil.

Can you guys can help me on this?

I like to use a Arduino Mega2560 with a W5100 shield to run a telemetry to send some data to a server.

The code i write worked well so far, so i needed to make it better, i need to storage the sensors data to a SD card when loses internet and send after it can connect again.

I understant that the W5100 uses the SPI to talk with the MEGA, and if i want to use the SD my code will have to specify when write/read the SD and when to send Data to Ethernet.

It's ok to use the SD card port on the W5100?

Can you people give me some thoughts on it?

I have:

04 DS18B20 sensors reading temperature
03 SCT013-100A reading current
03 ZMPT101B reading voltage
01 MPU6050 reading vibration ( Not sure to maintain these on the project )
04 5VDC Transducers reading pressure

The code read the sensors after 1 second on a timer and send them to the server.

Thanks!


Nick_Pyner

#1
Apr 21, 2020, 04:04 am Last Edit: Apr 21, 2020, 07:01 am by Nick_Pyner
It's ok to use the SD card port on the W5100?
The W5100 is probably the best SD card module you can get for Arduino. The simplest solution is to send data to the SD continuously, thereby immediately solving all your "if and when" problems.

Welcome to the forum.

Zarak225

The W5100 is probably the best SD card module you can get for Arduino. The simplest solution is to send data to the SD continuously, thereby immediately solving all your "if and when" problems.

Welcome to the forum.
Thanks!

So i need to store a array of data on that SD and then send it to a server.

Do you have some help on this? I dont find any answer on the forum on this specific matter.

Nick_Pyner

#3
Apr 22, 2020, 04:10 am Last Edit: Apr 22, 2020, 07:09 am by Nick_Pyner
No.
You send continuously to both the Internet and the SD.  This means SD serves as a backup in the event of losing the Internet. This probably goes quite some way to explain why the W5100 shield has an SD slot. You may retrieve off SD if and as you like, or maybe never. The last thing you should want to do is regularly retrieve from SD and send that to Internet.

This is all standard datalogging procedure, and I'm surprised to hear you can't find any answers. As far as SD is concerned, the examples in the SD library are really all you need.  Same applies to the Ethernet card. By Internet, I assume you mean the Internet of Things, the provider of which will have relevant examples of how to send the data.

Zarak225

No.
You send continuously to both the Internet and the SD.  This means SD serves as a backup in the event of losing the Internet. This probably goes quite some way to explain why the W5100 shield has an SD slot. You may retrieve off SD if and as you like, or maybe never. The last thing you should want to do is regularly retrieve from SD and send that to Internet.

This is all standard datalogging procedure, and I'm surprised to hear you can't find any answers. As far as SD is concerned, the examples in the SD library are really all you need.  Same applies to the Ethernet card. By Internet, I assume you mean the Internet of Things, the provider of which will have relevant examples of how to send the data.
Thanks Nick!

Maybe some of my idea has lost its meaning on the language translation. But my problem its just on this part:

"SD serves as a backup in the event of losing the Internet"

How do i code this?

Because, how do i code the arduino understand how much of data was not sent to the server due to losing of connection?

Lets say my internet is off for 1 hour i lose X bytes of data. And if is off 2 hours i lose Y bytes of data.

How do i tell my arduino how much of the storaged data on the sd he needs to send?



Nick_Pyner

#5
Apr 24, 2020, 04:32 am Last Edit: Apr 24, 2020, 07:31 am by Nick_Pyner
Your English is fine - better than the President of the United States. The problem is your understanding of the principle I outline. One reason for this is that I'm afraid the principle I outlined is not necessarily what you want(!)

I don't know how much you know about programming, but I can tell you that you don't need much. So consider this pseudo code.
Code: [Select]
void loop()
{
aquireData()
send-to-internet()
send-to-SD()
delay(1000);
}

void aquiredata()
{
read sensors
}

void send-to-internet()
{
do what the service provider tells you to do
}

void send-to-SD()
{
print to log file in the usual manner
}


What this means is that ALL your data is stored locally, in order, and in one place, and IS recoverable in the event of internet failure. It does NOT provide for gathering and sending the missing data out once the Internet has been restored.

The first things to be considered are:
1. Is there any point in sending the old stuff?
2. How will the other end handle it if you do send it?

For all that, it has just occurred to me that (in principle!) it is possible to sort out what you want. On each transmission, the Internet receiver will send a code back to acknowledge receipt that you can then print to SD as a marker at the start of the current line. This tells Arduino what is going on and when, and you then read the file and re-send the lines of data that have the relevant marker. I hope that is clear...

Zarak225

#6
May 04, 2020, 09:02 pm Last Edit: May 04, 2020, 09:13 pm by Zarak225 Reason: Error
Your English is fine - better than the President of the United States. The problem is your understanding of the principle I outline. One reason for this is that I'm afraid the principle I outlined is not necessarily what you want(!)

I don't know how much you know about programming, but I can tell you that you don't need much. So consider this pseudo code.
Code: [Select]
void loop()
{
aquireData()
send-to-internet()
send-to-SD()
delay(1000);
}

void aquiredata()
{
read sensors
}

void send-to-internet()
{
do what the service provider tells you to do
}

void send-to-SD()
{
print to log file in the usual manner
}


What this means is that ALL your data is stored locally, in order, and in one place, and IS recoverable in the event of internet failure. It does NOT provide for gathering and sending the missing data out once the Internet has been restored.

The first things to be considered are:
1. Is there any point in sending the old stuff?
2. How will the other end handle it if you do send it?

For all that, it has just occurred to me that (in principle!) it is possible to sort out what you want. On each transmission, the Internet receiver will send a code back to acknowledge receipt that you can then print to SD as a marker at the start of the current line. This tells Arduino what is going on and when, and you then read the file and re-send the lines of data that have the relevant marker. I hope that is clear...

Thanks for my english! But the actual president of Brazil it's not that bright too. Eh

On the topic of my problem, i understand the logic that you write on your pseudo code. I will test it, and then move to the problem of how to send old data and how my end will handle it.

I need the old data because its a telemetry, on the event of losing internet ( that will occur often ) i dont want to lose data, my graphs will have various "holes" on it.

Nick_Pyner

Indeed not too bight, and it would seem that the recent call to revert to a military dictatorship might not be such a bad idea, but Bolsonro's mangled English is quite excusable, while Trump's bumbling is definitely not.

Note item 2. in my previous. You need to check with the IoT broker that it is possible to fill the gap from your backup file. What you want to do is mostly pretty normal, but I have never heard of backing up off the card to IoT.!

ballscrewbob

@Zarak225

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up