Arduino to google sheet

Welcome:

I’ve worked on a program to receive the data from the Arduino board to another Arduino board via serial to serial
Then the other Arduino linked me to the ethrnet board to send data to Google sheet.
When a connection TX and RX, I receives data in serial monitor but does not send anything to google sheet.

  please help me`

#include <SPI.h>
#include <Ethernet.h>
//-------------------------------------------------------------------------------
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address
char server[] = "api.pushingbox.com"; //pushingbox API server
IPAddress ip(192,168,1,7); //Arduino IP address. Only used when DHCP is turned off.
EthernetClient client; //define 'client' as object
String data; //GET query with data
String suhu; //suhu (bahasa Indonesia) means temperature
boolean koneksi = false;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  if (Ethernet.begin(mac) == 0) {
	Serial.println("Failed to configure Ethernet using DHCP");
	Ethernet.begin(mac, ip);
  }
  delay(1000);
}
//------------------------------------------------------------------------------
void loop(){
   if (Serial.available() > 0) {      
   suhu =  Serial.readString();
   }// ADC to celcius conversion
   kemasData(); //packing GET query with data
   Serial.println("connecting...");
   if (client.connect(server, 80)) {
     sendData();  
     koneksi = true; //connected = true
   }
   else{
     Serial.println("connection failed");
   }
  // loop
  while(koneksi){
    if (client.available()) {
	  char c = client.read(); //save http header to c
	  Serial.print(c); //print http header to serial monitor
    }
    if (!client.connected()) {
	  Serial.println();
	  Serial.println("disconnecting.");
          Serial.print("Temperature Sent :");
          Serial.println(suhu); //print sent value to serial monitor
	  client.stop(); 
          koneksi = false; 
          data = ""; //data reset
    }
  }
  delay(5000); // interval
}

void kemasData(){
  data+="";
  data+="GET /pushingbox?devid=vB990F945F7F0481&tempData="; //GET request query to pushingbox API
  data+=suhu;
  data+=" HTTP/1.1";
}
void sendData(){
  Serial.println("connected");
  client.println(data);
  client.println("Host: api.pushingbox.com");
  client.println("Connection: close");
  client.println();
}

Do you really want to use wired Etherner with Particle devices are meant for wireless IoT?

1 Like

Yes I use an Ethernet board with an Internet router

But then I have to ask, are you actually using a Particle devices?
Since this is a board specifically for Particle devices we’d need to get some more context about your use case.

If you are using an Arduino board, you may be better helped there.

1 Like

ok Thank you