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

LED's won't light up with Arduino
Every function executes on Arduino reset
What is the output of this arduino code?
Shield L6474 and motor equiped with a reducer
NRF24L01+PA+LNA (Transciever) not communicating between two arduinos
Can't program Arduino 328P after first time use of ICSP Sparkfun AVR Pocket Programmer
Arduino uploading issue: “avrdude: no programmer has been specified on the command line or the config file”
Code is showing multiple object declaration error during multiple file compilation
arduino wifi upload google spreadsheet
How to solve error compiling an arduino sketch?
load image in the TFT lcd screen without SD card
how to send dummy data on gpio pins of arduino uno.?
Serial Port not working () on Arduino in JetBrains CLion
Error in using IF statement
Arduino not displaying results
Python ImportError: No module named yahoo_finance

Categories

HOME
ionic-framework
pdf
client
mockito
plone
json.net
lodash
alfresco
jsp-tags
electronics
umd
callback
enterprise-library-5
contact
volttron
modx-revolution
spring-tool-suite
leiningen
ef-migrations
firefox-webextensions
jprofiler
amazonsellercentral
zapier
abi
tokenize
functional-testing
accessor
mustache.php
core-text
bootstrap-tour
zurb-foundation-6
captiveportal
claims-based-identity
rundeck
dynamic-featured-image
windows-server-2000
libuv
newline
react-chartjs
binary-data
semantic-versioning
lxd
accelerate-framework
force-layout
restlet
lto
squib
email-templates
avro4s
fedex
angular2-meteor
flickr-api
upstart
paxos
sage-one
powercli
tizen-native-app
aurelia-validation
brightcove
darcs
magma
nsarray
zendesk-app
imanage
angular-strap
log4c
superstack
testng-dataprovider
bgp
captivenetwork
rhino-servicebus
itextpdf
system.management
energy
jfugue
sdhc
atk4
feedback
ng-animate
angularjs-ng-click
device-manager
markers
websocket4net
eol
dealloc
geos
easy-install
cos
coderush
spring-portlet-mvc
semantic-diff
assembly-loading
javax.script
yslow
gin
dbal
privilege
yagni
sustainable-pace
project-hosting
document-conversion

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App