[Help] ESP32 and lora sx1276 UART

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
qu3d45
Posts: 2
Joined: Thu Jul 11, 2019 10:33 am
Location: Odemira
Contact:

[Help] ESP32 and lora sx1276 UART

Post by qu3d45 » Mon Nov 04, 2019 1:14 am

Hello, I'm new to micropyton and programming in general. I'm a little confused, I've been looking for a solution without success for days.

If anyone is willing to point me in the right direction, I appreciate it.

What I want to do:
I am developing a project where I have two nodes (one in transmission mode and the other in receiver mode) ie unidirectional communication. The goal is to monitor some water quality parameters (ph, temperature, flow etc) on the first node and send to the second node. The second node will also measure parameters and send by GPRS to the cloud.

The problem:
I did my research job completely wrong because I didn't go to see if there were any micropython libraries for the sensors I have to use. For the sensors it was no problem, looking at the examples in python and arduino, I was able to write code and get the readings. I now have two Ebyte lora E32 modules but they communicate over UART and the examples I find have SPI connections. I lack the right knowledge to adapt the code to work in UART mode.

What I already searched for:
Libraries and examples: loboris, MZachmann, lemariva and Wei1234c;
AUART: peterhinch https://github.com/peterhinch/micropyth ... r/auart.py

The difficulty I have is I can not understand how I can communicate with modules by UART. Is it possible to back up files created for SPI? What should I do?

Sorry for the long post, and thanks.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [Help] ESP32 and lora sx1276 UART

Post by jimmo » Mon Nov 04, 2019 5:38 am

Hi,

Can you provide a link to the SPI examples? I wonder if you're perhaps looking at SPI code that talks directly to the SX127x inside the E32 module, rather than to the E32 itself which seems to use a UART interface.

I read some tutorials, e.g. https://www.teachmemicro.com/e32-ttl-10 ... ra-module/ and it shows some basic overview of what the UART protocol

To use UART from MicroPython, machine.UART should be all you need. http://docs.micropython.org/en/latest/l ... chine.html

It's not that easy to follow, but you can see this example Arduino sketch which uses SoftwareSerial (i.e. UART) to talk to an E32 -- https://github.com/Bob0505/E32-TTL-100/ ... TL-100.ino

User avatar
qu3d45
Posts: 2
Joined: Thu Jul 11, 2019 10:33 am
Location: Odemira
Contact:

Re: [Help] ESP32 and lora sx1276 UART

Post by qu3d45 » Mon Nov 04, 2019 1:03 pm

Hello jimmo,

first of all thanks for the reply.

I had already seen these guides (sorry for wasting your time). The modules are configured according to the datasheet, I have both in normal mode, on the same address.

The example I saw in SPI is this (there are others but the principle is the same): https://github.com/lemariva/uPyLora

from the main.py file, I realize I have to have the dependencies:
import config_lora
from sx127x import SX127x
from controller_esp32 import ESP32Controller

The problem is that the controller_esp32.py file is for SPI communication.

I have also looked for examples for UART communications with other modules (like NRF24), I will try to adapt.

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: [Help] ESP32 and lora sx1276 UART

Post by mcauser » Tue Dec 24, 2019 10:16 am

The E32-915T20D from EByte uses the SX1276.
https://s.click.aliexpress.com/e/FI48NfnS
It has an onboard microcontroller which communicates with the SX1276 over SPI and provides a simple UART interface to control it. You do not get direct access to the SX1276. The UART protocol is super simple. You give each device an address and they can send packets to each other, or broadcast to all devices within range. You don’t have to set any registers, simply UART read and write, with 2x IOs to set the device mode (sleep, wake, config, wor).

The above board runs on 915MHz band. It also comes in 898 and 433 bands, for international users. Australia uses the 915 band.

EByte also sells modules which provide direct access to the SX1276 over SPI. Ie no microcontroller or UART. These modules are less breadboard friendly and designed to be added onto larger existing boards or breakouts
https://s.click.aliexpress.com/e/5U51gQdw
These modules need different drivers as you are controlling the SX1276 directly.

Post Reply