"Bastwan Board is a low-power-based LoRa management tools, in addition to compatible Arduino IDE outside its feathers presentation format makes it an excellent choice for project development.
Bastwan board:
RAK4260 processor
32 Power
micro USB interface for easy programming
3.3V logic operations
256K FLASH, 32K RAM
How RS485 work?
RS485 communication standard is widely used in the industry, it can be used like Bastwan processor to read or write to other devices.
Wing RS485 Bastwan shielding plates help by communicating with the management apparatus Modbus protocol, which is (Re, De, Di, Ro) operated by the communication pin. Modbus communication protocol with the general use
Pin Description:
RO: a receiver (RX)
DI: a transmitter (TX)
RE: digital pin (pin 10 corresponding to Bastwan)
DE: digital pin (pin 11 corresponding to Bastwan)
What is Modbus?
Modbus communication protocol is based on a client / server architecture, designed to work with a programmable logic controller (PLC) with the use.
Modbus network and allows the control device transmits the result to the computer.
This protocol may be used in conjunction with the RS485 or RS232.
C4E Modbus sensors:
C4E sensor is a conductivity sensor and a temperature
Using the Modbus protocol to provide readings
Capable of operating in a voltage range of 5v-12v
There are four electrodes (2 and 2 platinum pattern) to sense the level of conductivity
Capable of sensing range of -10 ° - 60 ° and a pressure of 5 bar
For this project, only the pin 1 (V), 3 (GND), 4 (B) and 5 (A).
connect:
Wing mounted on the plate Bastwan, then identifies pin configuration, and connected to the sensor;
Only four connections:
5-12V: a sensor supply voltage (in this case, the proposed connection Bastwan card VBUS)
GND: ground pin is circuit (Bastwan also pins)
B: It is connected to the same name Wing RS485 Modbus (B) of the output
A: It is connected to the same name Wing RS485 Modbus (A) of the output
De Re must know and enable them to digital pins, and the rest of the board is to install and activate the device which pins are to be declared in the program to remember (in this case, they are the D10 and D11).
Transmission code reading sensor C4E
In this project, the use of the library:
#include
#include
#include
How to install the library it?
Will open the Arduino IDE
Click on the toolbar and select "Tools"
On the Tools menu, find the "Library Manager" section
When you open the Library Manager, a window will appear with a search engine.
In this search engine, enter the name of the library "AqualabSensor"
Installation Library
(Aqualab Library)
1, to operate the device type name: aqualaboModbusSensorsClass aqualaboModbusSensors
2, at 9600 baud serial port 1 to start reading the pin plate and wait for it to open:
void setup () {
Serial.begin (9600);
Serial1.begin (9600);
while (Serial!);
Serial.println ( "" Modbus Sensor C4E "");
3, connected to the statement from the device or device Wing (ID sensor can find the default pin and sensor)
aqualaboModbusSensors.begin (30, 11, 10, Serial1);
Sensor parameters and LoRa
Bastwan acquired by the sensor is read with a card Modbus expansion boards (Lora) data and sends it to another Bastwan plate.
By sending packets Lora
(C4E Sensor serial read data)
The transmitter is sending print data, conductivity and temperature
Receiving code data:
#include
#include
The activation speed of 9600 baud, and the parameter declaration LoRa card as a receiver:
Looking for a packet:
Read and print the received packet data in the packet:
Receiver is to acquire print data by LoRa temperature, conductivity and spring constant:
Transmit data to the IOT
Things Things is designed to provide an open communication network.
In this network, we can create applications, our equipment in order to be able to register them, the platform is capable of receiving and transmitting analog data communications LoRa work from the site management.
As we all know, data can be read by LoRa technology from one plate to another plate, remember that our module also has LaRaWan, can transmit data to the Internet of Things platform with the help of Cayenne LPP library.
After registration, we will be able to visit our console, we can find the application and in which the gateway.
Add an application to register our sensors.
When the application starts, it will send us a section, we will add an identifier to the portion of our device (lowercase letters with no spaces) and a description.
When we determine our application, it will display the following menu to us, we will find a general description of where, no equipment.
Will enter the "Devices" section, where we will register our Bastwan license plates.
We will make a license plate identifier and automatically generate a "Device EUI".
After registering our equipment in our application, the following panel, in which we can see our application key, key equipment and configuration.
There is also a toolbar, we can select to view the description and status of our equipment, we are observing the data received and our communication settings.
Will find general settings and local device settings, under normal circumstances, we will find labels and their method of activation of our equipment, we have to change the ABP therein.
When you select ABP method, a display panel, we have to generate a key that will be used later in them. In this section, save the data is sufficient.
After changing the activation method, we will get the key to connect the device to the network The Things needed.
Transmitting data to a networked program was
1, requires the following libraries:
#include
#include
#include
#include
CayenneLPP lpp (51);
2, how to install or cayenne LPP Beelan library?
For the library, we have to enter our platform on Github: We will choose where the master branch.
After selecting the main branch, we will go to the "Code" icon and select the option to download the ZIP file.
After downloading the file, we will open it and extract the files Arduino library folder.
3, network, or from things before we get the key distribution credentials:
const char * devAddr = "" 26013557 "";
const char * nwkSKey = "" 040A022068FB1C137888440CE072ACF0 "";
const char * appSKey = "" 3D3E011CBB4CEF72885D12B91C85D680 "";
4, will be assigned a time interval and a counter between each transmitted packet, to help understand the number of transmitted packets:
const unsigned long interval = 5000;
unsigned long previousMillis = 0;
unsigned int counter = 0;
char myStr [50];
char outStr [255];
byte recvStatus = 0;
5, the pin is asserted that we will use in Lora module and activate the sensor
const sRFM_pins RFM_pins = {
.CS = SS,
.RST = RFM_RST,
.DIO0 = RFM_DIO0,
.DIO1 = RFM_DIO1,
.DIO2 = RFM_DIO2,
.DIO5 = RFM_DIO5,
}
aqualaboModbusSensorsClass aqualaboModbusSensors;
6, the 9600 baud serial reading start sensor to monitor the
void setup () {
Serial.begin (9600);
while (Serial!);
7, the module start Lora
Serial.println ( "" Modbus Sensor C4E "");
if (! lora.init ()) {
Serial.println ( "" RFM95 not detected "");
ResSure (1, SensorValue);
INT TEMP = Aqualabomodbussens.Sensorc4e.Temperature;
Serial.Print (f ("", tempetaure = "));
Serial.Print (TEMP, 2);
LPP.AddTemperature (2, TEMP);
}
Contact Ubidots
To connect our devices to visual applications, such as Ubidots, we need to enter the "Integration" section in the taskbar.
Add device integration:
When you start integration, an application list will be displayed, we must find applications in Ubidots.
When we choose our application, it will ask us to provide tokens, access key, and identifiers for identifying devices in Ubidots.
Our identifier must be an identifier located in Ubidots or applications.
Access key is default
Be
This token will be found in the Ubidots profile of the API certificate section
When you open this section, what we have to do is copy our token number and paste it into the Things Network.
After the integration is complete, we will be able to see the Ubidots logo in the device description.
After that, we can see the name of our components in the device part of Ubidots.
Now we will go to the data section, we will select the dashboard in this section, we will be able to customize the sample and process data obtained from our sensor.
Add a widget to see our data, it will show us a lot of options to visualize our device's behavior.
After selecting the widget, we will have to add variables, in which case the temperature and conductivity will be displayed according to the channel we choose.
After selecting a variable, we must add a name for the widget, in which case it has been named according to the variable.
After saving Widget, we will be able to observe changes in sensors in a fully personalized manner.
Simply compare our serial monitor and thong network, you can verify that the data is the same. "delay (5000);
Return;
}
pinMode (RFM_TCX_ON, OUTPUT);
pinMode (RFM_SWITCH, OUTPUT);
pinMode (LED_BUILTIN, OUTPUT);
8, the device type that will be used, in this case its class:
lora.setDeviceClass (CLASS_A);
lora.setDataRate (SF8BW125);
lora.setChannel (MULTI);
9, which will take us previously defined key ABP
lora.setNwkSKey (nwkSKey);
lora.setAppSKey (appSKey);
lora.setDevAddr (devAddr);
10, the Modbus communication initiated by Serial1
Serial1.begin (9600);
11, the pin will find the Modbus devices in which
aqualaboModbusSensors.begin (30, 11, 10, Serial1);
12, the sensor parameters
Serial.println ( "" Init sensor "");
aqualaboModbusSensors.initSensor ();
Serial.println ( "" Ready ... "");
}
13, starting from the sensor readings
void loop () {
aqualaboModbusSensors.read ();
14, will be assigned to variable degrees Celsius
Serial.print ( "" Temperature: "");
Serial.println (aqualaboModbusSensors.sensorC4E.temperature, 2);
15, the variable designated as the conductivity μS / cm
Serial.print ( "" Conductivity: "");
Serial.println (aqualaboModbusSensors.sensorC4E.conductivity, 2);
16, sends data to the IOT
if (millis () - previousMillis> interval) {
previousMillis = millis ();
Serial.print ( "" Sending: "");
printVariables ();
lora.sendUplink ((char *) lpp.getBuffer (), lpp.getSize (), 0, 1);
}
recvStatus = lora.readData (outStr);
if (recvStatus) {
Serial.println ( "" Received: "");
Serial.println (outStr);
}
lora.update ();
}
17, variable print things in the network
void printVariables ()
{
lpp.reset ();
int sensorValue = aqualaboModbusSensors.sensorC4E.conductivity;
Serial.print (F ( "" conductivity = ""));
Serial.print (sensorValue, 2);
lpp.addBarometricP
Our other product: