This
time, let’s try to develop a IOT solution based on the following section
1.
Communication method between WizFi250 and Pushing box
2.
Adding sensors into the device to transmit data to Cloud Server
(by Easy Module Shield and Arduino
Uno)
3.
WizFi250 send the message to Twitter through Pushing box
PushingBox Cloud Server
This Pushing Cloud server is very
simple to register and operate.
Link: https://www.pushingbox.com/
Registration: Using google account
to login.
Firstly, you can create a Pushingbox
Account
If you have Google account, please
press login with Google on the top right hand corner.
Go to “My Services” and “Add a
service”
Adding devices means it will add the location platform for
pushing those data.
You could choose Twitter, email or even push to a specific link for your
own use.
This time we select Twitter and add this service.
Enter to My Scenarios, you can find your “Scenario name” & “Device ID”.
After that you press the “Manage” button to enter my service.
You can
find that Twitter service is added. And it connects to your Twitter account.
Obtain
the Xively API sever IP
PushingBox API Server : 213.186.33.19
PushingBox API Port: 80
Association to AP in WIZfi250
AT+WLEAVE
[OK]
AT+WSET=0,wiznet,,
[OK]
AT+WSEC=0,WPA2,vickitjohn
[OK]
AT+WNET=1
[OK]
AT+WJOIN
Joining : wiznet
Successfully joined : wiznet
[Link-Up Event]
IP
Addr : 10.0.1.5
Gateway : 10.0.1.1
[OK]
HTTP Request format for PushingBox
When
Temperature is 30C and humidity is 70%
The local data save to Twitter through PushingBox
AT+SCON=O,TCN, 213.186.33.19,80,,0
[OK]
[CONNECT 0]
AT+SSEND=0,,,132
[0,,,132]
Send “get.txt” to pushing box
through WizFi250
Receive from the PushingBox API
server
AT+SSEND=0,,,132
[0,,,132]
{0,213.186.33.19,80,398}HTTP/1.1 200 OK
Set-Cookie: 6OgpBAK=R1224197954; path=/; expires=Tue, 10-May-2016 02:39:33 GMT
Date: Tue, 10 May 2016 01:40:21 GMT
Content-Type: text/html
Content-Length: 0
Connection: close
Set-Cookie: 60gp=R4109563240; path=/; expires=Tue, 10-May-2016 02:41:29 GMT
Server: Apache
Content-Location: pushingbox.php
Vary: negotiate,Accept-Encoding
TCN: choice
X-Powered-By: PHP/5.5.34
Pushing Box has provided some other
API sources code.
Please refer the link:
https://www.pushingbox.com/api.php
In Arduino Uno Source Code, you must
set the
Device ID: v7A7E2DA2DE9D52F
Dest IP: 213.186.33.19
Server: api.pushingbox.com
And set the correct HTTP request format for
PushingBox.
void sendData(String thisData)
{
uint8_t content_len[6] = {0};
String TxData;
if (myClient.connect() == RET_OK) // RET_OK
{
Serial.println(“connecting..");
// send the HTTP Get request:
TxData = "GET /pushingbox?devid="; TxData += DeviceID;
TxData += "HTTP/1.1\r\n";
TxData += "Host: api .pushingbox.com”;
TxData += “Accept: */*";
TxData += "Connection: close";
TxData += “\r\n\r\n";
myClient.send((String)TxData);
lastConnectionTime = millis();
}
}
#include <Arduino.h>
#include <SPI.h>
#include <IPAddress.h>
#include “WizFi250.h"
#include “WizFi250_tcp_client.h"
#define DeviceID "“v?A7E2DA2DE9DS2F"
#define SSID “wiznet"
#define KEY “xxxxxxxxxx"
#define AUTH “"
#define REMOTE_PORT 80
#define LOCAL_PORT 5004
IPAddyess ip (10,0,1,15);
IPAddxess destIP (213,186,33,19);
TPAddress gateway (10,0,1,1);
IPAddress mask (255,255,255,0);
char server[] = “api.pushingbox.com" ;
unsigned long lastConnectionTime = 0;
const unsigned long postingInterval = 10*1000;
boolean Wifi_setup = false;
boolean lastConnected = false;
boolean isFirst = true;
The library for the connection
between WizFi250 and Arduino Uno that the source File shows in Github
Please refer the link:
github.com/Wiznet/Arduino_WizFi250/tree/master/Software/WizFi250
Source code
For the source code, we will use the
HTTP client reference source code for the this testing.
About connecting with Easy Module
Shield and Arduino Uno, you could also read the previous article for more
information:
WizFi250+Arduino Uno+YuRobot with
Xively
Please refer the link:
WizFi250+Arduino Uno+YuRobot with Xively(English)
Result in
Twitter