Go Down

Topic: Facing a complete requirement change with a technology i don't know completely (Read 211 times) previous topic - next topic

Mmedina_student

First i'm going to explain the objective of my project then i'm going to explain what my first approach to the problem was and last i'm going to explain what the changes are and the information i need.

The main purpose of my project is to detect whether a parking spot is occupied or empty.

My first approach was to use an arduino uno with an ethernet shield and a sensor (the kind of sensor is not important for the moment). the problem with that approach is that i would need to cable the shield to connect it to internet. So my teacher told me to simplify the installation of the device in the place.

What he requested me to engineer is a device that has to be independent from any type of hardware or installation nearby, so what he needs me to do is a device that can connect to internet via 3g or 4g or any type of widely available connection in the city.

in my city there's not much places that sell arduino hardware the only shield with GSM technology available to buy is this shield.

Mini SIM800L GPRS/GSM

http://www.roboticatemuco.cl/index.php?id_product=209&controller=product&search_query=gsm&results=2

What i need to do is upload data from the sensor to a database, currently i have a local database but i don't know if i will be able to continue to develop with a local environment since i wont be able to make a local area network.

- Is that shield able to make an http request to a server?

mauried

How are you detecting whether the parking spot is occupied or empty?

INTP

Nothing changes if you actually did some work and had it working with wifi. A GSM mobile hotspot would work just the same. As I recall, you continually failed to describe your project in adequate detail in other threads you have made, so the locations, positions, distances, all relevant details on how you would secure the device are unknown to anyone trying to get an idea of what your project actually needs to do.
Maybe if you just continued posting in your old threads, you won't have to reconfuse everyone again.

Mmedina_student

Nothing changes if you actually did some work and had it working with wifi. A GSM mobile hotspot would work just the same. As I recall, you continually failed to describe your project in adequate detail in other threads you have made, so the locations, positions, distances, all relevant details on how you would secure the device are unknown to anyone trying to get an idea of what your project actually needs to do.
Maybe if you just continued posting in your old threads, you won't have to reconfuse everyone again.
Other details of the project are irrelevant to what i'm asking, what i'm asking is if the gprs shield is able to do the same things the ethernet shield (that i'm currently using) does. i don't give specific information about what kind of sensor i'll be using because that's irrelevant to what i'm asking i don't want people to ask what kind of sensor i'll be using or any kind of question that can mislead the particular information i need.

Mmedina_student

How are you detecting whether the parking spot is occupied or empty?

That's irrelevant to what i need to know.

What i need to do is to save a boolean variable to a database.

avr_fred

Quote
What i need to do is to save a boolean variable to a database.
What you need to do is stay on a single topic. You first question was:

Quote
What i need to do is upload data from the sensor to a database, currently i have a local database but i don't know if i will be able to continue to develop with a local environment since i wont be able to make a local area network
Next up:

Quote
what i'm asking is if the gprs shield is able to do the same things the ethernet shield (that i'm currently using) does.
Good grief. How is anyone supposed to respond if every new post brings a different question?

Mmedina_student

first and second quotes are the same thing written differently(that's what i'm currently able to do with the ethernet shield and one of the goals of my project, the last quote is the actual information i need from this thread.

I'm not asking HOW to do it, what i'm asking if it's possible to do it similarly as the ethernet shield with the SIM800L shield.

this is my current code using the ethernet shield.

#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>

// this code generates data from the sensors and makes an http request to a local server and the page requested makes an insert of the data passed

#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

// Enter the IP address for Arduino
// Be careful to use , insetead of . when you enter the address here
IPAddress ip(192, 168, 0, 170);

int vcc = 5; //attach pin 2 to vcc
int trig = 6; // attach pin 3 to Trig
int echo = 7; //attach pin 4 to Echo
int gnd = 8; //attach pin 5 to GND

float cm1;
float cm2;
float cm3;
float cm4;
float cm5;

bool isparked1;
bool isparked2;
bool isparked3;
bool isparked4;
bool isparked5;

long duration;
long duration1;
long duration2;
long duration3;
long duration4;
long duration5;

char server[] = "192.168.0.11";//direccion o ip del servidor (en este caso estamos usando un servidor local por lo tanto usamos la ip de esta maquina

// Initialize the Ethernet server library
EthernetClient client;

void setup() {

  pinMode (vcc, OUTPUT);
  pinMode (gnd, OUTPUT);
  // initialize serial communication:
  Serial.begin(9600);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
}
//metodo para calcular los centimetros
float microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

//metodo para ejecutar la medicion
long ejecutarMedicion()
{
  pinMode(trig, OUTPUT);
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(5);
  digitalWrite(trig, LOW);
  pinMode(echo, INPUT);
  duration = pulseIn(echo, HIGH);//photocell

  return duration;
}


void loop() {

  digitalWrite(vcc, HIGH);

  Serial.println();
  Serial.print("comenzando loop");
  Serial.println();
  Serial.print("haciendo nueva medicion 1");
  Serial.println();

  //medicion
  duration1 = ejecutarMedicion();
  //fin medicion

  //calculo en centimetros
  cm1 = microsecondsToCentimeters(duration1);
  //fin calculo de cm
  Serial.print("Centimetros 1: ");
  Serial.print(cm1);
  Serial.println();
  //si los centimetros son menos de 100 quiere decir que hay un auto estacionado, si es mayor a 100 el estacionamiento esta desocupado
  if (cm1 <= 100)
  {
    isparked1 = true;
    Serial.print("Estacionado: SI 1");
    Serial.println();
  }
  else if (cm1 > 100)
  {
    isparked1 = false;
    Serial.print("Estacionado: NO 1");
    Serial.println();
  }
  Serial.print("esperando 2 segundos");
  Serial.println();
  delay(2000);

  Serial.print("haciendo nueva medicion 2");
  Serial.println();
  duration2 = ejecutarMedicion();

  cm2 = microsecondsToCentimeters(duration2);
  Serial.print("Centimetros 2: ");
  Serial.print(cm2);
  Serial.println();

  if (cm2 <= 100)
  {
    isparked2 = true;
    Serial.print("Estacionado: SI 2");
    Serial.println();
  }
  else if (cm2 > 100)
  {
    isparked2 = false;
    Serial.print("Estacionado: NO 2");
    Serial.println();
  }

  if (isparked1 != isparked2)
  {
    Serial.print("isparked1 es distinto de isparked2");
    Serial.println();
    Serial.print("esperando 2 segundos");
    Serial.println();

    delay(2000);

    Serial.println();
    Serial.print("haciendo nueva medicion 3");
    Serial.println();
    duration3 = ejecutarMedicion();

    cm3 = microsecondsToCentimeters(duration3);
    Serial.print("Centimetros 3: ");
    Serial.print(cm3);
    Serial.println();
    if (cm3 <= 100)
    {
      isparked3 = true;
      Serial.print("Estacionado: SI 3");
      Serial.println();
    }
    else if (cm3 > 100)
    {
      isparked3 = false;
      Serial.print("Estacionado: NO 3");
      Serial.println();
    }

    if (isparked2 == isparked3)
    {
      Serial.println();
      Serial.print("isparked2 == isparked3");
      Serial.println();
      Serial.print("esperando 2 segundos");
      Serial.println();

      delay(2000);

      Serial.print("haciendo nueva medicion 4");
      Serial.println();
      duration4 = ejecutarMedicion();

      cm4 = microsecondsToCentimeters(duration4);
      Serial.print("Centimetros 4: ");
      Serial.print(cm4);
      Serial.println();
      if (cm4 <= 100)
      {
        isparked4 = true;
        Serial.print("Estacionado: SI");
        Serial.println();
      }
      else if (cm4 > 100)
      {
        isparked4 = false;

        Serial.print("Estacionado: NO");
        Serial.println();
      }

      if (isparked3 == isparked4)
      {
        Serial.print("isparked3 == isparked4");
        Serial.println();
        Serial.print("esperando 2 segundos");
        Serial.println();

        delay(2000);

        Serial.print("haciendo nueva medicion 5");
        Serial.println();
        duration5 = ejecutarMedicion();
        cm5 = microsecondsToCentimeters(duration5);
        Serial.print("Centimetros 5: ");
        Serial.print(cm5);
        Serial.println();

        if (cm5 <= 100)
        {
          isparked5 = true;
          Serial.print("Estacionado: SI");
          Serial.println();
        }
        else if (cm5 > 100)
        {
          isparked5 = false;
          Serial.print("Estacionado: NO");
          Serial.println();
        }

        if (isparked2 == isparked3 && isparked3 == isparked4 && isparked4 == isparked5)
        {
          Serial.print("Todos los valores de 4 mediciones son iguales");
          Serial.println();
          Serial.print("Conectando...");
          Serial.println();
          if (client.connect(server, 80))
          {
            Serial.print("CONECTADO");
            Serial.println();
            Serial.print("nuevo valor: ");
            Serial.print(isparked5);
            Serial.println();
            Serial.print("haciendo la insercion del nuevo valor");
            Serial.println();
            client.print("GET /write_data.php?"); // This
            client.print("value="); // This
            client.print(isparked5);
            if (isparked5 == 0)
            {
              Serial.println();
              Serial.print("NO ESTACIONADO");
            }
            else
            {
              Serial.println();
              Serial.print("SI ESTACIONADO");
            }
            client.println(" HTTP/1.1"); // Part of the GET request
            client.println("Host: 192.168.0.11"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
            client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
            client.println(); // Empty line
            client.println(); // Empty line
            client.stop();    // Closing connection to server
          }
          else
          {
            Serial.print("no hay conexion");
          }
        }
      }
    }
  }
  Serial.println();
  Serial.print("terminando loop");
  Serial.println();
}
   

TomGeorge

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

sterretje

Maybe this helps for the Arduino side of things: arduino use sim800 to connect to internet.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up