Hello! I'm the one who is trying to do mkr1000&grove heart rate sensor
Problem: Publish to artik cloud has some problem..! (I think code or something will be problem)
1.Open SSL generated & updated
I downloaded open ssl generation tool and make keys
& firmware update with WIFI101 FIRMWARE UPDATER <- update certification with "arduino.cc:443, api.artik.cloud:443"
- my code:
#include <WiFi101.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiSSLClient.h>
#include <WiFiUdp.h>
#include <ArduinoHttpClient.h>
#include <ArduinoJson.h>
#include <SPI.h>
#include <Wire.h>
int bpm;
String state;
// ARTIK Cloud REST endpoint
char server[] = “api.artik.cloud”;
int port = 443; // We’re using HTTPS
// Device ID tokens
String deviceToken = “2af07ef39656458b9a749b1dcd5e9d8f”;
String deviceId = “484f96b4fc6d4b0aa731ee38618c7294”;
// Your wifi network
char ssid[] = “/*secret..!!*/”;
char pass[] = “/secret/”;
char buf[200]; // buffer to store the JSON to be sent to the ARTIK cloud
const int LED = 6;
int ledState = 0;
WiFiSSLClient wifi;
HttpClient client = HttpClient(wifi, server, port);
int status = WL_IDLE_STATUS;
void setup() {
Serial.begin(9600);
while(!Serial);
while ( status != WL_CONNECTED) { // Keep trying until connected
Serial.print(“Attempting to connect to Network named: “);
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.print(rssi);
Serial.println(” dBm”);
}
}
void loop() {
Serial.println(“loop”);
Serial.println(“making POST request”);
String contentType = “application/json”;
String AuthorizationData = "Bearer " + deviceToken; //Device Token
String convert;
Wire.requestFrom(0xA0 >> 1, 1); // request 1 bytes from slave device
while(Wire.available()) { // slave may send less than requested
unsigned char c = Wire.read(); // receive heart rate value (a byte)
//Serial.println(c, DEC); // print heart rate value
convert=String(c,DEC);
bpm=convert.toInt();
}
int len = loadBuffer(bpm);
Serial.println("Sending data"+String(bpm));
// push the data to the ARTIK Cloud
client.beginRequest();
client.post("/v1.1/messages"); //, contentType, buf
client.sendHeader("Authorization", AuthorizationData);
client.sendHeader("Content-Type", "application/json");
client.sendHeader("Content-Length", len);
client.endRequest();
client.print(buf);
// read the status code and body of the response
int statusCode = client.responseStatusCode();
String response = client.responseBody();
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Serial.println("Wait a bit");
delay(15000);
}
int loadBuffer(int BPM) {
StaticJsonBuffer < 200 > jsonBuffer; // reserve spot in memory
JsonObject & root = jsonBuffer.createObject(); // create root objects
root[“sdid”] = deviceId;
root[“type”] = “message”;
JsonObject & dataPair = root.createNestedObject(“data”); // create nested objects
dataPair[“heartRate”] = BPM;
root.printTo(buf, sizeof(buf)); // JSON-print to buffer
return (root.measureLength()); // also return length
}
===================
- result:
"Attempting to connect to~~
ssid
...
loop
making POST request"
That's all..
No charts were generated on artik cloud
- no prints on serial monitor more
what can I do for this problem?