In order to be able to program your Wemos D1 Mini
you need to add the board to the Arduino IDE:
- Open the Arduino IDE.
- Go to
File
>Preferences
- Locate the textfield labeled
Additional boards manager URLs
at the bottom of the preferences window - If the field is empty, simply enter the following value:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
- If the field already has a URL in it (maybe you added a different device in the past) just put a comma
,
at the end of the existing value, and paste the above URL after it. - Click OK to save the change and close the preferences window.
- Open the Board Manager (
tools
>board
>board manager
) and search foresp8266
. Click install. - When Arduino is done installing the files you can select the right device to use:
tools
>board
>ESP8266
>Lolin (Wemos) D1 R2 & mini
- To be able to upload make sure you select the right port. When in doubt, just unplug the board, check the list of port options, then plug the board back in and note which new port appeared.
- Find and install "MCCI LoRaWAN LMIC Library" from the library manager.
- Now go into your Arduino libraries folder using Finder or Windows Explorer, and find the
MCCI LoRaWAN LMIC Library
folder. Inside is a folder calledproject_config
with a single file calledlmic_project_config.h
. Open this file in some text editor. - Find the line
#define CFG_eu868 1
and uncomment it by removing the//
in front of it, and comment out the other frequency plans by adding//
in front of them. This will make sure the library is set up for the European frequency plan. So the file will look like this:
In order to use The Things Network (TTN) we need to create an account. From this account we can create an application which will allow us to start receiving data from devices.
- Go to thethingsnetwork.org and click the
sign up
button in the top right. - Select the
Join The Things Network
option on the left. - Confirm your email address via the email they'll send you and log in.
- Select the region you are in (e.g.
Europe 1
). - In the menu in the top right, click
console
to get to your dashboard.
We need to create an application on TTN. This application will be the place where we can access any data being sent from our node.
- In the menu bar select
Applications
and create your application. - In the menu bar on the left select
integrations
>MQTT
. - At the bottom of the page, click
Generate new API key
Now we need to add our node to the application. This gives us some codes we can paste into the Arduino project, which will let TTN know what application our node belongs to.
- Go to
applications
> select your application - On the bottom right select
Register end device
- For
input method
selectEnter end device specifics manually
and use these settings:
- For JoinEUI, just enter 8 pairs of zeroes:
00 00 00 00 00 00 00 00
- Press
confirm
next to the JoinEUI field to have the next fields appear. - Press
Generate
behind theDevEUI
andAPPKey
fields to generate random values. - The
End device ID
gets filled in automatically: replace this value with a human-readable name, likemy-wemos-node
. This will help you recognize your node in the interface. - Press
Register end device
to finish
You now have all information you need to start programming your Wemos D1 mini to send data to The Things Network. Specifically what you need to copy to the Arduino code are the AppEUI
, DevEUI
and AppKey
values.
First, click the <>
icon behind the AppEUI
and DevEUI
fields. The text msb
and two little arrows appear. Click those arrows to change the format to lsb
(this basically reverses the values which is needed by the Arduino library), then press the copy icon to copy the value to your clipboard and paste them into the right spot in the Arduino code.