Things used in this project

Hardware components:
Linkitone 03
MediaTek Labs LinkIt ONE
I use WiFi module of LinkIt ONE in this project
×1
SUNNY WEBBOX
×1
MTA8000(EMS Panel)
×1
Software apps and online services:
Ide web
Arduino IDE
QT
Create connected devices, UIs and applications that run anywhere on any device, on any operating system at any time.

Schematics

Schematic of data network
This project includes the following parameters:
1- LinkIt ONE (WiFi module)
2- Energy management module
3- Sunny WebBox (read data parameters of Inverters and micro grid status
P4

Code

QT source codeC/C++
QT source code for control and monitoring application
No preview (download only).
Web Server for Monitoring micro-grid objects Arduino
/*
  WiFi Web Server

 A simple web server that a repeated counter

 Change the macro WIFI_AP, WIFI_PASSWORD and WIFI_AUTH accordingly.

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe
 modified 20 Aug 2014
 by MediaTek Inc.
 */
#include <LTask.h>
#include <LWiFi.h>
#include <LWiFiServer.h>
#include <LWiFiClient.h>
#include <LBattery.h>

//#define WIFI_AP "Pronet1"
//#define WIFI_PASSWORD "!23$56&89"
#define WIFI_AP "MTACO"
#define WIFI_PASSWORD "1234567890"
#define WIFI_AUTH LWIFI_WPA  // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP according to your WiFi AP configuration

String inputString = "";         // a string to hold incoming data
char* myObject[10]; //Array list of microgrid objects
int objectsNo=0; //No. of objects
boolean stringComplete = false;  // whether the string is complete

LWiFiServer server(80);

void setup()
{
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
  LWiFi.begin();
  // initialize serial:
  Serial1.begin(9600);
  Serial.begin(115200);
  delay(2000);
  // keep retrying until connected to AP
  Serial.println("Connecting to AP");
  while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD)))
  {
    delay(1000);
  }

  printWifiStatus();

  Serial.println("Start Server");
  server.begin();
  Serial.println("Server Started");
}

int loopCount = 0;

void loop()
{
  // put your main code here, to run repeatedly:
  delay(500);
  loopCount++;
  LWiFiClient client = server.available();
  if(Serial1Packet())
  {
    ListObjectTransfer();
    }
  if (client)
  {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected())
    {
      if (client.available())
      {
        // we basically ignores client request, but wait for HTTP request end
        int c = client.read();
        Serial.print((char)c);

        if (c == '\n' && currentLineIsBlank)
        {
          Serial.println("send response");
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          client.println("<PPanel>");
          client.println(myObject[0]);// Online power of solar panel
          client.println("<PPanel/>");
          client.println("<TotalG>");
          client.println(myObject[1]);// Online Total power generation from solar panel
          client.println("<TotalG/>");
          client.println("<Motion>");
          client.println(myObject[2]);// Status of motion sensor
          client.println("<Motion/>");
          client.println("<Battery>");
          client.print(LBattery.level());
          client.println("<Battery/>");
          client.println("<Signal>");
          client.print(LWiFi.RSSI());//-10dBm = Max & -100dBm = Min
          client.println("<Signal/>");
          client.println("<br/>");
          client.println("</html>");
          client.println();
          break;
        }
        if (c == '\n')
        {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(500);

    // close the connection:
    Serial.println("close connection");
    client.stop();
    Serial.println("client disconnected");
  }
}

void serial1Event() {
  while (Serial1.available()) {
    // get the new byte:
    char inChar = (char)Serial1.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    // ':' char is equal to end packet of transfer from EMS module
    if (inputString.endsWith("</P>")) {
      stringComplete = true;
    }
  }
}

void ListObjectTransfer()
{
  //You can find object of transfer fron serial port and saved them at myObject string array
  }

bool Serial1Packet()
{
  serial1Event(); //call the function
  // print the string when a newline arrives:
  if (stringComplete) {
    //Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
    return 1;
  }
  else
  return 0;
}

void printWifiStatus()
{
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(LWiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = LWiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  Serial.print("subnet mask: ");
  Serial.println(LWiFi.subnetMask());

  Serial.print("gateway IP: ");
  Serial.println(LWiFi.gatewayIP());

  // print the received signal strength:
  long rssi = LWiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}
WiFiWebServer2.rarArduino
No preview (download only).

Credits

Hashem
H.Ghorbanpanah

Research and Development Supervisor at Mashhad Electric Energy Distribution Co. M.SC.Computer Software Engineering

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Driving Parameters Analysis System
Advanced
  • 1,538
  • 21

Full instructions

Smart system for analyzing the driving skills of a person using IOT and Cloud Computing powered by Mediatek LinkIt One

Employee safety controller
Advanced
  • 710
  • 10

Work in progress

Safety controller care about employee health

Employee safety controller

Team KNITU-Embedded Lab

Air Quality System using LinkIt ONE and MCS
Advanced
  • 2,360
  • 24

Monitor the Temperature, Humidity, Pressure, Air Quality, Dust particle concentration online & even detect Fire using LinkIt ONE & Sensors.

Energy Planner
Advanced
  • 280
  • 6

Full instructions

Solar panels produce when there is sun, and during daytime I can earn money with my generated energy. When should I use the washing machine?

Pill Machine
Advanced
  • 437
  • 8

Full instructions

Smart way to take medicine without worry schedule, miss medicines or wrong pills

Pill Machine

Team HA Geek

Smart Furniture Using Linkit Mediatek 7688 Duo
Advanced
  • 573
  • 9

Protip

We are making smart furniture and our first prototype is for smart computer table.

Add projectSign up / Login