There is a lot of information distributed across this forum on how to build nodes for TTN. I'm going to summarize how I built my first TTN node using an Arduino Uno and an RN2483 radio module. See this as a "How to get started" tutorial for first time builders. There are a lot of things this design can improve on, but this is at least a good place to start.
What you will need:
- Arduino Uno (an Arduino Nano, or any other ATmega 328p, or Arduino compatible board should work too)
- Microchip RN2483 LoRa module
Solder wires to the pins marked with red dots in the top view diagram below. It is better to use stranded wire, as solid core wire tends to easily break off when you solder directly to the radio's pins. An alternative way is to use VeroBoard.
You might also want to add a 8.6cm piece of wire to pin 23 (RFH) to act as antenna. Solid core wire does however work better in this case to keep the antenna straight.
An example of how I did this can be seen in the following photo:
Now connect the RN2483's wires to the Arduino like this:
RN2483 pin name <--> Arduino pin number UART_TX (6) <--> 10 UART_RX (7) <--> 11 RESET (32) <--> 12 VDD (34) <--> 3.3V GND (33) <--> Gnd
In my case it looks like this:
Next on to the software side.
Download the zip file containing the code from my github repository: https://github.com/jpmeijers/RN2483-Arduino-Library
Follow the steps to install an Arduino library.
After you installed the library, in your Arduino IDE you can go to
File -> Examples -> RN2483 Arduino Library -> ArduinoUnoNano-basic
On the TTN Dashboard which is currently available at https://staging.thethingsnetwork.org, register a new application and a new device. My advice is to use ABP for your first node. After creating it, enable "relax frame counter".
Around line 87 in the example sketch you opened earlier you will see lines looking like:
//ABP: initABP("Dev Address", "App Session Key", "Network Session Key"); join_result = myLora.initABP("02017201", "8D7FFEF938589D95AAD928C2E2E7E48F", "AE17E567AECC8787F749A62F5541D522"); //OTAA: initOTAA("App EUI", "App Key"); //join_result = myLora.initOTAA("70B3D57ED00001A6", "A23C96EE13804963F8C2BD6285448198");
In the comments above both lines the values that should be filled in between braces are described. If you registered a node as ABP on the TTN Dashboard, you have to uncomment the initABP line, and copy the correct keys from the dashboard into the Arduino sketch. Note that this is a hexadecimal value, so only numbers (0-9) and the capital letters A-F are valid. The strings should not contain any other characters. Use the example keys in the sketch as guideline what it should look like.
Program the code onto your Arduino. If it runs, the LED on the Arduino should be constantly on, except for going out for 100ms once every 5s. This means it is transmitting packets to TTN. If you do not see this behaviour, check your wiring.
If you are in the reach of a TTN gateway, you should now see your messages arriving on the dashboard.
You should have your first working TTN node now. Change the code, experiment, and let us know what you built!
Some more examples of my improvements to the Arduino+RN2483 combination:
Arduino Uno with RN2483 shield. The design of the shield is on my Github page.
Arduino Nano, surfacemounted on one side, with the RN2483 on the other side. I can provide this PCB design if someone needs it.
The idea for this last node is to use it as a sensor for ttnmapper.org. To power it I will use either a USB power bank, or two AA batteries.
More experiences with this type of setup can be found here on Janos' site. He also has nice photos of his setup using an Arduino Pro Mini + RN2483 running my code.