Vimarsh
Created June 3, 2019 © CC BY-NC-SA

Monitor Oceans

The project measures the speed and acceleration of tsunamis and also keeps an eye on other movements in the ocean.

IntermediateFull instructions provided4 hours34
Monitor Oceans

Things used in this project

Hardware components

Wio LTE EU Version - 4G, Cat.1, GNSS, Espruino Compatible
Seeed Studio Wio LTE EU Version - 4G, Cat.1, GNSS, Espruino Compatible
The module for Communication to a server if a cellular network is available in that region which is not true. The best option will only be satellite communication.
×1
SORACOM Air Global IoT SIM
SORACOM Air Global IoT SIM
For Cellular Communication Available globally. Recommended for use.
×1

Software apps and online services

Arduino IDE
Arduino IDE
for coding
Firebase
Google Firebase
Server

Story

Read more

Schematics

Just need The Seeed Wio

Connect the battery and all antennas.
Good to go

Code

Soracom_Sub_code.ino

Arduino
Change project ID keep it public.
Good to go.
#include <WioLTEforArduino.h>
#include <WioLTEClient.h>
#include <PubSubClient.h>		// https://github.com/SeeedJP/pubsubclient
#include <stdio.h>
#include "gnss.h"

#define APN               "soracom.io"
#define USERNAME          "sora"
#define PASSWORD          "sora"

#define MQTT_SERVER_HOST  "mqtt.firebase.com/<project_id>/"
#define MQTT_SERVER_PORT  (1883)

#define ID                "WioLTE"
#define OUT_LAT       "latitude"
#define OUT_LONG         "longitude"

#define INTERVAL          (60000)

WioLTE Wio;
GNSS gnss = GNSS();
WioLTEClient WioClient(&Wio);
PubSubClient MqttClient;

void callback(char* topic, byte* payload, unsigned int length) {
  SerialUSB.print("Subscribe:");
  for (int i = 0; i < length; i++) SerialUSB.print((char)payload[i]);
  SerialUSB.println("");
}

void setup() {
  delay(200);

  SerialUSB.println("");
  SerialUSB.println("--- START ---------------------------------------------------");

  SerialUSB.println("### I/O Initialize.");
  Wio.Init();

  SerialUSB.println("### Power supply ON.");
  Wio.PowerSupplyLTE(true);
  delay(500);

  SerialUSB.println("### Turn on or reset.");
  if (!Wio.TurnOnOrReset()) {
    SerialUSB.println("### ERROR! ###");
    return;
  }

  SerialUSB.println("### Connecting to \""APN"\".");
  if (!Wio.Activate(APN, USERNAME, PASSWORD)) {
    SerialUSB.println("### ERROR! ###");
    return;
  }
  gnss.Power_On();
  while (false == gnss.Check_If_Power_On()) {
    SerialUSB.println("Waitting for module to alvie...");
    delay(1000);
  }
  SerialUSB.println("\n\rPower On!");

  if (!(gnss.open_GNSS())) {
    SerialUSB.println("\n\rGNSS init failed!");
    return;
  }

  SerialUSB.println("Open GNSS OK.");
  delay(2000);

  SerialUSB.println("### Connecting to MQTT server \""MQTT_SERVER_HOST"\"");
  MqttClient.setServer(MQTT_SERVER_HOST, MQTT_SERVER_PORT);
  MqttClient.setCallback(callback);
  MqttClient.setClient(WioClient);
  if (!MqttClient.connect(ID)) {
    SerialUSB.println("### ERROR! ###");
    return;
  }
  MqttClient.subscribe(IN_TOPIC);

  SerialUSB.println("### Setup completed.");
}

void loop() {
  if (gnss.getCoordinate()) {
    SerialUSB.println();
    SerialUSB.print("GNSS: \r\n");

    // Output double type
    SerialUSB.print("Data type in double: ");
    SerialUSB.print(gnss.longitude, 6);
    SerialUSB.print(",");
    SerialUSB.println(gnss.latitude, 6);

    SerialUSB.print("Publish:");
    //    SerialUSB.print(data);
    SerialUSB.println("");
    MqttClient.publish(OUT_LAT, gnss.latitude);
    MqttClient.publish(OUT_LONG, gnss.longitude);

err:
    unsigned long next = millis();
    while (millis() < next + INTERVAL)
    {
      MqttClient.loop();
    }
  } else {
    SerialUSB.print("...");
  }

}

Credits

Vimarsh

Vimarsh

5 projects • 38 followers
Currently, a student studying Physics @ BITS Pilani. A maker and a learner :D
Thanks to vimarsh.

Comments