Arxiu de la categoria: Arduino

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

SPI – Sample of master and slave using two Arduino

Sample of SPI communication using two Arduino on S4A Programming Learning Board :

Arduino’s SPI master code (mirror)

Arduino’s SPI slave code (mirror)

 

How it works:

When at master board is pressed button attached at pin 2 (zero level), it is immediately received by slave and lits led at pin 3 on. Afterwards, master is reading slave and updates its led at pin 3. Pressing again button at pin 2 at master side lits led at pin3 off at slave side and, afterwards, master updates its own pin 3.

 

Modbus RTU on RS485 using Arduino and PyQt

Bill of materials:

Arduino Nano

S4A Programming Learning Board (pdf)

USB to RS485 Converter

RS485 Converter Module Board For Arduino

Arduino source code (version for RS485 module)

Program source code in pyQt (Python + Qt)

Connections:

Arduino         S4A PLB (P1)      RS485 module
  GND               P1-1              GND
   5V               P1-10             VCC
    5               P1-4              DE
    6               P1-3              RE
    7               P1-2              RO
    4               P1-5              DI
                                      A / D+
                                      B / D-