MANAGING THE ARDUINO CODE


STEP 4 — TEST THE ARDUINO

Upload the Code

Your code is now ready to be uploaded to the Arduino and tested. Make sure all the electronics and wires are still properly connected to the Arduino. Take your USB cord and plug one end into your computer and the other end into the USB port on the Arduino. You should see LED lights illuminate on the Arduino itself. It is now receiving power.

In the IDE, click on Tools and make sure the following are selected:

  • Board:  “Arduino Mega or Mega 2560”
  • Processor:  “ATmega2560 (Mega 2560)”
  • Port:  “COM# (Arduino Mega or Mega 2560)”

The COM# will actually have a number with it (e.g., COM1, COM2, etc.). Once you have these set correctly, you can upload your code by clicking on the arrow button in the top left corner of the IDE. The IDE will first re-compile the code and, if successful, then upload it to the Arduino. Once uploaded, the Arduino will immediately start running the code and will continue to do so until the power connection is lost.

Configuring the Upload Settings

Uploading the Code

Check the Serial Monitor

Now you will want to open up the Serial Monitor on your computer. Go to Tools → Serial Monitor. This is where all the Serial.print() statements in the code are writing to. At the bottom right corner of the Serial Monitor, make sure it is set to 9600 baud. If everything is set correctly, you should begin to see information printed to the screen.

Check the GPS and radiation measurements. Do they look correct? The GPS measurements might have a bunch of zeroes if you are inside a building. This is because it’s probably having a hard time receiving signals from the satellites. You will probably have more success picking up the GPS signals if you test your payload next to a south-facing window or, even better, outdoors away from a building.

There will be four radiation measurements, each calculated over the last 20 minutes: count, counts per minute, dosage, and dosage error. The International Advisors should be able to explain what each of these mean. After startup, the dosage measurements typically fluctuate for the first few minutes before settling somewhere between 0.05 and 0.10 uSv/hour (microSieverts per hour). This is the background radiation at your current location.

Printing Data to the Serial Monitor

Opening CSV File in Microsoft Excel

Check the CSV File

You will also need to check the CSV file on the SD card. First turn off the Arduino by disconnecting the USB cord. Then eject the microSD card from the Ethernet Shield, insert it into the black SD card adapter it came with, and slide the adapter into the proper SD card slot on your computer. Most laptops have a slot for SD cards.

On your computer, navigate to the SD card drive, find your .csv file, and open it in either a text editor or Microsoft Excel. Check to make sure it has data and that the data are being written correctly. This is a crucial step since this is where all your flight data will be stored. If the SD card isn’t creating or writing to the CSV file correctly, your flight data will have issues or be missing altogether.

Before moving on, you may delete the CSV file from the SD card if you wish. The Arduino will either create a new file (if none exists) or add the data to a pre-existing file (assuming it has the same name). It will not overwrite a file with the same name. Properly eject the card from your computer and completely insert it back onto the Ethernet Shield.

Check the Battery Pack

Disconnect your USB cord from the Arduino and plug in the battery pack that will be used during the flight. If the Arduino LEDs light up, the battery is providing power to the Arduino. Allow the Arduino to run for 15–20 minutes on battery. Then unplug the battery, remove the SD card, and check to make sure it was logging data during this time. If it did, your payload is just about ready to fly!

Delete the file, eject the SD card, and re-insert it back onto your Ethernet Shield before moving on to the final step.