RFID-Part
- send RFID of Tag
- send status of checksum
Voltage-Control
- send if fence is broken or if sth. lies on it
- send if animal-gate is open or closed
LoRA
- send and receive data
IEEE 802.15.4
- send upd pakages between client and server
Server
- receive data from LoRa-Module via UART
- send data to CoAP-Server
To flash tap
$ BOARD=nucleo-f411 make all flash term- Selfmade RFID-Board
- Nucleo-F441
- mbed SX1276MB1xAS LoRa Shield
Necessary lib:
#include"lora.h"The nodeID and the frameID enums are filled with
typedefenumlora_nodeID
{
NODEID_NODEone=0x01,
NODEID_NODEtwo=0x02
} lora_nodeID;
typedefenumlora_frameID
{
FRAMEID_HEARTBEAT=0x01,
FRAMEID_RFID_TAGID=0x02,
FRAMEID_FENCE=0x10
} lora_frameID;feel free to extend them
Make a Frame
lora_frameframe;The Frame has the form
typedefstructlora_frame {
uint8_tnodeID;
uint8_tframeID;
chardata[6];
} lora_frame ;So let's fill the struct with a NodeID
frame.nodeID=0x03;and with a FrameID
frame.frameID=FRAMEID_RFID_TAGID;Fill the struct with some payload:
charpayload[6] = {0}; .
.
.
frame.data[0] =payload[0];
frame.data[1] =payload[1];
frame.data[2] =payload[2];
frame.data[3] =payload[3];
frame.data[4] =payload[4]; frame.data[5] =payload[5]; Now we send our frame via LoRa:
lora_send_frame(frame);To begin convince that u include the librarys for the mlx90109
#include"mlx90109.h"#include"mlx90109_params.h"#include"checksum/ucrc16.h"Define Clock and Data Pin fit to the used hardware
#defineMLX90109_PARAM_CLOCK#defineMLX90109_PARAM_DATACreate device descriptor
mlx90109_tmlx90109_dev;The device descripter has the form
typedefstruct {
mlx90109_params_tp; /**< device configuation parameter */uint8_tcounter; /**< counter for data bits*/uint8_tcounter_header; /**< counter for Header bits "10000000000"*/uint8_tdata[128]; /**< raw data*/
} mlx90109_t;Then we create a Tag Object
tagdatanewTag; Then make an interrupt for detecting new tags in the near field
voidinterrupt_hand(void*args)
{
if (args){}
int16_ttemp=mlx90109_read(&mlx90109_dev);
if (temp==MLX90109_DATA_OK)
{
printf("data ok\n");
}
return;
}Use the format-function to make raw-data(just a bitstring) to tagData (formated in TagID and countrycode). In this function also a checksum test is running in the background.
mlx90109_format(&mlx90109_dev, &neuerTag);Necessary lib:
#include"fence.h"Measure the voltage at fence
doublemeasure (intnumberOfMeasurement, doublecalculateParameter)detecting the Gate state:
recognise_gate_funk (intport, intpin);| Value | Fence |
|---|---|
| 0 | open |
| 1 | closed |
| 2 | error at initialisation of the port |
calculate transfer value
calculate_transfer_value(doublevoltageFence, intrecogniseGate)| Value | Fence | Gate |
|---|---|---|
| 1 | broke | closed |
| 2 | broke | open |
| 3 | intact | closed |
| 4 | intact | open |
- bidirectorial communication (LoRa) - Testing under real conditions
- Error-handling