Close

Firmware Update #3

A project log for 2020 HDP Dream Team: Conservation X Labs

The 2020 HDP Dream Teams are participating in a two month engineering sprint to address their nonprofit partner. Follow their journey here.

Oluwatobi OyinlolaOluwatobi Oyinlola 08/25/2020 at 12:550 Comments

Now that the two way testing was completed between the Bouy and Onboard gateway,

We now try to test the Wifi logic on the Esp controller, there are some libraries that needed to be added to the onboard gateway in other to achieve it.

// include libraries
#include <WiFi.h>
#include "ESPAsyncWebServer.h"
#include "SPIFFS.h"

And then the initial include functions SPI.h and LoRa.h

Going forward, network credentials will need to be set based on the user ssid and Password!. The device will connect to Wifi and confirm the ssid and password and print out the assigned IP address

// Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  } 

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

Currently we have not designed the complete web server to be so fancy, we only want to set the GPIO high or Low and send the information to Bouy and if the message was sent, it prints it on serial.

// Route to set GPIO to HIGH
  server.on("/on", HTTP_GET, [](AsyncWebServerRequest *request){
    String message = "ON_REQUEST";
    // send a message to LoRa Node
    LoRa_sendMessagetoNode(message);
    Serial.println("Send Message to Node!");
// Route to set GPIO to LOW
  server.on("/off", HTTP_GET, [](AsyncWebServerRequest *request){
    String message = "OFF_REQUEST";
    // send a message to LoRa Node
    LoRa_sendMessagetoNode(message);
    Serial.println("Send Message to Node!");

Discussions