Skip to content

Repository files navigation

SmartFarm Project

Overiew

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

Used Boards

  • Selfmade RFID-Board
  • Nucleo-F441
  • mbed SX1276MB1xAS LoRa Shield

Send packages via LoRa

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);

RFID

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_DATA

Create 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);

Fence

Necessary lib:

#include"fence.h"

Measure the voltage at fence

doublemeasure (intnumberOfMeasurement, doublecalculateParameter)

detecting the Gate state:

recognise_gate_funk (intport, intpin);
ValueFence
0open
1closed
2error at initialisation of the port

calculate transfer value

calculate_transfer_value(doublevoltageFence, intrecogniseGate)
ValueFenceGate
1brokeclosed
2brokeopen
3intactclosed
4intactopen

To-Do:

- bidirectorial communication (LoRa) - Testing under real conditions
- Error-handling 

About

SS 2017 - RIOT im Internet of Things - Bachelor Project of Computer Science and Electrical Engineering

Topics

Resources

Stars

13 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages