User Tools

Site Tools


arduino_stripboard_windows_programming

Programming Arduino Nodes using Windows

Having just completed setting-up some nodes using the Arduino stripboard design, I thought it might be helpful to jot down some notes and gotchas.

Equipment needed: Ideally you need an AVRISP mkII programmer connected to a ZIF socket. I use an Olimex AVR-ISP mkII (abt £20) along with a Sparkfun AVR ISP Shield (£14) as this provides a ZIF socket, ISP connector and the Olimex can be set to power the chip. If you want a cheaper option, it's easy to make your own ISP to ZIF socket using stripboard. To use the Olimex AVR-ISP with Arduino IDE, you need to follow the instructions in the user manual to update the firmware. It's a simple and well documented process.

Node ID: If you want to upload to the central UKHASnet you need to decide on a unique ID for your nodes. You can see an up-to-date list of existing nodes here: https://www.ukhas.net/nodeList When you create your node you also need to complete the Station field. If it's not visible on the node creation screen, go ahead and create your node and then open the edit node dialogue to add the station type.

Perparation

  1. If you haven't done so already, install the Arduino IDE from here:http://arduino.cc/en/Main/Software
  2. Download a zip of the UKHASnet firmware from here: https://github.com/UKHASnet/UKHASnet_Firmware
  3. Unzip the firmware into your My Documents/Arduino folder. This is where the Arduino IDE looks for its sketches/programs.
  4. Next we need to add the board configuration details for this project.
  5. Select and copy the Arduino board script from this page guides:arduino_design.
  6. Use the Windows menu to find Notepad. Right-click and choose Run as Administrator. NB: if you don't run Notepad as administrator you won't be able to save the edited file.
  7. With Notepad, open C:\Program Files\Arduino\hardware\boards.txt
  8. Paste the script you copied earlier at the end of this file and save it. That completes the setup.

Node Programming

First decide what type of node you want to build. I suggest you start with a gateway and a sensor node. That way you’ll have some data along with a way of extracting it from the network.

  1. For the sensor, start the Arduino IDE and open the sensor sketch that you’ll find in: File – Sketchbook – UKHASnet_Firmware_Master - arduino_sensor.
  2. Click on the Arduino tabs to open NodeConfig-template.
  3. This file sets many parameters for the node so you need change all references to P01, P02 and replace them with your node ID. You also need to change the location string to your coordinates.
  4. When you’ve finished updating the NodeConfig-template you must SAVE As to create the nodeConfig.h
  5. Assuming you’re using an AVRISP mkII programmer, go to the Tools menu – Programmer and make sure AVRISP mkII is selected also check that the board is set to: 'ATmega328 on a breadboard (8MHz internal clock)'.
  6. The next stage is to burn the bootloader. NB: This is essential for the node to work correctly. Make sure the AVRISP programmer and chip are plugged in. From the Tools menu select Burn Bootloader.
  7. The final stage is to upload the code to the ATmega328.
  8. Go to the File menu and choose Upload Using Programmer.
  9. Watch the status screen at the bottom of the Arduino IDE to check that the programming completes successfully. NB: The build will probably fail if you've already installed libraries that are contained in the UKHASnet firmware folder, i.e. 1-wire. The simple solution is to delete the Arduino libraries as they're easy to put back later.
  10. Repeat the above for the gateway node.

Testing

The simplest way to power these nodes for testing is with 3 x AA cells. With both units (gateway and sensor) powered-up, connect a serial lead to the Tx/Rx pins on the gateway node and open a terminal session at 9600 baud - PuTTY is a good program if you don't already have a favourite. Give the system a while to settle down and you should start seeing packets along with an RSSI report. There will be two types of packet, one is a beacon and the other is a full data packet that includes the location string. You can change the frequency of the beacon transmissions by amending the nodeConfig.h file (#define BEACON_INTERVAL).

Checking the RF

With the sensor and gateway nodes powered-up, you can check the RF. To do this you need a receiver for 869.5MHz. The cheapest solution is to use one of the RTL digital TV dongles with SDR Sharp software. If you have a FUNcube Dongle v1 or v2 they can also be used. Tune the receiver to 869.5MHz, set the receive mode to FM and change the bandwidth to 30kHz. If all is well, you should be seeing brief bursts of RF activity which is the transmissions from your nodes. If your using SDR software you will hear the signal just after it prints on the Raspberry Pi terminal. This is due to processing delays in the SDR software.

Gateway

If you want to upload your data to UKHASnet and also make your node available to relay balloon traffic, here's what you need to do:

  1. Using a Raspberry Pi, clone Phil's gateway code from here: https://github.com/UKHASnet/Gateway-Upload.
  2. Navigate to ukhasnet-upload.py and change the gateway_callsign to your gateway node ID.
  3. Connect the Tx/Rx and ground connections between your gateway node and the Pi. NB: you need crossover the Tx/Rx connections so Tx on the Pi goes to Rx on the node and vice versa. In truth, you only need to connect node Tx to the Pi's Rx in this simple implementation.
  4. The Pi also needs to be connected to the Internet - Ethernet or Wi-Fi is fine.
  5. Run ukhasnet-upload.py to start the transfer of data.

That's it! If all is ok you should see your station appear on the map.

Voltage Reporting

You will probably find that your sensor node reports the wrong board voltage. This is easily corrected as follows:

  1. Measure the board voltage with a multimeter.
  2. Note the value broadcast by the node and divide by 1.102 (the default fudge factor).
  3. Divide the measured voltage in 1 by the result of 2 above to find the new fudge factor.
  4. Enter the new value into BATTV_FUDGE in the NodeConfig.h file for the sensor.

Troubleshooting

  • Arduino build fails: Check that libraries contained in the UKHASnet_Firmware folders are not also present in the Arduino Libraries folders.
  • Corrupt data when testing with a serial terminal: Try changing the terminal to 1200 baud. If that works then you haven't burnt the bootloader correctly as the clock divide by 8 fuse is still set.
  • Data is visible on the UKHASnet website but there is no map plot: Make sure your node type is set to station or balloon as appropriate. You can check/correct this using Node Edit.
arduino_stripboard_windows_programming.txt · Last modified: 2014/10/17 21:37 by g4wnc-mike