Quantcast
Channel: AirQ Networks Development Blog » arduino relay
Viewing all articles
Browse latest Browse all 9

How to use AirQ ShielD to build custom wireless solutions

$
0
0

A lot of you asked us if AirQ ShielD could be used to build customs hardware solutions without using other AirQ Networks devices. And the answer is definitively yes. AirQ ShielD is nothing more than a transceiver and it is designed to accept commands that send bytes to another AirQ ShielD. To develop a wireless solution using AirQ ShielD you need:

  • At least two AirQ ShielDs (but you can use how many you need).
  • Two Arduino Uno boards.
  • The sNET library for Arduino

AirQ ShielD allows sending data messages to another AirQ ShielD. The maximum number of bytes that can be sent is 10. To a send a message to another shield the sNET::sendToDevice() method can be used. Let’s do an example. Suppose that you received two AirQ ShielDs: one with sNET address equal to 191.0.0.11 and the other one with the address 191.0.0.12. And suppose that you want to send the “HELLO” string from 191.0.0.11 board to 191.0.0.12. The following Arduino code is all you need.

#include <sNET.h>
#include <SoftwareSerial.h>

sNET snet(1);

void setup() {
  snet.begin();
}

void loop() {
  char *data = "HELLO";
  snet.processMessages();

  snet.sendToDevice(191,0,0,12, 0x1, (uint8_t*)data, 5);
  while(1);  
}

The code is self-explanatory: the first 4 parameters are the address of the remote shield that will receive the message; the fifth parameter (0×1) says sNET library to send a data message; the remaining part is the data we want to send and its size. If you want to send a message to all AirQ ShielD on the same sNET network, you can use the sNET::sendBroadcast() method:

#include <sNET.h>
#include <SoftwareSerial.h>

sNET snet(1);

void setup() {
  snet.begin();
}

void loop() {
  char *data = "HELLO";
  snet.processMessages();

  snet.sendBroadcast((uint8_t*)data, 5);
  while(1);  
}

 


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images