ESP8266 and Arduino using LoRa and AES encryption

Here there are the raw codes to get an Arduino and an ESP8266 connected at SX1276. They are able to do LoRa bidirectional communication between them. It has been developed a PyQt program to change frequency dynamically and be able to check CRC and AES features in real time:

PyQt code, examples and libraries for Arduino and ESP8266 using SX1276 for LoRa bidirectional communication with AES encryption capabilities.

Captura de 2016-06-19 21:23:03

 

ESP8266_LoRa

SX1276 and Arduino Nano hardware
SX1276 and Arduino Nano hardware

ESP8266 library for SX1276 using LoRA and PyQt

This PyQt code sends to ESP8266 payload binary information prepended by two bytes. 1st byte is function mode and 2nd byte is payload length. This code is able to receive binary information, to add CRC at the end or request a CRC calculation from ESP8266.

This ESP8266 library code is an adaption loraIno library for Arduino.

Hardware is based on absolutelyautomation.com IoT post and it can be found inside this pdf.

ESP8266_LoRa

Using LoRa with SX1276 and PyQt
Using LoRa with SX1276 and PyQt

To develop ESP8266 library code I have hacked common (H)SPI libraries for ESP8266. They are included in the same compressed file (spiESP.h , spiEspDirect.h and loraESP.h ). There is an example of use at loraESP.h library.

Programming STM32 using Arduino IDE on Debian Jessie

BOM

ST-LINK V2 programmer
stm32f103c8 learning board evaluation kit
STM32F103C8T6 ARM STM32 Minimum System Development Board Module 

20160608_133426

20160608_135242

 

Discovering ST-LINK V2 on Debian Jessie

I have followed these steps and I have changed file /etc/udev/rules.d/49-stlinkv2.rules because Arduino IDE doesn’t detect /dev/stlinkv2_4 but it is able to detect /dev/ttyACM4

stm32_rules

 

Arduino IDE

There is a good explanation at Roger Clark’s post. This is my suggested code:

stm32ArduinoIDE

If you have trouble with libusb-1.0 you can copy st-flash, st-info, st-term and st-util compiled binary files from texane’s stlink source code  to arduino-1.6.5/hardware/Arduino_STM32/tools/linux/stlink folder:
stlink-master

stlink

Arduino library for SX1276 using LoRA and PyQt

This PyQt code sends to Arduino payload binary information prepended by two bytes. 1st byte is function mode and 2nd byte is payload length. This code is able to receive binary information, to add CRC at the end or request a CRC calculation from Arduino.

It is attached an example inside loraIno library for Arduino.

Hardware is based on absolutelyautomation.com IoT post and it can be found inside this pdf.

SX1276 and Arduino Nano hardware
SX1276 and Arduino Nano hardware

You can run PyQt program on a Linux Terminal (it has been tested on Debian Jessie):

$ ./lora06.py /dev/ttyUSB0

In another Linux Terminal or another computer (it has been tested on Debian Jessie):

$ ./lora06.py /dev/ttyUSB1
Using LoRa with SX1276 and PyQt
Using LoRa with SX1276 and PyQt

PyQt and Arduino code

How to deal with binary data between Python and Arduino

This PyQt code sends to Arduino payload binary information prepended by two bytes. 1st byte is function mode and 2nd byte is payload length. This code is able to receive binary information, to add CRC at the end or request a CRC calculation from Arduino.

How to run in Linux (it has been tested on Debian Jessie):

$ ./dealingBinary.py /dev/ttyUSB0 9600

How to run in Windows (it has not been tested):

>  python dealingBinary.py \\.\COM1 9600

pyQt screenshot

PyQt and Arduino code