Hello
I have an Arduino MEGA with 3G shield (UC20-G) and want to store my data into the dweet.io.
So, i try to test it by posting "Hello world" on the dweet.io ,but it do nothing.
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "call.h"
#include "sms.h"
#include "internet.h"
#include "File.h"
#include "http.h"
INTERNET net;
UC_FILE file;
HTTP http;
//SIM TRUE internet
#define APN "www.dtac.co.th"
#define USER ""
#define PASS ""
//SoftwareSerial mySerial(2, 3); // RX, TX
AltSoftSerial mySerial;
void debug(String data)
{
Serial.println(data);
}
void data_out(char data)
{
Serial.write(data);
}
void setup()
{
Serial.begin(9600);
gsm.begin(&mySerial,9600);
gsm.Event_debug = debug;
Serial.println(F("UC20"));
gsm.PowerOn();
while(gsm.WaitReady()){}
Serial.print(F("GetOperator --> "));
Serial.println(gsm.GetOperator());
Serial.print(F("SignalQuality --> "));
Serial.println(gsm.SignalQuality());
Serial.println(F("Disconnect net"));
net.DisConnect();
Serial.println(F("Set APN and Password"));
net.Configure(APN,USER,PASS);
Serial.println(F("Connect net"));
net.Connect();
Serial.println(F("Show My IP"));
Serial.println(net.GetIP());
Serial.println(F("Start HTTP"));
http.begin(1);
Serial.println(F("Send HTTP POST"));
http.url("https://dweet.io/dweet/for/testing2?hello=world&foo=bar");
Serial.println(http.post());
Serial.println(F("Clear data in RAM"));
file.Delete(RAM,"*");
Serial.println(F("Save HTTP Response To RAM"));
http.SaveResponseToMemory(RAM,"https://dweet.io/dweet/for/testing2?hello=world&foo=bar");
Serial.println(F("Read data in RAM"));
read_file(RAM,"https://dweet.io/dweet/for/testing2?hello=world&foo=bar");
Serial.println(F("Disconnect net"));
net.DisConnect();
}
void read_file(String pattern,String file_name)
{
file.DataOutput = data_out;
file.ReadFile(pattern,file_name);
}
void loop()
{
if (gsm.available())
{
Serial.write(gsm.read());
}
if (Serial.available())
{
char c = Serial.read();
gsm.write(c);
}
}
then, in the serial monitor, it showed
UC20
Power Retry
Power Retry
Power OFF
Power Retry
Power ON
+CFUN: 1
+CPIN: READY
+QUSIM: 1
+QIND: SMS DONE
+QIND: PB DONE
UC20 Ready...
Close Echo
OK
GetOperator --> "DTAC",6
SignalQuality --> 4
Disconnect net
OK
Set APN and Password
OK
Connect net
OK
Show My IP
OK
10.75.149.191
Start HTTP
OK
Send HTTP POST
OK
10
Clear data in RAM
Error
Save HTTP Response To RAM
Read data in RAM
OK
OK
Disconnect net
OK
Could someone suggest me how to solve this?
Thank you for your advice.