Sunday, September 13, 2020

LoRa Radio for the Amateur Radio Operator

 LoRa is a long range spread spectrum modulation technique derived from chirp spread spectrum (CSS) technology. Generally these devices are long range, low power, devices that are used for the Internet of Things (IoT) networks. 

Generally these devices are low in cost, and programmable using the Arduino IDE. There are many different Arduino compatible boards now. LoRa is different than LoRaWAN - this project just uses LoRa devices, and the devices are all under $30.00 U.S. dollars. (most a lot less than that).  

There are several projects like this, actually a lot more then several. There are even a few specifically for Ham radio. Probably one of the better known projects is from Travis Goodspeed and is simply called LoRaHam https://github.com/travisgoodspeed/loraham. This project hasn't been updated in about 2 years. The LoRaHam project is one of the first, if not the first project specifically for amateurs. The project code is easy to read, and it is fairly easy to understand what is going on.  Travis is using Adafruit M0 LoRa Feathers, which are a little more expensive. The drawback was I did not see how it would scale, the other thing that I thought about was these are IoT devices, meaning you could set up a sensor network, but there was no provision for adding devices that were not "chat" devices.  A more recent ham radio project called LoRaMaDor by Elvis Pfutzenreuter https://github.com/elvis-epx/LoRaMaDoR. Was inspired by LoRaHam, this project is still active, and I've contributed some small python scripts to the project. This project was designed more as a terminal program. It uses ESP32 devices mainly because the sketch uses a lot of memory, and the ESP32s have plenty of memory.  This project uses a better, more scale-able protocol, which I believe is similar to AX.25, thou I'm not 100% sure about that. The main draw back to the LoRaMaDor is how big the sketch when it's compiled. It appears that it was designed to work with just the ESP32 hardware. I did not try it with a LoRa M0 because I don't own one. The other problem is the sketch is just confusing to someone who may not be a programmer. I have been programming for a while, but I only consider myself to be an intermediate programmer, and while I understood some of it, other parts just were confusing. Maybe in another 5 years I'll understand.

I am also aware of the Hamshield for the Arduino, and aware there is a "chat" sketch for that device, that can be found here: https://github.com/EnhancedRadioDevices/LoRaChat. I don't know anything about this device except that it at a slightly higher power output than the "cheap" IoT devices. 

My project which tentatively I am calling LoRaAPS or LoRa Amateur Packet Service. The name may change based on feedback, or it may not. I was inspired by both of the above projects, and APRS.

What makes this project different, I attempted to create something that is as simple to understand as LoRaHam, but with "real" protocols that can be expanded on, and scaled. I am treating the device as an IoT device, like it was designed to be. The protocol uses json, the gateway uses a MQTT broker. The device will beacon every 10 minutes (like LoRaMaDor devices), It uses some of the same settings as LoRaMaDor, but isn't directly compatible with that system. By using some common IoT systems, interfacing to the devices should be fairly easy and straight forward. 

The sketches were written to able to add or change LoRa hardware as needed. Currently the hardware I have is Two LoRa32u4 devices, based on the Arduino Leonardo, Two TTGO T-Beam v1 with Oled display and GPS, and 4 TTGO ESP32-Oled. 

LoRaAPS uses Repeaters (digipeaters), pagers, and gateway devices, the roll of the device depends on which sketch is loaded onto the device. However LoRa32u4 devices seem to lean to being digipeaters. 

Roles:

DIGIPEATER - These devices will repeat any packet that they get, there is limited checking, if a message is addressed to the DIGIPEATER it will not be repeated. IE: Our digitpeater's callsign is KD8BXP-10.  If we send a message to KD8BXP-10 and if the digipeater hears the message, the message will stop there. If these are hooked to a computer, you can use a terminal program to send messages, but currently there is no way to see a message addressed to the digipeater. Sketch is called "relay"

GATEWAYS - These devices will also repeat any packet they hear. Packets not addressed to them will also be sent to a MQTT broker. Packets that are addressed to them will stop, and not travel. ESP32 devices appear to be perfect for this role, because they can connect to a WiFi network. Like the digipeater there is a limited serial interface, for sending messages, they will not show messages addressed to them. GATEWAYS add a few more limited checks for messages, mostly so a message they have already send doesn't get resent either OTA or back to MQTT.

PAGER - these are mobile devices, because the "network" is relatively small/new, they will also digipeat any packet they hear. Devices with some type of screen work well for this role, ESP32 devices with OLEDs. These devices will show messages addressed to them on the screen. If using an ESP32 a bluetooth terminal can be used to send messages, or if you connect them to a computer a serial console can be used.  These devices will also show "BEACON", "CQ", "WX", and "BLT" special calls. 

SERIAL PORT:  Settings: All roles can send messages via the serial port if connected to a computer, PAGERs using ESP32 devices can also send messages with a bluetooth terminal.  Serial Port Settings: 8-N-1 9600baud, the newline code is used to indicate you are ready to send.  You may also want to turn on "ECHO" for your terminal program, just to make it easier to see what you are typing. For Bluetooth you must make sure the BT terminal program you are using can send a "newline" code.  *Using PUTTY or the Arduino Serial Console is probably recommended* 

CALLSIGNS: All devices need to have a callsign with two digit ssid,00 to 99, which gives 100 possible devices. Callsigns must be unique, otherwise problems will arise, missed messages, or messages not sent, and could create other issues. 

SPECIAL CALLS: "BEACON", "CQ", "WX", "BLT".  "BEACON" this is sent every 10 minutes as long as the device is on, the message it sends can be changed within limits (Remember to keep the message short if you want to change it) by Default it will send "DE: KD8BXP-00 LoRaAPS v1 pager" or something similar to that. "CQ" can be used to see if anyone is around that wants to chat, like a normal "CQ", to use just send "CQ some message".  "WX" weather information, this is for future expansion, but could be used to ask a sensor for information, or used to make general weather reports. (*Still a work in progress, however it can be used now). "BLT" is like a bulletin on the APRS system, this could be used to make a general short anouncement, Like "BLT KD8BXP-20 Gateway going off line" or "BLT Net tonight at 7pm on W8BLV 146.610 repeater". I considered adding "GPS", "NET" and "CHAT" - but thought between "BLT" and "CQ" that could cover "NET" and "CHAT", and I couldn't figure out what I really thought "GPS" would be used for.

ROUTING: Routing is based off APRS "hops". APRS recommends 3 hops, the path for APRS is recommended to be WIDE1-1, WIDE2-2. What this means is the first station that hears a packet will mark off the first WIDE1-1, causing the path to become WIDE1-1*, WIDE2-2. The next station will mark off one of the hops from WIDE2-2, causing the path to look like this WIDE1-1*, WIDE2-1, finally the third station that hears the packet will retransmit and mark off the last hop. The next station to hear the packet will not retransmit.  This project uses a count down, when the counter reaches 0, the packet will no longer be transmitted. Because all the devices also act as digipeaters the use of a specific call was not needed (IE: WIDE1-1). On each hop the station that repeats the packet will also add it's call to the packet. (* Not implimented yet * Ability to display the path the packet took)

PACKET: When sending a message to someone you may see something like this:  
{"T":"KD8BXP-00","F":"KD8BXP-02","M":"This is the message","R":3,"P":["KD8BXP-02","NOCALL1","NOCALL2","NOCALL3"]}
The above is a json string that is sent OTA, and if coming from a GATEWAY to an MQTT broker. Json  stands for JavaScript Object Notation, it's lightweight format for storing and transporting data. It is common to find websites that use JSON, it has also become a defacto standard for the IoT. For machines this is easy to read and understand, while for humans it may look like it doesn't make much since, it is actually pretty easy to read simple json. Originally the JSON for this project was going to look a little different, I had to make some changes because of limits of how much data could be sent over LoRa. IF we look at what I had originally thought, it might be a little easier for a human to read.
{"TO":"KD8BXP-00","FROM":"KD8BXP-02","MESSAGE":"This is the message","RT":3,"PATH":["KD8BXP-02","NOCALL1","NOCALL2","NOCALL3"]}

So, hopefully this makes a little more since. JSON is generally in pairs, so in the above example. "TO" and "KD8BXP-00" are together. This message is meant for the device that has the callsign "KD8BXP-00". "FROM" and "KD8BXP-02" are a pair, so KD8BXP-02 sent the message, "MESSAGE" well this should be self explanatory, it's the message that has been sent. "RT" and 3, this is the re-transmit counter, and will be updated with each hop. Finally "PATH" as you can see PATH is associated with a group as signified from the [ ] braces. But the idea is the same, as the simple example. "PATH" each time the packet is re-transmitted, the callsign of the transmitting station will be added, first spot will be the original call (yes, "FROM" and the first call in the PATH are duplicated.) NOCALL1 will be replaced by the first hop, NOCALL2 by the 2nd hop, and NOCALL3 by the 3rd and final hop.

To save some space when sending OTA, everything was shorten to the first character of what it represents. It does make it a little harder for humans to read, but when you know what they mean, it is still readable. "T" = "TO", "F" = "FROM", "M" = "MESSAGE", "R" = "RT", "P" = "PATH". For the TTGO T-Beam, another field was added for "C" = "COORDINATES" or latitude, and longitude. It will look something like the "PATH" field.  {"C":[38.39899,-84.4994]}. The TTGO T-Beam will add it's latitude and longitude to each packet sent. But currently no other device uses this information.

SENDING A MESSAGE: While all the various roles can be used to send a message, only a pager can currently display a message received. Because of this, I recommend only using the pagers to send messages. The easy way is to connect the pager to a computer and use a terminal program, see above for settings. Sending a message is "callsign-ssid message", a message of upto 77 characters can be sent. IE:
"KD8BXP-00 This is my test message"

With out the quotes, If you forget the ssid, or if the message is too long you will get an error message in the serial console. (*BT currently has no feedback, an updated version will be coming soon). CALLSIGNS can be entered in low case, or upper case as desired. This makes it simple to create programs that can interface with the devices. IE: python script, or other types of programs.

ARDUINO SKETCHES: I am not going to go into how to install the correct "board core" for your device, there hundreds of tutorials on that subject. I'm also not going to go into how to install a library, again, there are a lot of tutorials for this as well. I do want to say which libraries are required and were to find those libraries. 

  1. LoRa https://github.com/sandeepmistry/arduino-LoRa
  2. ArduinoJson (please use version 5.13.5) https://github.com/bblanchon/ArduinoJson
  3. TimedAction https://playground.arduino.cc/Code/TimedAction/
  4. SSD1306Ascii https://github.com/greiman/SSD1306Ascii
  5. PubSubClient https://github.com/knolleary/pubsubclient
  6. (for the T-Beam Device) TinyGPS++ https://github.com/mikalhart/TinyGPSPlus
  7. (for the T-Beam Device) axp20x https://github.com/lewisxhe/AXP202X_Library

Sketch names: gatewayLoRa32, pagerLoRa32, pagerT-Beam, relay32u4, relayLoRa32

GatewayLoRa32 - This is written for the ESP32 devices (LoRa32-Oled) the display is not used, this will gate messages to a MQTT Broker. see GATEWAYS above. 

 PagerLoRa32, PagerT-Beam - these are written for the ESP32 based boards, with OLED display support. The T-Beam version also adds GPS support. See PAGERS above.

Relay32u4, RelayLoRa32 - These are digipeaters, Relay32u4 was written for the LoRa32u4 boards, while RelayLoRa32 is written for the ESP32 device, no OLED display, these will just relay (digipeat) see DIGIPEATER above.

The sketches are written in such away that if you do not have a ESP32 or LoRa32u4 or T-Beam, you should be able to adapt the sketches to work with what you do have. * Please share if you have other hardware, let's extend the project and make the network better. *

LORA SETTINGS: LoRa settings should be considered for each area, the only thing to consider is frequency to use. The current project uses 433mhz hardware, with a spreading factor of 9, coding rate of 5, tx power of 17, and bandwidth of 62500. Every device using the network has to match, frequency, and the above. These can be local settings however, and don't have to be used globally. But if you want to communicate with another ham in your own town, the settings do have to match each other. 

MQTT BROKER: MQTT is a lightweight messaging protocol for small sensors and mobile devices, optimized for high-latency or unreliable networks. Originally designed by IBM in 1999, it was used to monitor oil pipelines. The goal was to have a protocol that is bandwidth-efficient, and uses little battery power. This is a publish/subscribe with topic hierarchy. IE: Device 1 publishes a message "Light ON" to topic "LIGHTS", Device 2 (The light) subscribes to the topic "LIGHTS" and acts on the message "Light ON". For this project, the gateway subscribes to the same topic it publishes too, this is a little strange, but not unheard of, our gateway will filter out it's own messages, it will also filter out invalid JSON.  The project currently uses a public MQTT broker, because of this anyone can subscribe or publish to the topic (an attempt was made to make the topic hard to remember, but not impossible). Also because this connection could be seen by the public consider every message sent to be in the clear, don't send sentive information. 

Because MQTT is a common and standardized protocol, phone apps, python scripts, or custom written software can be used to expand on the network, and make the network more useful.

* IF this project gains lots of users, it may make more since to more to a private broker, at which time the project would need to gain funds to fund that broker. 

** A Raspberry PI could also be used as a broker, this might be good for keeping information within a local network, and not gated out to the world. If you choose to go this route, you might also consider using a MQTT bridge to bridge to more/other networks. http://www.steves-internet-guide.com/mosquitto-bridge-configuration/

RECOMMENDED SETUP: At this time the "network" is small, very small. So I would recommended setting up at least one gateway, one relay (digipeater), and one pager. Good antennas are almost a must for this project, but they will work with the stock "antenna".  DIGIPEATERS should be on higher ground,  while a gateway can sit on your desk to make it easier to connect it to the internet. PAGERs can either be mobile or stationary. SSIDs - there is no hard or fast rule to this, I would recommend using higher numbers for your GATEWAY and DIGIPEATERS, leaving the lower number ssids for the PAGERS.  IE: GATEWAY - KD8BXP-70, DIGIPEATER - KD8BXP-80, PAGER KD8BXP-00, or PAGER KD8BXP-01. If you plan on deploying some sensors you may want those to be in the 50 or 60 range. This are just recommendations, and are subject to change based on feedback, and other factors.

Sept 12, 2020 - v.5, documentation written. github repository created, code not yet published. 


Tuesday, December 18, 2018

A 100 meter lidar (?) Maybe not.....

100 Meter LiDAR Range Sensor
Found this unit on Aliexpress, for around $32 dollars, it was probably used as an electronic tape measure. The thing that peaked my interesting was the 100 meter range (328 feet or so). It is easy to use, and seems to work well, but so far I've not gotten anywhere close to the 328 feet. (32.8 feet is about the best I've seen so far)
Could this be a miss print on the listing, or could I just be using this wrong (?) ......
Well either way, I've set this up to work with an Arduino Uno - so far I'm just displaying the distance on a DF Robot 1602 LCD/w buttons.
Laser Type: 635nm, 1 mw (red)
Range: 0.02 to 100 meters
Typical accuracy: +/- 2mm (0 to 40, indoor 20 meters white walls; through correction can be up to +/- 1.5mm)

The laser can be turned on or off (assuming for aiming reasons), reads can be “automatic”, fast (less accuracy), and slow (more accuracy) - “automatic” appears to be about medium speed.
The laser can also display it’s temperature and voltage levels. The output of the sensor is in the format of a String, a typical reading may look something like this:
“12.345m,0079” which tells the distance, and signal quality.  Signal quality a lower number is better. This is good for display, and easy to use for display, but it’s a problem if we need to compare the numbers, or if we are using this on a robot and need the robot to stop at a distance.
Luckily - there is a way to remove the unwanted information from a string, and turn that string into a float - it’s not pretty, and a lot of code to do it, but it can be done.
In my demo, I’ve converted the distance from meters to feet to cm to inches. I’ve dropped the signal quality - but it can be pulled out and used as well.
The demo, will display if the laser is on, or off, the temperature and voltages (default temperature is Celsius, and I convert it to Fahrenheit), formatted for the display I am using.
I’ve setup 5 buttons, one for normal reading, one for fast, one for slow - one will toggle the laser on or off, and one will display voltage, temperature.
An expanded demo would be to use this on a robot for distance/obstacle avoidance.
(under my less than scientific tests, I’ve only been able to get a reading of 32.x feet or about 10 meters - anything greater than 32 feet gives either a reading that is just wrong, or an error. Is it possible that I have a bad unit, or that it really is 10 meters not 100 meters (which would mean it was listed wrong to start with)? )

Wednesday, October 10, 2018

Merge two GIT repositories to ONE.

Recently I wanted to merge two GIT repositories into one.  The main reason for this was the two projects were different, but closely related, sharing much of the same code.  And I just thought it would be easier if everything was together.

So I did what any normal person does, I googled it.  Turned out this is easier to do that I thought it would be - the results are easy to find on google - but I thought I'd share my use case - not only might it help someone else - But it will help me when I want to do this again - I willn't have to search, I can just look at my blog :-)

This posting on stackoverflow asks the question perfect:
https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories

Question:
"Consider the following scenario:
I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.
How do I merge A into B, without losing history on any side?"
The Best Answer:
If you want to merge project-a into project-b:
cd path/to/project-b git remote add projectgit remote add project-a path/to/project-a git fetch projectgit fetch project-a git merge
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge git remote remove project-a 
This method worked pretty well for me, it's shorter and in my opinion a lot cleaner.
Note: The --allow-unrelated-histories parameter only exists since git >= 2.9. See Git - git merge Documentation / --allow-unrelated-histories
This also worked pretty well in my case, I ran into one conflict - so off to google again to find how to resolve that (again, GIT makes it pretty easy to deal with the conflict)
https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/

This needs to be read - but the basics of it the arrows in the file show where the conflict is, and from which branch the conflict came from.  And the equals is the dividing point.
So you might see something like
If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a

Decide if you want to keep only your branch's changes, keep only the other branch's changes, or make a brand new change, which may incorporate changes from both branches. Delete the conflict markers <<<<<<<=======>>>>>>> and make the changes you want in the final merge. In this example, both changes are incorporated into the final merge:
If you have questions, please open an issue or ask in our IRC channel if it's more urgent.
Add or stage your changes: git add *
and commit the changes with a comment:
git commit -m "resolved merge conflict"

There are other cases covered by the github help competing changes to a file that deal with complete file conflicts

Monday, September 10, 2018

DF Robot micro:Maqueen Robot For BBC Micro:Bit (programmed with the Arduino IDE)

DF Robot micro:Maqueen Robot
For BBC Micro:Bit (programmed with the Arduino IDE)
Sep 10, 2018



Prerequisites:
  1. Arduino IDE 1.8.x (recommend 1.8.5) installed and setup for your machine. https://www.arduino.cc/en/Main/Software
  2. Install the Arduino-nRF5 board core. Follow the instructions here: https://github.com/sandeepmistry/arduino-nRF5
  3. Install the Adafruit Micro:Bit Library: https://github.com/adafruit/Adafruit_Microbit and learn more about it here:  https://learn.adafruit.com/use-micro-bit-with-arduino
  4. Finally install the arduino-BLEPeripheral library (either from the library manager or by following instructions here: https://github.com/sandeepmistry/arduino-BLEPeripheral  ) * Note be sure it’s the one from sandeepmistry if you are using the library manager *
  5. NewPing Library (Which I believe is this library) https://github.com/eliteio/Arduino_New_Ping and is only needed if you are going to use an ultrasonic.

For this project you will need at least one Micro:Bit Controller:

And the Maqueen Robot chassis: https://www.dfrobot.com/product-1783.html

The Micro:Bit is setup to use Microsoft:MakeCode or Scratch and Python.
The Sandee P Mistry Board core lets us use this board with the Arduino (C style) language as well.

General Information:
I used the general information that is found either in the Maqueen MakeCode library on the board itself, or from trial and error to come up with something that works (mostly) with the Arduino IDE.

Working (or mostly working):
  1. Motors (I2C interface, easier to port than I thought it would be)
  2. Line Sensors (P13, P14)
  3. Ultrasonic (using newping library) P1, P2 * Attempted to get this working without the library, but it failed (????) *
  4. 2 LEDs P8, P12
  5. Buzzer P0 - *  tone is not yet implimented with the board, analogWrite works but doesn’t sound great, bit bang also works, but doesn’t sound great - this is in the mostly working columb)
What’s not working: (These things work if you use MakeCode, but so far I’m unable to get them to work with Arduino).
  1. NeoPixels (P15 4 pixels) - The Adafruit Neopixel library appears to be the only library that supports the Micro:bit, this isn’t surprising. But I’ve not been able to get it work on P15, it does work on P2 which is what the example provided is using. https://learn.adafruit.com/micro-bit-lesson-3-neopixels-with-micro-bit/software
  2. IR receiver (P16) - so far I am unable to get this to work at all - *I need something that doesn’t mess with interrupts or timings, but I think that is a big ask for this device*
  3. Communication between two Micro:bit controllers - It’s a bit upsetting to me that such a basic thing was neglected in the Arduino IDE (If this does work, and you have supporting code please share - I have not been able to get this to work, or find any code that claims it works) ** This is a basic thing in the MakeCode, I’ve not been able to find the library they use or information about how they make it work **  https://learn.adafruit.com/micro-bit-radio-controlled-puppet/code-the-two-micro-bits    


Basic Sketches:  (To be duplicated)
  1. Drive and turn - (done) I2CMotortest, I2CMotortest2
  2. *RGB Breathing Ambient Light - unable to complete at this time.
  3. LED Light Flash - (DONE) - blinkdemo
  4. Read Ultrasonic Distance  (*DONE*) - They output to the LED Matrix, I output to the Serial console of the Arduino IDE (Easy to change as needed) newping
  5. *Read Infrared Key Assignments - unable to complete at this time. *
  6. *IR Remote Control - unable to complete at this time*
  7. Line Tracking - Currently Working on it.
  8. Ultrasonic Obstacle Avoiding - (DONE) - avoid
  9. Light Operated Sprite (unsure about this one)
  10. Wireless Remote Control  - * They are using a Micro:bit Gamepad (see below), I believe I can make this work with the Tablet and Adafruits Bluefruit LE Connect software * This is a work in progress.

The compass and accelerometer on the Micro:bit also work, as well as the LED Matrix and the two buttons on it.  *The Compass is in the wrong orientation to be used as a true compass, but it maybe able to be used to do relative positions, I will have to test that more.*

I am in the process of making a library and attempting to duplicate the applications in the DF  Robot wiki. It is not even close to being ready. I’ll post a link when it is ready.

DF Robot also provided a Micro:Bit Gamepad for use with this project, the gamepad has 8 buttons total (various P#s), a LED on P16, buzzer on P0, and a vibration motor on P12
Button assignments:
DOWN  - P13
LEFT - P14
UP - P8
RIGHT - P15
X - P1
Y - P2
A - P5
B - P11

This was very easy to port over to the Arduino IDE, the buttons are all HIGH until they are pushed then they go LOW.
I may not be able to use this as intended because I am having problems getting two Micro:bit to communicate directly with each other.

A game or something may be coming thou...we will see

Friday, June 29, 2018

Using the Mediatek LinkIt One board with Linux and Arduino IDE (1.8.5)

Using the Mediatek LinkIt One board with linux and Arduino IDE
June 29, 2018

By piecing together a couple of instructables, and a “answer” from stackoverflow. And a couple of things of my own, I was able to get “Blink” to work on the LinkIt One board using Arduino IDE 1.8.5 - most of the thanks goes to user v-i-s-h from instructables Who provided most of what is needed.
Both of these instructables where written by v-i-s-h.

They mostly work as written - if you take the 1st one, STEP 1 and STEP 2 then start on the 2nd instructable, when that is done move back to the 1st for STEP 4 and 5. It mostly works.

On Arduino IDE version 1.8.5 you will get compile errors, which can be fixed using the information found here:
User Alan Wootton has the correct answer - you will still get compiler warning, but it works.
I got it to work by editing platform.txt
and adding core/ so that it reads:
{build.path}/core/syscalls_mtk.c.o
instead of
{build.path}/syscalls_mtk.c.o
platform.txt was located in:
/Users/awootton/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.17
answered Dec 16 '15 at 0:04
111


STEP 1 - Install the LinkIt One core into the Arduino IDE,

v-i-s-h has provided a core url that will work on linux machines.
https://raw.githubusercontent.com/v-i-s-h/LinkIt-One-Linux-Arduino-Support-/master/package_vish_linkItOne_linux_index.json

You will have to make a few changes, so you’ll need to go into the hidden “.arduino15” directory that should be in your home folder. You are looking for the packages directory under .arduino15
So it will look something like this:
/home/{user}/.arduino15/packages
You’ll want to find the LinkItOneLinuxArduino directory.

STEP 2 - in the tools/linkit_tools/1.1.17 directory

“/home/{user}/.arduino15/packages/LinkItOneLinuxArduino/tools/linkit_tools/1.1.17”
We need to make the scripts executable by issuing the command
chmod a+x *.sh
  ***DON’T REPLACE THE platform.txt file yet, there is a new version that uses  the updated “packtag.py” tool.

--So now we jump over to the 2nd Instructable.

STEP 3 (STEP 1) Get the updated packtag.py package.

And you’ll copy or move this file to the linkit_tools/1.1.17 directory from the previous step.
And you’ll need to make the python script executable.
chmod +x packtag.py

STEP 4 (STEP 2) Download the new platform.txt

You’ll need to right click on the link and then save as - if it doesn’t have the name platform.txt - rename it.
Replace the platform.txt found in
“/home/{user}/.arduino15/packages/LinkItOneLinuxArduino/hardware/arm/1.1.17” with the file you just downloaded - remember it needs to be called “platform.txt”

Important - Restart the IDE!

Now we can jump back to STEP 4 and STEP 5 from the original instructable.

STEP 5 - Blink The Built in LED.

Make sure to select the Linkit One from the board manager, look for the blink example (standard Arduino example)
*** NOTE The LinkIt One doesn’t define  LED_BUILTIN (The board core was written long before this became a standard thing to do) ***

The easiest way to fix this is at the top of the sketch add the line:
#define LED_BUILTIN 13

Or can also replace all the LED_BUILTIN with the number 13.

At this point, this is where the instructable kind of gets a little lost and confusing, So here is what I learned.
You need to save the modified version of your sketch (To compile sketches for this board you need to have a saved copy somewhere that you can get to easy).

On my system, the LinkIt One enumerates as two serial ports, /dev/ttyUSB0 and /dev/ttyUSB1 (of course those could change depending on what else I have plugged in.)
And apparently the device could show up as /dev/ttyACM1 and /dev/ttyACM0
What I found is compile the sketch, you need to have the board plugged in, it will fail to upload, but that is ok because we are not going to compile the sketch the way we would with a “normal” Arduino board.
To compile - click on the “Sketch -> Export” tab in the IDE,
In your sketch directory (This is why you need to save it somewhere), you will find a binary called “app.vxp”

Now we need to switch the LinkIt One from UART mode to MS mode - what I’ve found about this is the battery for the LinkIt One needs to also be installed and on….
(this could just be me).
Besure to make the mode change with the power removed.

Once you restart the LinkIt One, a small 10Mb removable drive should show up.
You are going to copy the “app.vxp” file to the MRE folder on the removable drive.

*** A ONE TIME STEP IS NEEDED ***
In the root of the LInkIt One drive you’ll see an ‘autostart.txt’ file, and you’ll need to edit it and point it to the app.vxp file, not the test.vxp file it is pointed at.
This should be on the 2nd line of the file, and it should look something like:
App=C:\MRE\app.vxp

You only need to do that once.

Disconnect your LinkIt One, (make sure battery is off as well, no power) - put it back in UART mode, and you should see the LED blink (or your sketch run on it).

That’s about it.