# Arduino sketch generator

**URL:** <https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542>\
**Category:** End Devices (Nodes)\
**Created:** [April 7, 2017, 11:50am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542 "2017-04-07T11:50:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdelaet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jdelaet/32/8164_2.png) [@jdelaet](https://www.thethingsnetwork.org/forum/u/jdelaet)\
**Post date:** [April 7, 2017, 11:50am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/1 "2017-04-07T11:50:52Z")

</div>

On the side of our dashboard for TTN Den Bosch we, some time ago, created a tool to generate Arduino sketches in a simple and fast way for the members of our community.  
I know there is still a lot to do, but the basics are working. Maybe it is time to share it with a bigger audience.

You can find it here: [https://lcd-web.nl/ttngenerator/](https://lcd-web.nl/ttngenerator/)

The tool is in PHP/Mysql.  
The base is a template where some spots need to be filled depending on selection of radio, sensors, etc.  
The tool is a form to enter/select the variables and a function to generate and display the sketch. The generated sketch can be copied to the Arduino IDE.  
The function simply replaces some placeholders in the template and inserts the code that belong to the selected radio and sensor.

Things I would like to add:

- access TTN console to select a device and get the device keys
- test RN2483 radio; more specific which library to use best and test OTAA
- use the device keys in the (string) format as currently displayed in the console

---

<div class="post-metadata">

**Author:** ![ccadic](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ccadic/32/32636_2.png) [@ccadic](https://www.thethingsnetwork.org/forum/u/ccadic)\
**Post date:** [April 7, 2017, 11:53am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/2 "2017-04-07T11:53:44Z")

</div>

Excellent. Tnx

---

<div class="post-metadata">

**Author:** ![jezd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jezd/32/46461_2.png) [@jezd](https://www.thethingsnetwork.org/forum/u/jezd)\
**Post date:** [April 7, 2017, 12:01pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/3 "2017-04-07T12:01:24Z")

</div>

Nice idea, will test later

---

<div class="post-metadata">

**Author:** ![lex\_ph2lb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/lex_ph2lb/32/44998_2.png) [@lex\_ph2lb](https://www.thethingsnetwork.org/forum/u/lex_ph2lb)\
**Post date:** [April 7, 2017, 12:04pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/4 "2017-04-07T12:04:50Z")

</div>

Thanks for sharing, took a quick look and it generates nice templates.

---

<div class="post-metadata">

**Author:** ![Caspar](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/caspar/32/46719_2.png) [@Caspar](https://www.thethingsnetwork.org/forum/u/Caspar)\
**Post date:** [April 7, 2017, 9:58am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/5 "2017-04-07T09:58:28Z")

</div>

Please give it a cool name “Automatic TTN - Code Generator” aka “AT-CG”, or something, then please put it on github for others to help (i would love to do so).

Stuff i would like to add:

- Give the Pinmappings “Names” aka “Pinmapping for loratracker PCB”/“Pinmapping for charles red PCB”/etc.
- Add Pictures from those PCBs, so people are 100% sure to take the right one
- Add custom pins for the sensors
- Put deveui/appeui/etc. in seperated input fields to make copy&paste easier
- Tell about the used libraries for the different sensors outside of the code (make a warning on top for example) and make it easy for people to find/download/install them

Just to give you a few ideas - and thank you very much for the work done already!

---

<div class="post-metadata">

**Author:** ![JDP](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jdp/32/35697_2.png) [@JDP](https://www.thethingsnetwork.org/forum/u/JDP)\
**Post date:** [April 8, 2017, 12:17am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/6 "2017-04-08T00:17:37Z")

</div>

Jdelaet, nice idea. I look forward to trying it. If you pm me your address, you’ll get a RN2483 Arduino in the mail to test with…

---

<div class="post-metadata">

**Author:** ![jdelaet](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jdelaet/32/8164_2.png) [@jdelaet](https://www.thethingsnetwork.org/forum/u/jdelaet)\
**Post date:** [April 8, 2017, 11:36am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/7 "2017-04-08T11:36:40Z")

</div>

Thanks @JDP.  
I have a R2483 available to test, so no need to send yours. But very much appreciated.

The R2483 generated code should work for ABP devices. I need to test it for OTAA, but need to find the time to do that.

Any suggestion which library would be best to use for R2483?

Thanks, Jan

---

<div class="post-metadata">

**Author:** ![JDP](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jdp/32/35697_2.png) [@JDP](https://www.thethingsnetwork.org/forum/u/JDP)\
**Post date:** [April 8, 2017, 1:22pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/8 "2017-04-08T13:22:52Z")

</div>

Great! I use both TTN and Sodaq libraries. In Arduino IDE under library manager filter by ‘RN2483’ and you’ll find those 2, plus some others

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [September 27, 2017, 11:11pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/9 "2017-09-27T23:11:45Z")

</div>

This sketch generator is very useful for us and someone who is not an expert on C programming. Please keep update. Thank you.

---

<div class="post-metadata">

**Author:** ![ursm](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ursm/32/46475_2.png) [@ursm](https://www.thethingsnetwork.org/forum/u/ursm)\
**Post date:** [September 28, 2017, 9:28am UTC](https://www.thethingsnetwork.org/forum/t/arduino-sketch-generator/6542/10 "2017-09-28T09:28:41Z")

</div>

there is no link for the Lowpower library documented, but I assume that you mean

> **[rocketscream/Low-Power](https://github.com/rocketscream/Low-Power)**
>
> Low Power Library for Arduino. Contribute to rocketscream/Low-Power development by creating an account on GitHub.
