Many equal devices running equal code

Hello, I use several Esp8266 ( 12 ) with DHT Sensors to measure temperature and humidity. On each ESP the same code is running. With help of an index read buy the Internet I control the column to store the data in an array. How to use Blynk to generate an App with many Widgets ( gauges ) and running the same Code on every ESP ? Virtualwrite( Index, Value ) possible ?

Have you tried Device Tiles?

I have that with 7 devices all running the same code. They have to be distinguised somehow though, so they all need a unique name and a unique token. So the start of my code for those devices looks like this:

#define ROOM 2									  // UPDATE PER ROOM 

#if ROOM == 1
  char ESP_NAME[]             = "ESP_THM_LIVING";
  char auth[]                 = auth_T_LIVING;    // assign correct token number, stored in W42 header
  float TCalibration     = -1.2;                  // correction on displayed T
#endif
#if ROOM == 2
  char ESP_NAME[]             = "ESP_THM_STUDY";
  char auth[]                 = auth_T_STUDY; 
  float TCalibration     = -1.2;                  // correction on displayed T
#endif
#if ROOM == 3
etc.

then for every unit firmware I only need to change the “room 2” into “room 3” etc.
in blynk you should indeed use device tiles. It requires a bit of tinkering as there’s little documentation around, but it works like a charm

Thanks Rolph ! I wanted to try the same. But I dont understand why to use different tokens ? Is it not possible to use different virtual pins ? Did you try it ? Do you have any documentations about device tiles ?
Thanks
Klaus-Dieter from Germany

If you use a different token for each device then the Blynk online/offline status indicator at the top of the screen will give you accurate info about each device, including how long that device has been online or offline.
It also allows you to use device tiles, with one device for each tile, to display your data.

If you use the same token on multiple devices the you lose all of this.

Using the same token with different virtual pins requires more programming changes to be made to the code for each device.

I’m a great fan of OTA updating for ESP devices, and I also like to assign static IP addresses to my devices.
To make OTA work well, each device needs a unique OTA name, so I’d have a section of code at the top of the sketch that defines:

  • Auth Code
  • OTA Name
  • IP Address

Change these for each device, but the rest of the code can be identical.

Pete.

1 Like

It’s just a correct approach to use different tokens. Otherwise, many things can go wrong.

Using different virtual pins is ok, but it’s more of a hack. And while it may work for certain applications, it’s considered to be a bad practise.

Also, if you use different virtual pins, it’s already a different code which is way harder to manage than one line of a token.

also you cannot use the device tiles if you only have one token. the idea of the DT is that you create a number you need so in your case 3x4, then press the bolt (setup) of the DT and set it up like one interface, then select the 12 devices and youll have 12 tiles all with that one interface.

I understood the informations about BLynk that a Token is specific for a project. Is that correct ? Your suggestion I understand as one project. How to generate several tokens for one project ? Or is a token tied to a device and can be used in several projects.

Auth tokens are device specific, within the project… so even two identical projects cannot alternate between the same devices as they would all have different AUTH tokens.

The tokens are generated and tracked by the server, so while you can copy paste tokens in the devices, you cannot manually edit then in the App.

Now I m confused. How to generate tokens.
Example : using 2 esp8266 to display 2 temperatures in one project . How do I generate the tokens and how do I connect the device to the Display Widget ? Any detailled descrption ? Thanks.

You add a device in the App… the server generates the token and emails it to you… as documented in all those links at the top right of this page :wink: (scroll up)

http://help.blynk.cc/getting-started-library-auth-token-code-examples/getting-started

It’s simple. Stop the app with the square button in the top right hand corner. The “Nut” icon will appear, click it.
Scroll down to Devices and add another device. The new device will have a unique Auth code, e-mail this to yourself.

In the widget setup, when you have more than one device in a project you’ll see “Target”. Choose the device that you want the widget to be linked to.

Pete.