Trybotics Logo

Using DRF1276DM Lora Module With Node-red and Blynk

DESCRIPTION

When you want to read sensors on locations where no wifi exist then LoRa could be an option. LoRa means long range. It makes use of UHF wireless data technology (433MHz In Asian, 868MHz in Europe and 915 MHz in USA). Dorji DRF1276DM (868-915 MHz) is a special LoRa board which contain the Semtech SX1276 LoRa chip and also an MCU chip. This MCU take care for all the task and parameters needed for the SX1276 chip. The LoRa module receives from or sends data to the host through serial port (UART) at preset data format. The users don’t need to care about the process of data inside the module.

About the distance, up to 2000 meters should be possible.

Refer the datasheet from Dorji http://www.dorji.com/docs/data/DRF1276DM.pdf

On YouTube Andreas Spiess has done some field tests. http://www.dorji.com/docs/data/DRF1276DM.pdf

Refer also to http://www.dorji.com/docs/data/DRF1276DM.pdf

Description:

2x DRF1276DM (EUR & USA) or DRF1278DM (ASIAN) depends on which zone you are. Ebay

  • Antenne are included. Antenna for 868 MHz and 915 MHz are not the same. Order for the correct one.
  • This Supplier included the DAC-02 for free but ask the supplier if this is still valid.

1x Arduino mini pro 3.3V 8Mhz. Ebay

1x DHT22 Humidity & Temperature Sensor. Ebay

1x Dorji DAC-02 TTL-USB adaptor. (Needed for setup both Lora Modules and connect one LoRa module to the raspberry pi). If you cannot buy it then a FT232RL works also. You need some wires then.

1x FT232RL FTDI Serial Adapter 3.3/5V (Needed for programming arduino mini pro) Ebay

1x DC-DC Buck Step-down Power Supply Module 5V-36V to 3.3V Fixed Output.
(Not needed if you have 3.3V Power or battery) Ebay

1x RASPBERRY Pi 2 or 3.

1x Resistor 10k.

1x Breadboard.Ebay

Wire or copper wire (0.7mm) for the breadboard.

Description:

Step 1: From Node-red program in raspberry pi a request of Temperature and Humidity is given for Temperature & Humidity to DRF1276DM (Message is dht-read)

Step 2: Raspberry send this message by serial to DRF1276DM

Step 3: DRF1276DM connected to the raspberry pi is transmit the message (Wireless) to the DRF1276DM connected to the arduino.

Step 4:DRF1276DM send this message by serial to the arduino.

Step 5: Arduino checked the message. If the message is known, then the corresponding action is carryout (In this case the message dht-read is reading the dht22 sensor.)

Step 6: Arduino send the Temperature and Humidity values (serial) to the DRF1276DM connected to the arduino.

Step 7: DRF1276DM connected to the arduino transmit the message (Wireless) to the DRF1276DM connected to the raspberry pi.

Step 8: The message is send (Serial) from the DRF1276DM connected to the raspberry pi.

Step 9: Raspberry by send this message to Node-red

Step 10: Node-red received the Temperature and Humidity values and send the values to the Blynk cloud. User received the value on the mobil.

Description:

Before use these boards, a few configuration must be done. There is a special configuration tool from Dorji.

Download the tool from this site: http://www.dorji.com/docs/tool/DRF127xDM_V2.7.rar...

Connect DRF1276DM with the DAC-02 or RT232RL usb interface. See picture. If you using the Dorij Dac-02 solder a wire between pin 1 and 3, other wise the board is not enabled. Pin 3 (EN) must be connected to the ground. If using RT232RL set jumper at 3.3V.

Install the program and select the correct Com port.

Take over for both Lora modules exact the same values shown in the picture above.

Set Baud rate at 9600kb. The frequency depends which zone you are. With the DRF1276DM the frequency should be 868Mhz for Eur, 915Mhz for Ams. With the DRF1278DM the frequency should be 433Mhz for Azian.

Description:

Take a breadboard and place all the components on this board. Use a DC-DC voltage converter if the voltage is higher than 3.3V. I use an old 12V adaptor and connected to a 5-36V to 3.3V converter. If you using a battery or 3.3V power supply then a converter is not necessarily. A possibility is to remove the voltage converter from the arduino mini pro. The lifetime of the battery is much higher.

Before you place the mini on the board, it must be programmed. Connect the arduino mini pro to the RT232RL usb adaptor. Use all the connections otherwise the programming does not start on the arduino mini pro.

Download the program below.

You can change or add new commands in this arduino program (dht-read, ws1-on. ws1-off) . If you add or change it it must be also changed in Node-red. See step 8

Attachments

Description:

Connect the Lora module and the usb DAC-02 together. The benefit of the DAC-02 is that the pin layout is the same as for the DRF1276DM. So no wires are needed. Don't forget to solder a wire between GND and EN pin on the back site of the board.

Open terminal and enter command below.

Update raspberry: sudo apt-get update

Upgrade raspberry: sudo apt-get upgrade

Install or update nodejs/Node-red. Click on the link and copy the install/update link mentioned on the website into the terminal prompt. The latest version is 16.2 https://nodered.org/docs/hardware/raspberrypi

Auto startup of node-red: sudo systemctl enable nodered.service

Enter at the prompt: node-red-start
Read the name of the USB port in the last line. You need this to setup the serial port in node-red.

Exit Node-red: Press Ctrl C and enter at the prompt node-red-stop

If you login as not root user, then mostly the user are not member of the serial port.
sudo adduser MyUser dialout (Replace Myuser to your user)

Change the rights for the port.
sudo chmod a+rw /dev/ttyUSB0 (Replace ttyUSB0 with the correct port if necessary.)

Reboot the system.

Description:

In my opinion, Blynk is the most fantastic app what i have seen for IOT.

Go to the webpage of Blynk http://www.blynk.cc/getting-started/

Follow steps 1 & 2 (Follow the next steps if you develop your own applications)

For my application you need 2400 energy points (Every 1000 points cost 0.99 euros but if you sign Up, you get a certain number of energy for free)

Create a new project.

  • Add a device. For this project select arduino mini pro. For our project a device is not needed but it is mandatory to choose one.
  • Change project name to "Lora" for e.a.
  • You receive a E-mail with your Auth token for this project. This token is necessarily for Node-red. See Step 7

Add the Widget from the Widget box:

  • History Graph (Label Humidity %, Virtual pin V3, Min 35, Max 80)
  • History Graph (Label Temperature C, Virtual pin V4, Min -5, Max 30)
  • Value (Label Humidity %, Virtual pin V3)
  • Value (Label Temperature C, Virtual pin V4)
  • Value(Voltage, Virtual pin V5)
  • Button(Virtual pin V6)

Description:

Access and modifications to node-red

You have access to node-red locally in raspberry pi desktop through the web browser. Enter http://127.0.0.1:1880/
Or what I prefer remotely on my windows PC. Enter in your web browser http://{your_pi_ip-address}:1880

For e.a. http://192.168.2.232:1880/

Some addition/modification is needed in node-red, see below.

Add Blynk-Websocket node.

  • Click Option in Node-red (Three stripes at the top right corner) and select Manage Palette
  • Click Install tab page and enter Blynk on the search field.
  • Install node-red-contrib-blynk-websockets.
  • After install click done and refresh the page (F5)

Import Flow.To make it easy for u, there is a possibility to import the flow:

  • Download the file Node-red-flow. Open it, select all the text and make copy (Ctrl C).
  • Click Option in Node-red (Three stripes at the top right corner) and select import and then Clipboard.
  • Paste (Ctrl V) the text into the Clipboard and click button Import.

Enter Your Blynk Auth Token

  • Copy the token you received from the mail. See Step 6
  • Double click on one of the green Blynk node in the flow.
  • Enter your Token in the Topic field (See picture)
  • If you are ready then push Red Deploy button on the upper site of the node-red web page.
  • If everything is ok then a little circle changed to green to all Blynk nodes.

Enter USB serial port.

  • Double click on one of the braun Serial node
  • Enter your serial port into the serial port field (Mostly /dev/ttyUSB0). Take over all parameters as shown in the picture.
  • If you are ready then push Red Deploy button on the upper site of the node-red web page.
  • If everything is ok then a little circle changed to green to all Serial nodes.

Attachments

Description:

The Serial note below write command to the Lora-Arduino
The serial note above read the messages from the Lora-Arduino.

The msg.payload note write a message to the debug window (Right window -debug tab)

Function notes take a substring (Values) from the message coming from Lora-arduino Because Blynk server accept only values.

Start a request

Double click on the blue injection node (Request Humidity and Temperature) In this note you have several possibilities to send a request:

  • Payload is the command what is send by Lora e.a. 'dht-read'. Arduino received this command and checked if this command is known. If yes then the programed action is carryout.
  • Topic is the name of the topic (Option)
  • Repeat.
    • None. If you push the blue button left from the note, the command is send one message to lora-arduino.
    • Interval. You have the possibility to inject repeatedly by time interval a message. The blue button is then disabled.

The green Blynk node below is waiting for a push button on your mobile phone. When it received a message, it send this message to the function node. This note convert the value 1 or 0 to sw1-on or sw1-off, and send it to Arduino to pin 13 the build in led

You are free to add new injection nodes with your own commands. But the same commands must be added also in the arduino software with the corresponding actions.

Have Fun and let me know if you like it.


YOU MIGHT ALSO LIKE