arduino-uno


arduino wifi upload google spreadsheet


I want to use ESP8266 module upload data to google spreadsheet, I find a lot of information on the Internet, the following 4 lines of text is my place to stop operating, would like to ask how to solve the situation even after WIFI module will not work, thank you
SEND: AT
RECEIVED: OK
SEND: AT+CWJAP="chen","3681"
RECE
//-----------------------------------------------
//Author:
//Aditya Riska Putra
//Ahmed Reza Rafsanzani
//Ryan Eko Saputro
//
//ELINS UGM
//-----------------------------------------------
/*
Since Arduino can't handle https, we need to use Pushingbox API (uses http) to run the Google Script (uses https).
http://jarkomdityaz.appspot.com/
*/
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>
#define _baudrate 115200
#define SSID "chen"
#define PASS "3681"
#define _rxpin 4
#define _txpin 5
SoftwareSerial debug( _rxpin, _txpin ); // RX, TX
#define IP "184.106.153.149" // ThingSpeak IP Address: 184.106.153.149
//-------------------------------------------------------------------------------
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address
char server[] = "api.pushingbox.com"; //pushingbox API server
IPAddress Arduinoip(192,168,1,2); //Arduino IP address. Only used when DHCP is turned off.
EthernetClient client; //define 'client' as object
//String data; //GET query with data
String distant; //distant (bahasa Indonesia) means temperature
boolean koneksi = false;
String GET = "GET /update?key=?";
//------------------------------------------------------------------------------
void setup() {
//wifi-------------------------------------------------------------------------------------------------
Serial.begin( _baudrate );
debug.begin( _baudrate );
sendDebug("AT");
Loding("sent AT");
connectWiFi();
//---------------------------------------------------------------------------------------------
Serial.begin(_baudrate);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, Arduinoip);
}
delay(1000);
}
//------------------------------------------------------------------------------
void loop(){
// String baca_ADC = 5 ;//analogRead(7); //read analog input on pin A7
distant = 5 ;//baca_ADC * 5.0 * 100.0/1024.0; // 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(distant); //print sent value to serial monitor
client.stop();
koneksi = false;
GET = ""; //data reset
}
}
delay(5000); // interval
//upload--------------------------------------------------------------------------------------------
SentOnCloud( String(distant) );
//---------------------------------------------------------------------------------------------------------------
}
void kemasData(){
GET+="";
GET+="GET /pushingbox?devid=v7795E2403219CB1&tempData="; //GET request query to pushingbox API
GET+=distant;
GET+=" HTTP/1.1";
}
void sendData(){
Serial.println("connected");
client.println(GET);
client.println("Host: api.pushingbox.com");
client.println("Connection: close");
client.println();
}
//upload----------------------------------------------------------------
void SentOnCloud( String T )
{
// 設定 ESP8266 作為 Client 端
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
sendDebug(cmd);
if( debug.find( "Error" ) )
{
Serial.print( "RECEIVED: Error\nExit1" );
return;
}
cmd = GET + "&field1=" + T ;
debug.print( "AT+CIPSEND=" );
debug.println( cmd.length() );
if(debug.find( ">" ) )
{
Serial.print(">");
Serial.print(cmd);
debug.print(cmd);
}
else
{
debug.print( "AT+CIPCLOSE" );
}
if( debug.find("OK") )
{
Serial.println( "RECEIVED: OK" );
}
else
{
Serial.println( "RECEIVED: Error\nExit2" );
}
}
//-------------------------------------------------------------------
//wifi------------------------------------------------------------
boolean connectWiFi()
{
debug.println("AT+CWMODE=1");
Wifi_connect();
}
void Wifi_connect()
{
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
sendDebug(cmd);
Loding("Wifi_connect");
}
void Loding(String state){
for (int timeout=0 ; timeout<10 ; timeout++)
{
if(debug.find("OK"))
{
Serial.println("RECEIVED: OK");
break;
}
else if(timeout==9){
Serial.print( state );
Serial.println(" fail...\nExit2");
}
else
{
Serial.print("Wifi Loading...");
delay(500);
}
}
}
void sendDebug(String cmd)
{
Serial.print("SEND: ");
Serial.println(cmd);
debug.println(cmd);
}
//--------------------------------------------------------------
[1]: http://i.stack.imgur.com/MrclX.png

Related Links

AT+CSQ? returns error
Array accessing in arduino and for loop
Bluetooth module won't function when working with leapmotion
switch on or off the motor based on the reply of the user
IS my Modulo usage incorrect? What can
Use analog output as digital in relay pins
Arduino Uno and ESP8266-01
Power supply for raspberry and arduino
Arduino UNO and MPU 6050
Understanding timer choices/options
Programming attiny45 chip and ir remote library
Arduino Uno: Running multiple servos
MPU 6050 SD Writing Frequency Arduino is not constant , how to have a constant writing frequency?
MPU 6050 giving values -1
P10 with Arduino, display negative/all pixels on
Arduino-uno project [closed]

Categories

HOME
osgi
deployment
magnific-popup
server
deezer
json.net
raspberry-pi
syntax
electron
retrofit
swagger-ui
imacros
export-to-csv
static-libraries
lombok
pythonanywhere
autocad-plugin
tdd
maxmind
replaceall
saas
dbclient
quote
gsmcomm
http-status-code-503
data-manipulation
language-concepts
jmonkeyengine
disassembling
bitbucket-pipelines
unspecified
elasticsearch-plugin
preconditions
keydown
outlook-api
slick-3.0
segment
executenonquery
wso2carbon
hibernate-tools
strptime
python-c-api
boost-multi-index
yii2-extension
nstextview
elgg
magma
nodebb
snmptrapd
dtexec
arrow-keys
imanage
instant
sts-springsourcetoolsuite
hover-over
yaws
netmq
browser-link
r-tree
jms2
teamcity-8.0
jqgrid-formatter
sysinternals
e10s
modalpopup
operator-precedence
jsonpickle
pick
camanjs
knuth
relocation
wordpress-theme-customize
oracle-warehouse-builder
java.nio.file
mbr
uv-mapping
ccss
dbconnection
html4
jelly
robotics-studio
wsdl-2.0
nsnetservice
bluepill
automount
labwindows
errai
ticoredatasync
wse3.0
stage
gdlib
w3wp.exe
fluent-interface
gamequery
substrings
microsoft-virtualization
phonon
aquaticprime
procedural-music

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App