Hi there,
I did copy a code from a resource online to get datas to Google Form by using pushingBox. I edited my codes and uploaded TMP7 Library as i was using it together with Arduino Uno and Wifi Shield. There seems to be a problem on my codes as it says "invalid conversion from 'byte* {aka unsigned char*}' to 'char*' [-fpermissive]" due to "WiFi.begin(mac, ip);"
My codes are as below:
#include <TMP37.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <SPI.h>
#include <SPI.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
#define TMP37;
#define TMP37PIN 0
byte mac[] = {0x78, 0xC4, 0x0E, 0x02, 0x0B, 0x3F }; //Wifi shield MAC
byte ip[] = {192,168,0,20}; // Arduino device IP address
char devid[] = "mydevid" ; // THIS IS THE DEVICE ID FROM PUSHINGBOX
int del=300; // Amount of seconds delay between posting to google docs.
char postmsg[100];
int k=0;
int temp_av = 0;
char server[] = "api.pushingbox.com";
WiFiClient client;
void setup()
{
Serial.begin(9600);
WiFi.begin(mac, ip);
delay(1000);
Serial.println("connecting...");
}
void loop(){
// average temp reading for 'del' time.........................................
for(int j=0; j<del;j++)
{
// Read local temp........................................
int chk = TMP37.read(TMP37PIN);
int temp = Fahrenheit(TMP37.temperature);
temp_av=temp_av+temp;
delay(1000);
}
int avtemp=temp_av/(del);
temp_av=0;
// Post to Google Form.............................................
if (client.connect(server, 80))
{
k=0;
Serial.println("connected");
sprintf(postmsg,"GET /pushingbox?devid=%c&status=%d HTTP/1.1",devid,avtemp); // NOTE** In this line of code you can see where the temperature value is inserted into the wed address. It follows 'status=' Change that value to whatever you want to post.
client.println(postmsg);
client.println("Host: api.pushingbox.com");
client.println("Connection: close");
client.println();
Serial.println(postmsg);
Serial.println("Host: api.pushingbox.com");
Serial.println("Connection: close");
Serial.println();
delay(1000);
client.stop();
}
delay(1000);
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
k==1;
return;
}
}
double Fahrenheit(double celsius) // Function to convert to Fahrenheit
{
return 1.8 * celsius + 32;
}
What was the mistake here? I'm still a newbie and I really don't know that much about using Arduino. I hope someone could assist me through. Thank you in advance.