示例#1
0
文件: lora.py 项目: jorveys/uPyLoRa
	def __init__(self, header=None, period=0):
		#Se especifica la cabecera en caso de que solo se quiera procesar algo en especifico
		#y tambien un periodo por si se quiere hacer cierta accion de manera periodica

		self.header = header
		self.period = float(period)
		self.status = 1
		self.cb = None

		self.controller = ESP32Controller()
		self.lora = self.controller.add_transceiver(SX127x(name = 'LoRa'),
								pin_id_ss = ESP32Controller.PIN_ID_FOR_LORA_SS,
								pin_id_RxDone = ESP32Controller.PIN_ID_FOR_LORA_DIO0)
示例#2
0
def get_lora():
    ''' Setup and return a LoRa Esp32 controller'''
    params = {
        'frequency': 868E6,  # 169E6, 433E6, 434E6, 866E6, 868E6*, 915E6
        'tx_power_level': 5,  # 2
        'signal_bandwidth':
        20.8E3,  # 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3, 41.7E3, 62.5E3, 125E3*, 250E3
        'spreading_factor': 5,
        'coding_rate': 5,
        'preamble_length': 12,
        'implicitHeader': False,
        'sync_word': 0x12,
        'enable_CRC': False
    }
    controller = ESP32Controller()
    return controller.add_transceiver(
        SX127x(name='LoraTx', parameters=params),
        pin_id_ss=ESP32Controller.PIN_ID_FOR_LORA_SS,
        pin_id_RxDone=ESP32Controller.PIN_ID_FOR_LORA_DIO0)
def send(lora, ds18_temp, pH_final, discharge, tdsValue, temp_dht22, hum_dht22,
         total_discharge):
    for i in range(0, 5):
        payload = '{} {} {} {} {} {} {}'.format(ds18_temp, pH_final, discharge,
                                                tdsValue, temp_dht22,
                                                hum_dht22, total_discharge)

        # Mensagem a enviar pelo sx127x.py:
        lora.println(payload)

        sleep(5)


#####----- LoRa -----#####
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)

#####----- DS18X20 -----#####
ds18_pin = Pin(5)
ds18_sensor = DS18X20(OneWire(ds18_pin))

addrs = ds18_sensor.scan()
addr = addrs.pop()

ds_read = ds18_sensor.convert_temp()
sleep_ms(750)
ds18_temp = ds18_sensor.read_temp(addr)
示例#4
0
# coding_rate (5 to 8)
"""IMPORTANTE REVIZAR Payload pag 31 data sx127x """
#parametros = {'frequency': 869E6, 'tx_power_level': 2, 'signal_bandwidth': 125E3,'spreading_factor': 8, 'coding_rate': 5, 'preamble_length': 8,'implicitHeader': False, 'sync_word': 0x12, 'enable_CRC': False}
objeto = SX127x(name='LoRa1',
                parameters={
                    'frequency': 866E6,
                    'tx_power_level': 14,
                    'signal_bandwidth': 125E3,
                    'spreading_factor': 10,
                    'coding_rate': 5,
                    'preamble_length': 8,
                    'implicitHeader': False,
                    'sync_word': 0x12,
                    'enable_CRC': True
                })
controller = ESP32Controller(
)  #Configuracion de Pines y SPI para modificarlos realizarlo en
#En esta seccion ocurre una herencia multiple del objeto lora
lora = controller.add_transceiver(
    objeto,
    pin_id_ss=ESP32Controller.PIN_ID_FOR_LORA_SS,
    pin_id_RxDone=ESP32Controller.PIN_ID_FOR_LORA_DIO0)

#  # Transceiver permite agregar numero del pin chip SELECT y  pines de interrupciones para mas funciones del Modulo LoRa
#      def add_transceiver(self,
#                         transceiver,
#                         pin_id_ss = PIN_ID_FOR_LORA_SS,
#                         pin_id_RxDone = PIN_ID_FOR_LORA_DIO0,
#                         pin_id_RxTimeout = PIN_ID_FOR_LORA_DIO1,
#                         pin_id_ValidHeader = PIN_ID_FOR_LORA_DIO2,
#                         pin_id_CadDone = PIN_ID_FOR_LORA_DIO3,
#                         pin_id_CadDetected = PIN_ID_FOR_LORA_DIO4,