IoT Octopus : send data using Blynk

Blynk is another way of sending and visualising data, from the Octopus, besides using Thingsspeak. To use Blynk, one needs to register with Blynk and download the Blynk app (available on iOS and Android).

Set up a remote sensing device on Blynk

To set up a data transmitting device on Blynk, one needs to do the following:

From the Blynk app :
– Open the Blynk app on your smartphone.
– Click on “new project”.
– Choose “esp8266” for the “choose device” question.
– Wait for the “Auth Token” email that Blynk has sent.

(then) In ArduBlocks :
– In the Setup part of your ArduBlocks sketch, add aWLAN block and a Blynk-Cloud block.
– In the WLAN block : specify the name of your wifi network and the password.
– In the Blynk-Cloud block : the Copy the Auth Token from the Blynk email, and paste it into the API-Key part of the ArduBlocks Blynk-Cloud block.

(more) in ArduBlocks :
– In the loop part of the ArduBocks sketch, add a Blynk-VirtualWrite block.
– In the Pin part of the block, specify by which Pin a sent value is referred to.
– In the “Value”/”Wert” part of the Blynk-VirtualWrite block, specify the variable to be sent to the Blynk app on your smartphone, as well as the Pin number that identifies this variable.
(if you’d like to send different variables, you can add more Blynk-VirtualWrite blocks, though with a different Pin for each block and variable one wants to send).

And another note regarding the ArduBlocks sketch. Save/set the sensor reading as a variable, rather than read it anew, creating slowdowns, every time it is used. For instance, rather than read the sensor value when it is printed to the serial and then again when it is written to the Blynk-VirtualWrite and sent with Blynk, save it as a variable, and you can simply use the variable in subsequent programming blocks needing the sensor value.

The “Set Number-Variable” block is in fact a very handy thing. This allows one to create a variable based on some value – eg. a sensor reading, or a calculated value. This way one could for instance have a variable loop Delay (ie Wait) time, depending on the sensor value.
One needs to set the variable before one uses it. Thus the “Set Number-Variable” block needs to be above the blocks where the variable is (later) used. 

Set up the Blynk app itself :

  • Go to “new project”
  • Long press on the black area.
  • This opens an area with a great many display options.
    (alas, some of the options require buying, to be used 🙁 )
  • To be economical, I’ve selected to use a “Value display”. 
    • This is inserted on the top left. 
    • You can access the display’s options by tapping it. 
    • You can set a title, eg “IAQ”. 
    • For the “Input”, select the PIN of the ArduBlocks variable you would like to show.
    • Turn the average to “virtual” and set the pin to V1.
  • “Refresh interval”. Set this to “push”.
    • The two values next to the Pin is the value range of the display. Since the IAQ value can go up to 200, I’ve set the top value as 200.
      These values are perhaps not that important to set for a display that has a numeric readout, such as we’re using here. However, if one uses a line-/bar-chart or a circular chart, then it’s important to specify the expected value range, as this will set the visual scale of the displayed data.

To get things going, simply press the triangle on the top right of your mobile’s Blynk app window, and Blynk should receive and show incoming data values.

What a finished IAQ overview can look like in the Blynk app

Find the Blynk documentation here

The Arduino text code, for the Octopus part, looks like this:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <bsec.h>
#include <Wire.h>
#include <Ticker.h>
String matrixausgabe_text  = " "; // Ausgabetext als globale Variable
volatile int matrixausgabe_index = 0;// aktuelle Position in Matrix
IPAddress myOwnIP; // ownIP for mDNS 
int IAQ = 0 ;
 Bosch BSEC Lib,
 The BSEC software is only available for download or use after accepting the software license agreement.
 By using this library, you have agreed to the terms of the license agreement: */
Bsec iaqSensor;     // Create an object of the class Bsec 
Ticker Bsec_Ticker; // schedule cyclic update via Ticker 
// ------------------------   Helper functions Bosch Bsec - Lib 
void checkIaqSensorStatus(void)
  String output; 
  if (iaqSensor.status != BSEC_OK) {
    if (iaqSensor.status < BSEC_OK) {
      output = "BSEC error code : " + String(iaqSensor.status);
      for (;;) {
      } // Halt in case of failure 
    else {
      output = "BSEC warning code : " + String(iaqSensor.status);
  if (iaqSensor.bme680Status != BME680_OK) {
    if (iaqSensor.bme680Status < BME680_OK) {
      output = "BME680 error code : " + String(iaqSensor.bme680Status);
      for (;;){
      }  // Halt in case of failure 
    else {
      output = "BME680 warning code : " + String(iaqSensor.bme680Status);
// Housekeeping: scheduled update using ticker-lib
void iaqSensor_Housekeeping(){  // get new data;
void setup(){ // Einmalige Initialisierung
  Wire.begin(); // ---- Initialisiere den I2C-Bus 
  iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
  String output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
  bsec_virtual_sensor_t sensorList[10] = {
  iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);
  Bsec_Ticker.attach_ms(3000, iaqSensor_Housekeeping);
  //------------ WLAN initialisieren 
  Serial.print ("\nWLAN connect to:");
  while (WiFi.status() != WL_CONNECTED) { // Warte bis Verbindung steht 
  Serial.println ("\nconnected, meine IP:"+ WiFi.localIP().toString());
  matrixausgabe_text = " Meine IP:" + WiFi.localIP().toString();
  myOwnIP = WiFi.localIP();
  Blynk.config("SZ2mHs8Dk3poz6mbxC3BBeh4cgIH7DLb","",80);// Downloads, docs, tutorials:
  int BlynkCon = 0;
  while (BlynkCon == 0) {
    Serial.print ("\nBlynk connect ... ");
    if (BlynkCon == 0) {
      Serial.println("failed, try again");
void loop() { // Kontinuierliche Wiederholung;// Blynk Housekeeping
  IAQ = iaqSensor.iaq ;
  Blynk.virtualWrite(1,IAQ);// Wert an Blynk-Server übermitteln;// Blynk Housekeeping
  delay( 5000 );

More Octopus tutorials :

  • Connect the Octopus with the internet and transfer data.
  • Octopus and MacOS
  • Send data from the Octopus, with Thingspeak.