Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Programming Questions / POST method on: September 07, 2014, 12:43:08 am
Hey guys,

I have pretty much been dealing with this issue for a day and wondering if anyone could give some input. There is an integer array on my Arduino that I want to send to a PHP server using the POST method. I wrote a test code as follows:
#include <SPI.h>
#include <Ethernet.h>
short unsigned int sensor[6000][9];
byte mac[] = {0x92, 0xA4, 0xCA, 0x0E, 0xCE, 0x01};
byte ip[] = {192,168,2,12}; //Arduino Ethernet chip IP address
byte server[] = {128,73,45,586}; //My fake  PHP server address
Client client(server, 80);

void setup(){
  Ethernet.begin(mac, ip);
  for (int v=0; v<6000; v++){
    for (int u=0; u<9; u++)
      sensor[v][u] = analogRead(u);

void loop(){
    for (int v=0; v<6000; v++){
      for (int u=0; u<9; u++){
          if(v!=6000 || u!=9)
    client.println(" HTTP/1.1");
    Serial.println("connection failed");

Now, for updateData.php,
= (($_POST['myData']));
$fh fopen("./data/myData.txt"'a+') or die("Unable to open file.");

I am expecting the same set of data to received and recorded as txt file on my server every 10 seconds or so. The Arduino does connect to my server according to serial output, but no file was actually recorded on my server. Does anyone know what might be the issue? Thanks!
2  Using Arduino / Programming Questions / Re: Transfering large file from SD card to server on: September 06, 2014, 10:37:41 pm
Hey guys, I got a newbie question that I am trying to resolve.

So let say my analog readings are stored in an array called "myData" with a size of [3][9], I tried the followings:
for(int i=0;i<3;i++){
  for(int j=0;j<9;j++){
client.println(" HTTP/1.0");
So I expect the actual traffic from the Arduino going to my server is going to look like:
POST,50,75,100,150,(skip),1000,1001,1002,1003 HTTP/1.0

to simulate sending a
on the Arduino.

On my updateData.php, if I have
$myData= (($_POST['myData']));
Can I assume that the "myData" variable would store the string "25,50,75,100,150,(skip),1000,1001,1002,1003"? So I just put the string in a loop to restore the format like how zeropingtomars advised to do?

3  Using Arduino / Programming Questions / Re: Transfering large file from SD card to server on: September 06, 2014, 06:46:10 pm
Actually, shouldn't the transfer rate only limited by the SPI's SCK bus instead of the baud rate? Both the SD card and ethernet chip doesn't use serial as far as I know.
4  Using Arduino / Programming Questions / Re: Transfering large file from SD card to server on: September 06, 2014, 06:33:37 pm
Thank you for all the responses! I was actually going to ask what is bottlenecking the transfer rate.

Yes I remember I used to turn the Arduino into a server at night when I didn't know about PHP. When I grab the file using a PC, it downloaded for maybe 10-20 minutes then say there is an error and the process stopped. The error happened every time and I didn't resolve the issue. And of course my Arduino was effectively frozen because it was still thinking it is talking to my web browser and will then resume the next day...

6-7 hours of download is fine, I just need to handle the data properly and hope it won't fail. I will give it more thought and give it a try, thank you!

Any additional inputs will be welcome.
5  Using Arduino / Programming Questions / Transfering large file from SD card to server on: September 06, 2014, 05:08:40 pm
Hey guys,

I have an Arduino actively logging data during daytime. Currently, it transfer data to my PHP server using the GET request after it obtained 16 analog samples from A0 to A15, by doing something like client.print(, you get the idea. Then my php script would look for the keywords using $_GET and permanently store them into a database. But now, I would like reduce the traffic and increase my sampling rate, so I would like to log all the data onto its SD card as a .txt file during the day and transfer the file to my server only at night.

I have already program the Arduino to log data into a .txt file, and I believe I can transfer it using the POST request instead of GET request. But I am not sure how it can be implemented... Let say I generate a 100MB .txt file on my SD each day filled with 40,000,000+ analog samples. I used to look for the keyword A0, A1, ..., A14, A15 on my PHP script when using the GET request, but now I clearly can't define 40,000,000 variables in my script on both side. Anyone got any idea on how to approach the problem?


As a side question, I am also considering to perform a near lossless compression on my samples before transfer to reduce the file size. Does anyone know if there is something like a AR or FIR library available? Thanks!!
6  Using Arduino / General Electronics / Re: External ADC design help on: August 30, 2014, 04:46:11 pm
Thanks again for the input.

(1) When I said pulling to 3v3, I meant putting a jumper across one of nine male header pairs, so that the 3v3 from the OpAmp buffer goes directly through the 1K resistor to the ground. So it should give me 65535 because that is the same voltage I apply to my ADC reference terminal.
(2) All the resistors are 1K, not 10K. Sorry my schematic is wrong.
(3) OpAmp becomes unstable when driving capacitive load without compensation, but isn't it only effective when amplifying signal with higher frequency contents? The bandgap reference produces a DC voltage of 3v3, maybe with some tiny amplitude AC noise. But I will certainly give it a try.

I am thinking maybe it's the MUX that has problem. Maybe the ON state resistance is too high? The Arduino ADC has a input impedance of 10MOhms thought... hmmm
7  Using Arduino / General Electronics / Re: External ADC design help on: August 30, 2014, 03:10:56 pm
Thank you for your response!
(1) The OpAmp is am using is a OPA2340U single power supply, rail to rail, dual OpAmp from TI. I am not sure about input offset voltage, but I am going to look it up. But as long as the ADC reference and sensor operating voltage is the same, it think it will be fine.
(2)  Yes. Each of my nine sensors have composed of a photo transistor and a 1K resistor. Maximum current is (9)(3.3/1000)=29.7mA. I also believe that a bandgap reference is not meant for driving sensors and should be buffered regardless of current consumption, but I am not sure... just my personal thought.
(3) It is a TEPT4400 NPN ambient light sensor, I put them outside to check ambient light level. I am not sure how the raw signal looks like, but the 10bit does give better result then the 16bit when I scale the 16bit data down to 10bit range. Both ADC always report 00000 when I short the MUX output to the ground which is perfect. When I pull the output to 3v3, my lowest sample is 64683 and the highest sample is 64732, which is 49 counts (3.3/65535*49=2.47mV) apart, and 852 counts (42.9mV) away from 65535.

Do you Is there is design fault to my circuit? Is this how people usually design external ADC circuit? Thanks you!!
8  Using Arduino / General Electronics / External ADC design help on: August 29, 2014, 03:26:25 pm
Hey guys!

This is my first time designing circuit for ADC and I have built a board a while ago but unfortunately did not get good result, and I am pretty sure I made some design error here and there so I just put my idea aside. Now that I got more free time on my hands, I wish to pick up the project again and design a new board  (and to restore my pride), I am wondering if you guys could offer any recommendation.

So I got 9 analog sensors (basically a photo-transistor plus a precision resistor) that output from 0-3v3 that I would love to enhance the sampling accuracy, and I have been thinking about using an external ADC to take higher quality samples. I got a couple of LTC1864 16-bit delta sigma dual channel ADC that runs on SPI which made it easy to interface with an Arduino. Since I got 9 sensors, I have also got an analog MUX. I would like to operate my sensors at the same exact voltage as my ADC reference at 3.300V, therefore I also got a LM4132 precision LDO voltage reference chip dropped down from a linear regulator at 5V from a switch regulator from a 12V battery regulated by a solar charged controller. Finally, the voltage reference won’t source enough current to drive all of my sensors, so I included an unity gain OpAmp to amplify the current. I digitized the signal right at the output of the MUX in attempt to minimize noise. As a backup, I also transmit the analog signal to my internal ADC through a coaxial cable just for comparing the result. The shield is grounded only at the sensor side to avoid ground loop. The signal from the photo-transistors is maybe 10Hz at most.

Tech sheets are given below:

Long story short, both 10bit and 16bit results are crappy, with huge amount of fluctuation. It got better after I removed the two OpAmp, but still both result are not acceptable. The trial was done a while ago and I think I have already thrown the data away. But just by looking at the design, what do you guys think might have went wrong? I would love to re design the board, so any comments will be extreamly helpful!

Thank you!!
9  Using Arduino / Storage / Data file larger than 4.3 GB on: August 26, 2014, 10:27:16 pm
Hi! I am trying to use a 32GB SD card to log a lot of data in a remote location and I would like to completely fill the card with data when I do go get it back. And I got some questions while writing the code:

1) The SD card is formatted as FAT32, which I believe has a maximum file size of 4.3GB. Does it means that Arduino won't be able to append additional data into the same data file once it reaches 4.3GB? I cannot find anything related to maximum accessible file size in the SD library link:

2) Does the write time becomes slower as the data file grow in size?

3) I would like to check for the space remaining on the card such that I know when to stop the routine. But I believe that the SD library doesn't support it? (I cannot use any other newer library) I can check the size of the data file using size(), but the maximum returnable value is 4,294,967,295 bytes. What happen if my data file size goes above that many bytes?

Thanks you!!
10  Using Arduino / Project Guidance / Re: Keeping a box cool on: August 26, 2014, 01:29:12 pm
Thanks for the response!
I can't put the box in the shade because I am measuring the Sun  smiley-sweat.
And isn't it elevating  the box better than bury it? Because the ground could get heated up by the Sun, and the heat will than transfer to the box from all sides? Whereas heat cannot conduct through air if I am to elevating  the box.

I am no physicist but I believe heat transfer involves conduction, convention and radiation. Hot air also goes up. So I guess the white color can deal with radiation and the layer of soft material can deal with hot air rising up from the bottom. I am not sure how to deal with the rest, nor if I am doing things right haha...
11  Using Arduino / Project Guidance / Keeping a box cool on: August 26, 2014, 01:14:50 pm
Hey guys,

I am planning on putting a battery, solar charge controller, arduino and some sensors into a sealed plastic box for gathering data in a desert environment for a month. The battery is not supposed to go above 65C, so I am thinking if there are ways to passively reduce the internal temperature as much as possible without a fan.

To prevent heat from entering my box from the bottom, I have filled the bottom of the the box with a layer of soft material like so:

Then I put a plastic plate on top and put my components on it. I am hoping the material can serve like a blanket to prevent the heat from transferring from the bottom of the box to my components.

The box itself is elevated from the ground for around a meter. The top of the box is white, so hopefully some of the sunlight will get reflected. Do you guys have any more recommendation of how to keep the heat from entering the box?

Thank you!!
12  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 23, 2014, 02:03:01 pm
Thanks. So I think the best approach is to buy another arduino to handle the ADC and send the data to my old Mega to store in SD card? I also want to setup a ethernet server at some point which also use SPI. Do I need a third arduino?
13  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 23, 2014, 10:17:14 am
Thanks. So basically, SD.h and SPI.h cannot exist together, am I right? Is there a solution to the problem? SPI uses MISO, MOSI, SCK and CS, where SD card is default to be 4 and my ADC is 11. I don't quite understand what kind of "parameters" changes may have cause the conflict. Can you be a little bit more specific?

Does anyone had experience using SD card with another SPI device? Thanks.
14  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 22, 2014, 08:45:34 pm
Thanks for your reply. I am using a MUX to take samples from 16 sensors and I just thought it would be nicer to pack all the data into one string and print only that string to both the serial monitor and SD card.

But I don't believe it has to do with the SPI problem I am encountering. Thank you though.
15  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 22, 2014, 06:44:03 pm
I don't understand what can cause the Arduino to froze. I am assuming the SPI.transfer conflicts with something in SD.h library? Am I not suppose to use both SD card and SPI device together?
Pages: [1] 2 3 ... 5