92 lines
3.3 KiB
Plaintext
92 lines
3.3 KiB
Plaintext
0. Clone the uPyLora github repository:
|
|
git clone https://github.com/lemariva/uPyLora.git
|
|
Also download the files 'ssd1306_i2c.py' and 'ssd1306.py' from https://github.com/lemariva/uPySensors.git and put them in the uPySensors subdirectory of the uPyLora repo
|
|
|
|
1. Install esptool
|
|
$ pip install esptool
|
|
|
|
2. Flashing:
|
|
esptool.py --port /dev/ttyUSB0 erase_flash
|
|
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20190708-v1.11-132-gc24d81119.bin
|
|
|
|
3. Setting up webrepl:
|
|
Connect using picocom:
|
|
$ picocom /dev/ttyUSB0 -b115200
|
|
|
|
>>> import webrepl_setup
|
|
-> enable, set password and reboot
|
|
PW for Lora Workshop: lorawork
|
|
|
|
Connect to local wifi:
|
|
>>> import network
|
|
>>> sta_if = network.WLAN(network.STA_IF)
|
|
>>> sta_if.active(True)
|
|
>>> sta_if.connect("<SSID>", "<PW>")
|
|
>>> sta_if.ifconfig() # this prints the IP
|
|
|
|
Use access point to connect:
|
|
>>> import network
|
|
>>> ap_if = network.WLAN(network.AP_IF)
|
|
>>> ap_if.active(True)
|
|
>>> ap_if.ifconfig() # this prints the IP
|
|
|
|
4. Download WebREPL html from http://micropython.org/webrepl
|
|
Connect to the access point of the ESP and then connect to the ESP via online Webrepl:
|
|
-> Enter IP from above and click connect. Login with password 'lorawork'
|
|
|
|
5. Upload the files via the WebREPL (using the 'Send a file' dialog):
|
|
LoRaDuplexCallback.py
|
|
LoRaPingPong.py
|
|
LoRAReceiver.py
|
|
LoRaSender.py
|
|
config_lora.py
|
|
controller.py
|
|
controller_esp32.py
|
|
pymakr.conf
|
|
sx127x.py
|
|
Also upload the files in the uPySensors subdirectory (in a moment we will create a subdirectory on the ESP32 and move the files there):
|
|
ssd1306_i2c.py
|
|
ssd1306.py
|
|
Note that we did not upload the file main.py at this point! The reason is that this file would get executed each time the ESP32 is reset. We will instead create our own main file soon.
|
|
In the WebREPL prompt do the following to create a subfolder and move the ssd* files we just uploaded there:
|
|
>>> import os
|
|
>>> os.mkdir('uPySensors')
|
|
>>> os.rename('ssd1306.py', 'uPySensors/ssd1306.py')
|
|
>>> os.rename('ssd1306_i2c.py', 'uPySensors/ssd1306_i2c.py')
|
|
|
|
6. Test sending/receiving:
|
|
Enter the following code in the WepREPL prompt:
|
|
import LoRaSender
|
|
import config_lora
|
|
from sx127x import SX127x
|
|
from controller_esp32 import ESP32Controller
|
|
|
|
controller = ESP32Controller()
|
|
lora = controller.add_transceiver(SX127x(name = 'LoRa'),
|
|
pin_id_ss = ESP32Controller.PIN_ID_FOR_LORA_SS,
|
|
pin_id_RxDone = ESP32Controller.PIN_ID_FOR_LORA_DIO0)
|
|
|
|
Then repeat steps 1 through 5 with a second LoRa module (but replace /tty/USB0 by /ttyUSB1)
|
|
|
|
For the second LoRa module enter the following code
|
|
import LoRaReceiver
|
|
import config_lora
|
|
from sx127x import SX127x
|
|
from controller_esp32 import ESP32Controller
|
|
controller = ESP32Controller()
|
|
lora = controller.add_transceiver(SX127x(name = 'LoRa'),
|
|
pin_id_ss = ESP32Controller.PIN_ID_FOR_LORA_SS,
|
|
pin_id_RxDone = ESP32Controller.PIN_ID_FOR_LORA_DIO0)
|
|
|
|
On the python prompt of the first module enter:
|
|
LoRaSender.send(lora)
|
|
|
|
On the second module enter:
|
|
LoRaReceiver.receive(lora)
|
|
|
|
The display of the first module should then display an output like the following:
|
|
Hello (0) RSSI: -157
|
|
The number should be counting up (starting from 0)
|
|
|
|
The second module should output the same text, but the RSSI will be different (RSSI = received signal strength indicator; this indicates how good the connection is
|