This project will help you create a connection between your phone and a LoRa module using the USB port and an Arduino Lilypad USB. There is an example chat app for point to point communication, and, you can modify it to make even a TTN sensor out of a smartphone :)
Step 1: HardwareYou can find all hardware elements here, or listed above.
You can chose between these two Atmega32U4 3.3v 8MHz models, although the black one seems to be a little bit better, the blue one stops working sometimes with my black phone ...
It is important to use OTG cable adapters
Choose one depending on what side you want to solder your chips
Since it is going to be in touch with your phone, I make use of a sandpaper and transparent tape to make it smoother and protect it from short circuits
there actually is transparent tape covering the contacts :)
Now you have to setup the Arduino IDE, note that you can use any other framework you like. It is not difficult but you have to do one or two things in order to compile the project.
Code is hosted in github.com,it is open source, feel free to contribute, reporting bugs or making suggestions would be great :)
Download it and open:
ArduinoIDE/USBRFMApp/USBRFMApp/USBRFMApp.ino
Change Sketchbook location under file --> preferences
If needed add additional boards under file --> preferences... I've been using:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
Select your board under tools --> Board
It should now compile.
Now open:
ArduinoIDE/USBRFMApp/USBRFMApp/Defaults.h
Change the default values if needed, they are in hexadecimal, I hope you can handle them, upload it to your board and configure it using the android app.
Android app Interface ConfigurationOnce it is all connected you can open and configure your device using the app located at.
USBRFMApp/USBRFMApp.v1.apk
You
can use that one, compile one yourself or download it from Google Play Store
It could be possible to connect your browser directly to the USB port using the Web Serial API, but at this time it is not mature enough and it does not work with phone browsers, that's why you have to use an Android app to access your USB port, it maybe changes in the future
The example chat program sends and receives encrypted messages using AES-256-CBC, the key depends on what room is configured under settings, use some secret room name for privacy, the same have to be configured in every device you want to chat with ... It is pretty easy...
Step 3: Custom AppIf you want to get rid of the chat system and read/write raw bytes from/to the RFM module open the Android Studio Project, edit the following file and add your logic.
AndroidStudio/USBRFMApp/app/src/main/assets/USBRFMApp/app/App.js
I hope it is clear enough
Comments