Skip to content

Commit

Permalink
cleanup repo ready for release
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Oct 31, 2024
1 parent 73a80f4 commit e3ed2e9
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 59 deletions.
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,74 @@
# LoLRa

*Transmit 900MHz LoRa frames surprisingly far without a radio*
Transmit 900MHz LoRa frames surprisingly far without a radio (And other radio shenanigans using ADCs, PWMs and I2S/SPI busses.)

* [Introduction](#introduction)
* [Background](#background)
* [LoRaWAN](#lorawan)
* [Limitations](#limitations)
* [Future Work](#future-work)
* [Resources](#resources)
* [Special Thanks](#special-thanks)
* [Range Tests](#range-tests)
If you are looking for the Hackaday 2024 microcontroller radio talk, you can <a href=https://cnlohr.github.io/lolra_talk>click here</a>.

## Introduction
* [Introduct and repo overview](#introduction-and-repo-overview)
* LoRa
* [Introduction (LoRa)](#introduction-LoRa)
* [Background](#background)
* [LoRaWAN](#lorawan)
* [Limitations](#limitations)
* [Future Work](#future-work)
* [Resources](#resources)
* [Special Thanks](#special-thanks)
* [Range Tests](#range-tests)

Firmware-only LoRa transmission, for a variety of processors. Send LoRa packets, without any radio, chips, external hardware or built-in radios at all on a variety of common, inexpensive processors. While not truly bit banging, this repository shows how using either a shift register (i.e. I2S or SPI port) or an APLL, you can send LoRa packets that can be decoded by commercial off the shelf LoRa gateways and other chips.
> [!NOTE]
> 1. This repo and many of the RF-specific files within are under an NON-AI license, and should not be included directly in other projects. **This repo is for educational purposes only and not intended to become a library**
> 2. The LoRa® and LoRaWAN® Mark and LoRa Logo are trademarks of Semtech Corporation.
> 3. LoLRa is not associated with Semtech in any way whatsoever.

## Introduction and Repo Overview

I have always been fascinated with sending and receiving radio signals from microcontrollers that don't have dedicated radio hardware. This repo serves as a overview of many of the projects I've done to do this decoding, along with example code (Though some of it is restrictively licensed)

> [!NOTE]
> This repo is designed for use with ITU Region 2 (The Americas) targeting 902-928MHz. Code changes are needed for use in Region 1 (EU, Russia, Africa) to target 863-870MHz or Region 3 (Australia, China, India) to target 920-923MHz.
> [!CAUTION]
> Because we rely on harmonics and aliasing, the primary frequency components emitted by your microcontroller are going to be in portions of the RF spectrum where RF transmissions are banned. Please filter your output or perform your tests in an area where you are unlikely to leak significant RF. The overall EIRP output is genreally ≪300uW across the whole spectrum spread out over hundreds of emission frequencies, but there is virtually no way a device deliberately transmitting on these frequencies could ever pass FCC part 15 compliance, even with filtering.
In general the repo is split up in to many projects, but categoriezed by device type.

* ch32v (Note, all examples require 8MHz (v203) or 24Mhz (v003) crystal oscillator)
* General Note: All OLED displays used here are 128x128 SPI-mode OLED displays.
* ch32v003-adcrx - prints quadrature values for receiving at 1/4 sample rate signals, or harmonics thereof. Specifically this is tuned to receiv CW on citizen band frequencies, specifically 27.000050 MHz
* ch32v003-lora - Successful (but very poor) transmission of LoRa messages with a ch32v003.
* ch32v003-timer - An attempt to use non-tabled dithering of PWM signals to send FM radio and/or 315MHz signals. *This does not work well* but it is included as a reference for dtrying to dither RF on the 003.
* ch32v003-txrx - Trying to send from one 003 to another 003 receiving. This does not work well - only about 1'.
* ch32v203-adcrx - Very basic quadrature decoding on a ch32v203.
* ch32v203-fft - Perform an FFT on a small window of samples on a ch32v203. This outputs to an OLED display. It doesn't keep up in realtime though. It also relies on <a href=https://gist.github.com/cnlohr/c4f9647a220781c005ff1a733dc9ed7f>fix_fft.h</a> (which cannot be distirbuted with this project because of a lack of license.
* **ch32v203-goertzel** - Perform a full goertzel's tuning on an incoming ADC signal so that it can listen to multiple AM and NBFM radio stations from an ADC pin.
* lib/calculator.html - webpage that can use webhid with ch32v203-goertzel.
* **ch32v203-lora** - Proper transmission of LoRaWAN packets (from the tests outlined below).
* ch32v203-tx - Very basic test, setup to just turn on a PWM on the ch32v203.
* esp32-s2
* **loratest** - Full stack protocol for sending LoRa messages from an esp32-s2. (From range test)
* **narrow_fsk_test** - Very basic test using dithering and the PLL in the esp32-s2 to see how tight/narrow control is possible with the esp32-s2. This does not do a dithered closed loop, but would not be terribly hard to add.
* **videoending** - Mechanism for allowing an ESP32-S2 to FSK, hopping around to draw a picture in a spectrogram. This was used for the video ending.
* esp8266
* example_125k_raw - Sending a raw 125kHz wide LoRa message.
* example_500k_raw - Sending a raw 500kHz wide LoRa message.
* **lorawan_example** - Using the I2S bus on the ESP8266 to send a full-stack LoRaWAN message to the things network.
* non_lora_310_transmit - Exmaple of how to transmit 310MHz OOK with an ESP8266.
* lib
* aes-cbc-cmac.h - Public Domain RFC4493 AES-CMAC header only library.
* LoRa-SDR-Code.h - MIT (unrestrictive) Licensed code to construct LoRa packets
* lorawan_simple.h - MIT (unrestrictive) Licensed code to construct LoRaWAN packets.
* rf_data_gen.h - Helper function for helping generate bit tables for I2S/SPI outpiut of carefully crafted signals.
* tiny-AES-c.h - Public Domain AES encryption/decryption library.
* tools
* 60-rtlsdr.rules - Make it so you can use your airspy from Linux as a user.
* complex_magsink_to_image.c
* testloradec.grc - Using gr_lora exmaple to decode LoRa in GNURadio

## Introduction (LoRa)

Firmware-only LoRa transmission, for a variety of processors. Send LoRa packets, without any radio, chips, external hardware or built-in radios at all on a variety of common, inexpensive processors. While not truly bit banging, this repository shows how using either a shift register (i.e. I2S or SPI port) or an APLL, you can send LoRa packets that can be decoded by commercial off the shelf LoRa gateways and other chips.

There are two major modes that this repository works with.

1. Transmission using a tunable PLL, creating a square wave, then using a harmonic (the 13th harmonic in the case of the ESP32-S2) and then transmitting the signal out a clock out pin.
Expand Down
2 changes: 0 additions & 2 deletions ch32v/ch32v003-adcrx/adcrx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// XXX TODO: Play with high bits of ADC control to see if there's a gain cicuit.

/**
MIT-like-non-ai-license
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ch32v/ch32v003fun
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 3 additions & 45 deletions ch32v/ch32v203tx/ch32v203tx.c
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
/**
MIT-like-non-ai-license
Copyright (c) 2024 Charles Lohr "CNLohr"
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the two following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
In addition the following restrictions apply:
1. The Software and any modifications made to it may not be used for the
purpose of training or improving machine learning algorithms, including but not
limited to artificial intelligence, natural language processing, or data
mining. This condition applies to any derivatives, modifications, or updates
based on the Software code. Any usage of the Software in an AI-training dataset
is considered a breach of this License.
2. The Software may not be included in any dataset used for training or
improving machine learning algorithms, including but not limited to artificial
intelligence, natural language processing, or data mining.
3. Any person or organization found to be in violation of these restrictions
will be subject to legal action and may be held liable for any damages
resulting from such use.
If any term is unenforcable, other terms remain in-force.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**/
// This file is under the standard MIT license, CC0 or Public domain. you choose.
// CNLohr <>< 2024
// It just does a normal PWM output from a ch32v203

#include "ch32v003fun.h"
#include <stdio.h>
Expand Down

0 comments on commit e3ed2e9

Please sign in to comment.