Hi. Doing some prototyping with Notecard + Notecarrier F and all is working well. I am thinking of migrating an application from Wifi to Notecard/Blues that uses Blynk IOT as both UI (via the Blynk Android app) and their backend. The application is a battery powered wireless air quality monitor that pulls samples from several sensors and also records GPS position every few seconds. I also use Thingspeak as datastore and API. Do you have any experience using Blynk or another synchronous client app with Notecard/Blues? My concern is reliability of Notecard to be continuously connected to the Internet as I currently do through Wifi, not in periodic/batch mode. Thanks.
Hi @drewcssv ,
The cellular Notecard DOES offer a continuous connection to the cell towers, via {"req":"hub.set","mode":"contiuous"}
. This will offer the fastest data egress available, but this is a very battery intensive mode to operate in. As such, we recommend having mains power available to your device. To achieve the same quickness during ingress, we have an optional "sync":true
parameter that can be supplied to the hub.set
command.
To learn more about this type of communication, checkout our Minimizing Latency Guide.
Hey @drewcssv,
Welcome to the Blues community! Weâre glad youâre here and I look forward to seeing how your project migration goes!
Iâve not personally used Blynk in some time, and havenât tried it with the Notecard, but if you follow Zakâs continuous mode instructions, you should be able to give it a shot. Let us know how it goes, and if you run into any stumbling blocks!
Hi.
It will work just fine with Blynk but you will need to go via something like Node-RED to convert the inbound MQTT message from Blues to Blynk API calls. Not sure what value you get out of the âalways connectedâ but then I dont know anything about your application. Either way itâs irrelevant to the question of being able to use Blynk.
Hi, thanks for the tips. Many Blynk users do indeed use Node-RED with MQTT. The value of Blynk to my application is a highly-customizable Android/iOS app that I can quickly build and deploy without needing Android, Swift or Xcode skills. It is this app that needs a constant connection, similar to, say, a Bluetooth connected app that monitors a realtime sensing device. When students using the air quality monitor sense particulates or CO2 gas the app instantly displays data and graphs showing the values in realtime. The data is also sent to the cloud and stored in Thingspeak.
Drew
Hi Drew,
Not sure I understand completely so read my reply with that in mind.
Blynk is a great App and I have been using it a lot for several years. It however does not require an always up connection. However if I understand correctly your specific use case does require always on.
You do have the option to use the WiFi Notecard in the case that you have wifi available to the node(s) and this would be the best in my opinion for an always on requirement. Should you need connectivity beyond the reach of wifi you can swap to the cellular notecard but I would avoid the always on scenario if your specific use case can work with some lag. As mentioned the Blynk platform does not care either way but it will not be realtime.
The cellular connectivity with the cellular notecard is robust even in always on mode but there is a cost associated with always on in the cellular world.
Hope this helps,
Serge
Can someone please help me understand how to execute a HTTP GET Route on Notehub?
I would also like to use my Notecard with Blynk. I want to create a Route (webhook) on Notehub to transform data sent by my Notecard and then execute a HTTP GET on Blynk. A HTTP GET on Blynk is the only way to send data for multiple Blynk datastreams.
Hi @markwkiehl,
There are two ways to get event data out of Notehub:
- Notehub Routes let you POST data to an endpoint that you define.
- The Notehub Event API allows you to âpullâ data out of Notehub from a remote service with an HTTP GET.
Does that make sense? Let me know if you have any more questions or if I can clear up any issues.
Rob
Thank you Rob for the clarification.
It doesnât seem like I can push data from my Notecard to an external cloud service via a HTTP GET. It is unfortunate that Blynk requires an HTTP GET to update the values of multiple datastreams.
What about using a âweb.getâ Web Transaction to perform a HTTP GET from my Notecard to Blynk? I need to configure the Route as a proxy.
IT WORKS! I created a Route that is configured as a proxy. Then I use a Web Transaction web.get with the ânameâ set to the URL parameters that contain the data (payload).
A complete example / tutorial has been posted to the following URL:
https://savvymicrocontrollersolutions.info/blues_io.php?blog=blues-io-route-blynk
@markwkiehl Bump! I am trying to follow your excellent example here but running into some issues. I can successfully execute the Route configured as a proxy, and generate a payload that is headed over to Blynk. But Blynk is consistently returning a â400â error, stating that I have an âinvalid tokenâ. I know the token I am using is correct as I can execute the route URL in Chrome, reading and updating data in Blynk:
https://ny3.blynk.cloud/external/api/batch/update?token=xxxxxxxxxxxxxxxx&v31=888&v2=13
So, something in the âweb.getâ Web transaction is somehow impacting the token, orâŚsomething else is causing Blynk to consider the token invalid. Any thoughts as to what might be happening?
The Notecard must be in continuous mode and connected to Notehub in order to execute the Notecard API request. Try setting up a Postman mock server and sending the request to that with the Notecard to verify the Notecard is pushing the data correctly since you already verified the Blynk side.
Hi Mark, thanks for the reply! I am using your example code with the only difference being an ESP32 S3 vs Swan MPU. Otherwise the code is same, with:
req = notecard.newRequest("hub.set");
if (req) {
JAddStringToObject(req, "product", PRODUCT_UID);
JAddStringToObject(req, "mode", "continuous");
if (!notecard.sendRequest(req)) {
notecard.logDebug("ERROR: hub.set in NotecardNetworkConnect()\n");
Serial.println("ERROR: hub.set in NotecardNetworkConnect()!\n");
return false;
}
}
and
// Push data to the proxy route and then to Blynk
Serial.println("\nMaking a Notecard request web.get..");
J *req = notecard.newRequest("web.get");
if (req) {
Serial.println("web.get init okay");
JAddStringToObject(req, "route", "BlynkGet");
JAddStringToObject(req, "name", "&V0=1.23456&V1=112&V2=blues.io&V7=-73.988&V7=40.724");
char c_v1[3];
char str[25];
char payload[99];
sprintf(c_v1, "%u", v1);
v0 = fGetSignedRandFloat();
dtostrf(v0, 7, 6, str);
strcpy(payload, "&V0=");
strcat(payload, str);
strcat(payload, "&V1=");
strcat(payload, c_v1);
strcat(payload, "&V2=blues.io&V7=");
lon = fGetRandLongitude();
dtostrf(lon, 7, 6, str);
strcat(payload, str);
strcat(payload, "&V7=");
lat = fGetRandLatitude();
dtostrf(lat, 7, 6, str);
strcat(payload, str);
Serial.print("payload: '"); Serial.print(payload); Serial.println("'\t");
JAddStringToObject(req, "name", payload);
v1++;
if (v1 > 199) {
v1 = 100;
}
// requestAndResponse() sends a JSON request to the Notecard, and returns
// the Notecard's JSON response.
// For this request, a favorable response will be: {"result":200}
J *rsp = notecard.requestAndResponse(req);
int result = JGetInt(rsp, "result");
if (result == 200) {
Serial.println("Response: 200 okay");
} else {
Serial.println("Response: "); Serial.print(result); Serial.println(" ERROR!");
}
notecard.deleteResponse(rsp);
}
Only thing I can think of is mismatched datatypes in my Blynk datastream but I usually see a different error message when that is the case, so thinking itâs something else that manifests as âinvalid tokenâ.
Success! Wanted to share that the routing to Thingspeak is working well now. Seems there was an error in the JSONata that was raising the error. Thanks to all for your help.