Associating multiple devices / auth tokens with the same project is the foundation on which IoT is based.
I remember someone else doing the exact same thing ā¦ garage weather station + house weather station and wanting to cross-pollinate the data between local displays. If I remember correctly, the recommendation at the time was the Bridge widget. We also talked about integrating the local devices with the National Weather Service to get the outdoor readings.
// Device #1
WidgetBridge bridge(V1); // or any other unused virtual pin for communication with Device #2
bridge.virtualWrite(V8, TempOut); // write TempOut to V8 on Device #2
// Device #2
BLYNK_WRITE(V8)
{
int TempIn = param.asInt(); // TempIn from Device #1
tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK);
tft.setCursor(175, 110);
tft.print(TempIn);
}
Ugly? It is actually a very simple and elegant way of triggering any other (within account) deviceās pin from another deviceās codeā¦ no App intervention required, aside placement of widgetā¦ which is dead simple.
As well as sharing data, it basically gives any sending deviceās code the ability to act like the other deviceās App project.
Beauty is in the eye of the beholder. In my eye, any time you hardcode credentials (e.g., SSID, password, auth token) in firmware, itās ugly. With the Bridge widget, the fact that you must hardcode the credentials of another device (or devices), is even more ugly.
But how else would any form of networking code function without some form of addressing and security?
From sensor device - āHey, you, control device over in the corner, flip the pin on that other lock device over thereā¦ no, that oneā¦ no, to your the leftā¦ your other left!.. ah forget it, the crook already entered and left the building with the TVā
Look at the MQTT Broker. @PeteKnight is a big MQTT fan. You certainly need āproject-level authorizationā.
In this use-case, the garage weather station would publish the outdoor temperature and humidity to the broker. The house weather station would subscribe to the outdoor temperature and humidity. The garage weather station doesnāt need to know the house weather station device-level credentials (and vice versa).
Letās assume that @877 wants to add a weather station in each room of his house. The garage weather station doesnāt need to hardcode the credentials for another half dozen devices. The new house weather stations simply subscribe to the outdoor temperature and humidity. The garage weather station doesnāt change at all.
Oh, I see what you meanā¦ but I am referring to the traditional Blynk method of cross device link, not one of the hundreds of other ways of IoT. PS, I think it is MQTT
Compared to other options, I think the Blynk font options are uglyā¦ but that is still the Blynk way of how they look.
I knew Iād get the blame somewhere along the line!
Thantās what Iāve been saying for ages, but does anybody listen?
The thing us that I there still needs to be some form of āhard-codingā.
The device thatās publishing data still needs the IP Address/URL of the MQTT server, and some credentials to be able to log-in, plus it needs to be told which topic(s) to publish the data to.
There still needs to be this āintroductionā before a handshake can be established and information exchanged.
Having said that, it is much easier to change things within Node-Red than re-flashing code to a device, so provided you get the credentials, topics and required data correct then itās easier to manipulate that in the way you want.
Iāve never had to use Bridge within C++ code (or even use the Bridge node in Node-Red) because itās easy to pull data from, and push data to any Blynk device within a project - provided you know the auth code. The devices donāt need to be in the same project, or even in the same account. Provided I know the auth code and the URL to the Blynk server then I can pull/push data - similar to how itās done with the RESTful API.
In my living room in Spain I have:
4 lights each attachyed to a to its own Sonoff
1 RGB LED strip
1 temperature/humidity sensor attached to a D1 Mini
1 Intrared transmitter attached to a D1 Mini
1 433MHZ transmitter/reciever attached to a D1 Mini
1 Nextion touch screen attached to a D1 Mini
Thereās also:
A weather station (yet to be installed - but working)
4 zones of outside lights each controlled by a Sonoff
A gate release system attached to a D1 Mini
A power monitor attached to a Sonoff
These are all controlled by, or push data into the same Blynk app (okay, not all of the data actually goes to Blynk, but itās there if I want it). Thatās 16 devices (so far), all linked together using Node-Red. I canāt imagine the pain that I would gave had to go through to do that with Blynk Bridge.
And, if I decide that Iād like to push the RSSI figures, or free memory figures for a number of my devices to a Superchart widget; then provided that data is being published from my device via MQTT then itās just a few clicks in Node-Red and quick change to the Blynk app to add the SuperChart. When I decide that I no longer want the data then itās a few clicks to take it out again.
Iām the first to admit that MQTT and Node-Red isnāt the answer to everything, but I think that itās a great solution for a simple to use smart home system and that once you get beyond two or three devices itās much easier solution once youāve got to grips with the basics.
Iād be OK with hardcoding the URL assuming your āproductā will always leverage the same MQTT server. But you wouldnāt want to hardcode the credentials (typically an MQTT server authorization token). This is the exact example I gave here,
Iām configuring the server authorization token (think of it as the MQTT server authorization token) and itās being applied to all of the devices. If needed, you could configure the MQTT server URL in the same way.
Note: Iām assuming that weāre connected to Blynk (preferably through dynamic authorization token provisioning / Blynk.Inject) in order to configure the MQTT server.
Note: Currently, without the ability to apply configuration changes (through, say a Text Input widget) across dynamically-provisioned devices, I must manually cut-n-paste (configure) the server authorization token from device to device to device (i.e., click on a Device Tile, click on the āSETUPā tab specific to the device, cut-n-paste the server authorization token, return to the Device Tiles widget, click on the next Device Tile and so on).
Agreed. But the information needed to establish the introduction need not be hardcoded.
But youāre hardcoding the Blynk device authorization tokens somewhere. I donāt want to know anything about Blynk device authorization tokens. Thatās between the Blynk server and the device. Keep my firmware out of it.
I wasnāt advocating the use of MQTT for this use-case. I was simply pointing out MQTT broker pub-sub as an example of a mechanism to exchange information between clients (devices) without the need to exchange device-level credentials. I shouldnāt have to introduce yet another cloud-based server in order to get this functionality. This functionality should be provided by Blynk. It sounds like weāre about to get something along these lines with the next major release (i.e., Cloud Pins).
I respect your opinion and your use of MQTT and Node-Red. Itās a good solution for your problem given the current state of Blynk.
I respect @Gunnerās opinion and his use of the Blynk widget. Itās a good (albeit ugly ) solution for his problem (and @877ās problem) given the current state of Blynk.
I think youāve managed to hijack @877ās thread and turn it from a general discussion about bridging and the use of MQTT versus Bly k Bridge into something thatās a much more detailed statement of requirements for your specific project.
Iām not saying that this isnāt a valid topic for discussion, and the problems youāve encountered will certainly apply to other commercial situations, but Iām not sure that this is the bets place to have it.
I have no issues hard-coding MQTT server credentials for my domestic situation, and have no reason to implement OAuth 2.0 tokens. Implementing a fully automated OAuth 2.0 dynamic provisioning system, alongside an automated Blynk dynamic provisioning system is quite a big step forward in terms of required development.
From all the āā, I think @877 enjoyed the discussion. Hopefully, it gave him some insight into how MQTT could be used to solve his use-case and some insight into related (planned) Blynk features.
Pick a good title and move the relevant posts into a new topic, then we (AKA you two ) can debate the best way to do things while I troglodyte my way with Bridge
Thanks @PeteKnight being considerate as usual . Although the thread has gone a little off topic, I really donāt mind. I would like to learn more but your discussion is a little over my head.
On the plus side I think I have the bridge working