I am trying to gather sensor info from various devices, and compile it into a char and have it posted to a server via php and the HTTP GET method.
When i compile this code i get "invalid operands of types 'const char*' and 'const char [6]' to binary 'operator+'"
#include "arduino4G.h"
// APN settings
///////////////////////////////////////
char apn[] = "";
char login[] = "";
char password[] = "";
///////////////////////////////////////
// SERVER settings
///////////////////////////////////////
char host[] = "";
uint16_t port = 80;
char resource[] = "";
///////////////////////////////////////
// variables
uint8_t error;
int Hum;
int pH;
int lat;
int lon;
int temp;
void setup()
{
error = _4G.ON();
Serial.println(F("Start program"));
//********************************************************************
// GET method to the Libelium's test url
// You can use this php to test the HTTP connection of the module.
// The php returns the parameters the user sends with the URL.
//********************************************************************
//////////////////////////////////////////////////
// 1. sets operator parameters
//////////////////////////////////////////////////
_4G.set_APN(apn, login, password);
//////////////////////////////////////////////////
// 2. Show APN settings via USB port
//////////////////////////////////////////////////
_4G.show_APN();
}
void loop()
{
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = _4G.ON();
if (error == 0)
{
Serial.println(F("1. 4G module ready..."));
////////////////////////////////////////////////
// 2. HTTP GET
////////////////////////////////////////////////
Serial.println(F("2. Getting URL with GET method..."));
// send the request
error = _4G.http( GET_METHOD, host, port, resource);
resource = "&Temp=" + temp
+ "&Hum=" + Hum + "&lvl=" + lon //fix
+ "&pH=" + "Enter sensor here" + "&lat=" + "&long=";
}
BUT, when I make the following changes below, I get this message.
#include "arduino4G.h"
// APN settings
///////////////////////////////////////
char apn[] = "";
char login[] = "";
char password[] = "";
///////////////////////////////////////
// SERVER settings
///////////////////////////////////////
char host[] = "";
uint16_t port = 80;
String resource;
///////////////////////////////////////
// variables
uint8_t error;
String Hum;
String pH;
String lat;
String lon;
String temp;
void setup()
{
error = _4G.ON();
Serial.println(F("Start program"));
//********************************************************************
// GET method to the Libelium's test url
// You can use this php to test the HTTP connection of the module.
// The php returns the parameters the user sends with the URL.
//********************************************************************
//////////////////////////////////////////////////
// 1. sets operator parameters
//////////////////////////////////////////////////
_4G.set_APN(apn, login, password);
//////////////////////////////////////////////////
// 2. Show APN settings via USB port
//////////////////////////////////////////////////
_4G.show_APN();
}
void loop()
{
//////////////////////////////////////////////////
// 1. Switch ON
//////////////////////////////////////////////////
error = _4G.ON();
if (error == 0)
{
Serial.println(F("1. 4G module ready..."));
////////////////////////////////////////////////
// 2. HTTP GET
////////////////////////////////////////////////
Serial.println(F("2. Getting URL with GET method..."));
// send the request
error = _4G.http( GET_METHOD, host, port, (String resource));
resource = "&Temp=" + (temp)
+ "&Hum=" + (Hum) + "&lvl=" + (lon) //fix
+ "&pH=" + "Enter sensor here" + "&lat=" + "&long=";
This error that highlights the line ** error = _4G.http( GET_METHOD, host, port, (String resource));**
expected primary-expression before 'resource'
resource, is normally a char based on the sample code provided with the 4G module as shown in the first segment of code.