How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Arduino, Seeeduino Serials and mutants. Share your problems and experence on arduino compatible board such as seeeduino/stalker, etc.

Moderators: lily.li, violet, salmanfarisvp

Post Reply
keantattong
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Thu Oct 11, 2018 2:46 pm

How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Post by keantattong » Mon Feb 25, 2019 12:07 pm

Currently, I'm able to send the gps data to loriot server via the following guidelines:
https://blog.squix.org/2017/11/using-se ... ot-io.html
(Using Seeeduino LoRaWAN with GPS and Loriot.io - Squix - TechBlog - blog.squix.org)

The arduino script below is modified to method ABP from the script inside above post where originally is OTAA method.

#include <TinyGPS++.h>
#include <LoRaWan.h>
#include "DHT.h"


TinyGPSPlus gps;
#define DHTPIN A0 // what pin we're connected to

#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);
char buffer[256];


void setup(void)
{
SerialUSB.begin(115200);
Serial.begin(9600);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer);

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
SerialUSB.println("That was the id");
// void setId(char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId("008Fxxxx", "4786C58Bxxxxxxxx", "526973xxxxxxxxxx");
// setKey(char *NwkSKey, char *AppSKey, char *AppKey);
lora.setKey("2B7E151628AED2A6ABF7158809CF4F3C", "2B7E151628AED2A6ABF7158809CF4F3C", "8413360695ABxxxxxxxxxxxxxxxxxxxx ");

lora.setDeciveMode(LWABP);
lora.setDataRate(DR0, US915HYBRID);

lora.setChannel(0, 923.2);
lora.setChannel(1, 923.4);
lora.setChannel(2, 922.2);
lora.setChannel(3, 922.4);
lora.setChannel(4, 922.6);
lora.setChannel(5, 922.8);
lora.setChannel(6, 923.0);
lora.setChannel(7, 922.1);

lora.setReceiceWindowFirst(0);
lora.setReceiceWindowSecond(923.3, DR2);
lora.setAdaptiveDataRate(false);

lora.setPower(20);

//while(!lora.setOTAAJoin(JOIN, 20000));
//SerialUSB.println("After OTAA join");

// Start DHT sensor
dht.begin();
}

void loop(void)
{
while (Serial.available() > 0) {
gps.encode(Serial.read());
}
if (gps.altitude.isUpdated()) {
SerialUSB.println(gps.altitude.meters());
SerialUSB.print("LAT="); SerialUSB.println(gps.location.lat(), 6);
SerialUSB.print("LONG="); SerialUSB.println(gps.location.lng(), 6);
SerialUSB.print("ALT="); SerialUSB.println(gps.altitude.meters());
long latEncoded = (gps.location.lat() * 8388606) / 90;
long lonEncoded = (gps.location.lng() * 8388606) / 180;
SerialUSB.print("Lat encoded: ");
SerialUSB.println(latEncoded);
SerialUSB.print("Lon encoded: ");
SerialUSB.println(lonEncoded);
float h = dht.readHumidity();
float t = dht.readTemperature();
SerialUSB.print("Humidity is: ");
SerialUSB.print(h);
SerialUSB.print(", Temperature: ");
SerialUSB.print(t);
bool result = false;
byte data[10] = {0};
data[0] = h;
data[1] = t + 100;
data[2] = (byte) (latEncoded >> 16);
data[3] = (byte) (latEncoded >> 8);
data[4] = (byte) latEncoded;

data[5] = (byte) (lonEncoded >> 16);
data[6] = (byte) (lonEncoded >> 8);
data[7] = (byte) lonEncoded;

result = lora.transferPacket(data, 10);
//result = lora.transferPacket(data, 10, 10);

if(result)
{
short length;
short rssi;

memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);

if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer, HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
delay(1000 * 60 * 5);
}
}

}

My seeeduino lorawan w/gps board is connected to USB cable and 3.7 volt 350mAh lipo battery via jst connector. After I uploaded the arduino script attached, the data is shown on the loriot server every 5 minutes. Unfortunately, when I removed the USB cable, the board is unable to send the gps data with tx, red light (in Diagram_01) on (when the first 5 min interval after remove the USB cable).

Can I know how to send data continuously from seeeduino lorawan w/gps board to loriot server as I need to install the seeeduino board in small boat and tracking their gps coordinates? So, I cannot have the USB cable connected while sending gps coordintes.

User avatar
bestlux
Kindergarten
Kindergarten
Posts: 85
Joined: Wed Jan 30, 2019 11:51 am

Re: How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Post by bestlux » Tue Feb 26, 2019 1:55 pm

Hello,
Could you please post how you connect the circuit? I suggest you burn a blink program first to verify if the circuit can work then try programs that are more complicated.
Good luck!

User avatar
bestlux
Kindergarten
Kindergarten
Posts: 85
Joined: Wed Jan 30, 2019 11:51 am

Re: How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Post by bestlux » Mon Mar 04, 2019 4:10 pm

Hello,
I'm sry for my omission that I have not considered you did not connect the USB port.
When there are SerialUsb code but the USB port is not connected, the program might be pended.
So you need to delete all of them.
Hope the information can help you.

keantattong
Pre-kindergarten
Pre-kindergarten
Posts: 9
Joined: Thu Oct 11, 2018 2:46 pm

Re: How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Post by keantattong » Tue Apr 09, 2019 12:36 pm

Hi, I already comment out all Serial.USB remain Serial,begin(9600) and Serial.available. After I unplugged the transmission is stopped and the red LED light to light up. But If I comment the Serial lines also, the transmission of data cannot start. So, may I know is there any alternative to replace the Serial lines that work under the condition of the USB cable is unpugged?

The following are the code:

#include <TinyGPS++.h>
#include <LoRaWan.h>
#include "DHT.h"


TinyGPSPlus gps;
#define DHTPIN A0 // what pin we're connected to

#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);
char buffer[256];


void setup(void)
{
//SerialUSB.begin(115200);
Serial.begin(9600);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
//SerialUSB.print(buffer);

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
//SerialUSB.print(buffer);
//SerialUSB.println("That was the id");
// void setId(char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId(NULL, "4786C58B003C002A", "526973696E674846");
// setKey(char *NwkSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, "2B7E151628AED2A6ABF7158809CF4F3C");

lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR2, AS923);

lora.setChannel(0, 923.0);
lora.setChannel(1, 923.2);
lora.setChannel(2, 923.4);
lora.setChannel(3, 923.6);
lora.setChannel(4, 923.8);
lora.setChannel(5, 924.0);
lora.setChannel(6, 924.2);
lora.setChannel(7, 924.4);

lora.setReceiceWindowFirst(2, 923.2);
lora.setReceiceWindowSecond(923.2, DR2);
lora.setAdaptiveDataRate(false);

lora.setPower(10);

while(!lora.setOTAAJoin(JOIN, 20000));
//SerialUSB.println("After OTAA join");

// Start DHT sensor
dht.begin();
}

void loop(void)
{
while (Serial.available() > 0) {
gps.encode(Serial.read());
}
if (gps.altitude.isUpdated()) {
//SerialUSB.println(gps.altitude.meters());
//SerialUSB.print("LAT="); SerialUSB.println(gps.location.lat(), 6);
//SerialUSB.print("LONG="); SerialUSB.println(gps.location.lng(), 6);
//SerialUSB.print("ALT="); SerialUSB.println(gps.altitude.meters());
long latEncoded = (gps.location.lat() * 8388606) / 90;
long lonEncoded = (gps.location.lng() * 8388606) / 180;
//SerialUSB.print("Lat encoded: ");
//SerialUSB.println(latEncoded);
//SerialUSB.print("Lon encoded: ");
//SerialUSB.println(lonEncoded);
float h = dht.readHumidity();
float t = dht.readTemperature();
//SerialUSB.print("Humidity is: ");
//SerialUSB.print(h);
//SerialUSB.print(", Temperature: ");
//SerialUSB.print(t);
bool result = false;
//SerialUSB.println(result);
byte data[10] = {0};
data[0] = h;
data[1] = t + 100;
data[2] = (byte) (latEncoded >> 16);
data[3] = (byte) (latEncoded >> 8);
data[4] = (byte) latEncoded;
data[5] = (byte) (lonEncoded >> 16);
data[6] = (byte) (lonEncoded >> 8);
data[7] = (byte) lonEncoded;

result = lora.transferPacket(data, 10);
//result = lora.transferPacket(data, 10, 10);
//SerialUSB.println(result);
if(true)
{
short length;
short rssi;

memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);

if(length)
{
//SerialUSB.print("Length is: ");
//SerialUSB.println(length);
//SerialUSB.print("RSSI is: ");
//SerialUSB.println(rssi);
//SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
//SerialUSB.print("0x");
//SerialUSB.print(buffer, HEX);
//SerialUSB.print(" ");
}
//SerialUSB.println();
}
delay(1000 * 60 * (0.5));
}
}

}

Thanks

User avatar
bestlux
Kindergarten
Kindergarten
Posts: 85
Joined: Wed Jan 30, 2019 11:51 am

Re: How to send gps data without USB cable connected from seeeduino lorawan to Loriot server

Post by bestlux » Tue Apr 09, 2019 2:09 pm

Hello,
Pls tell me how did you supply the power(a pic of wire connection is primary) and what kind of battery did you use.
Thx!

Post Reply