dummy Octal

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

dummy Octal

#1 Post by rayE » 17 Mar 2019, 12:55

Hi All,
Iv been using send to HTTP to send all 8 variables to Thingspeak (TS). Iv noticed there are a quite a few occasions when the data does not get to TS even though pinging TS says it is OK. My send data rate is every 30S. I just started to use the TS controller BUT it seems you cannot send all 8 data fields back in one go from 2 quad dummy variables. So i am attempting to make my own Octal dummy (8 variables).

Although this seems to work and will update all 8 fields on TS in one send with a MUCH better error rate than sendtoHTTP there are issues.

1. I update the 8 values in rules with values 10 to 80 (for test purposes) using the following code. Looking at debug window and the devices window the values are correct and correctly sent to TS. The problem is the variable names cannot be correctly set when i edit the device, it seems that the last 4 variables can have names but not the first 4 (not shown in the screen shot).

Code: Select all

TaskValueSet 3,1,10
   TaskValueSet 3,2,20 
   TaskValueSet 3,3,30
   TaskValueSet 3,4,40
   TaskValueSet 3,5,50
   TaskValueSet 3,6,60  	  
   TaskValueSet 3,7,70
   TaskValueSet 3,8,80  
Device screen grab.
device screen
device screen
devices.jpg (94.09 KiB) Viewed 3623 times
Here is my plugin code (i started with P033 and went form there)

Code: Select all

#ifdef USES_P130
//#######################################################################################################
//#################################### Plugin 130: Octal Dummy ##########################################
//#######################################################################################################

#define PLUGIN_130
#define PLUGIN_ID_130         130
#define PLUGIN_NAME_130         "OctalDummy Device"
#define PLUGIN_VALUENAME1_8     "Octal Dummy"
boolean Plugin_130(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_130;
        Device[deviceCount].Type = DEVICE_TYPE_DUMMY;
        Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].DecimalsOnly = true;
        Device[deviceCount].ValueCount = 8;
        Device[deviceCount].SendDataOption = true;
        Device[deviceCount].TimerOption = true;
        Device[deviceCount].GlobalSyncOption = true;
        break;
      }

    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_130);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_8));
        break;
      }

    case PLUGIN_WEBFORM_LOAD:
      {
        byte choice = PCONFIG(0);
        String options[1];                           //RAE
        options[0] = F("SENSOR_TYPE_OCTAL");         //RAE

        int optionValues[11];                         //RAE
        optionValues[0] = SENSOR_TYPE_OCTAL;         //RAE

        addFormSelector(F("Simulate Data Type"), F("p130_sensortype"), 1, options, optionValues, choice );   //RAE

        success = true;
        break;
      }

    case PLUGIN_WEBFORM_SAVE:
      {
        PCONFIG(0) = getFormItemInt(F("p130_sensortype"));
        success = true;
        break;
      }

    case PLUGIN_READ:
      {
        event->sensorType = PCONFIG(0);
        for (byte x=0; x<8;x++)   //RAE
        {
          String log = F("Dummy: value ");
          log += x+1;
          log += F(": ");
          log += UserVar[event->BaseVarIndex+x];
          addLog(LOG_LEVEL_INFO,log);
        }
        success = true;
        break;
      }
  }
  return success;
}
#endif // USES_P130
Other changes iv made elsewhere in the framework are listed.

Change in Cplugin_sensortype_helper.ino (added SENSOR_TYPE_OCTAL in switch statement)

Code: Select all

switch (sensorType)

  {

    case SENSOR_TYPE_NONE:

      return 0;

    case SENSOR_TYPE_SINGLE: // single value sensor, used for Dallas, BH1750, etc

    case SENSOR_TYPE_SWITCH:

    case SENSOR_TYPE_DIMMER:

      return 1;

    case SENSOR_TYPE_LONG:   // single LONG value, stored in two floats (rfid tags)

      return 1;

    case SENSOR_TYPE_TEMP_HUM:

    case SENSOR_TYPE_TEMP_BARO:

    case SENSOR_TYPE_DUAL:

      return 2;

    case SENSOR_TYPE_TEMP_HUM_BARO:

    case SENSOR_TYPE_TEMP_EMPTY_BARO: // Values 1 and 3 will contain data.

    case SENSOR_TYPE_TRIPLE:

    case SENSOR_TYPE_WIND:

      return 3;

    case SENSOR_TYPE_QUAD:

      return 4;

    case SENSOR_TYPE_OCTAL:     //RAE

      return 8;

  }
Added this define in ESPeasyGlobals.h

Code: Select all

#define SENSOR_TYPE_OCTAL                  30   //RAE
 
TIA
Ray

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: dummy Octal

#2 Post by rayE » 18 Mar 2019, 02:20

OK, so woke with a fresh head today and found 2 things.
1. Problem in plugin code (updated code below)
2. This line in Globals.h (changed from 4 to 8)

Code: Select all

//#define VARS_PER_TASK                       4
#define VARS_PER_TASK                       8   //RAE
All appears to be running OK, system details looks very similar to before i added the Octal plugin.

Code: Select all

System Info	Copy info to clipboard (⋄)
Unit:	0
Local Time:	1970-01-01 00:00:24
Uptime:	0 days 0 hours 0 minutes
Load:	51.40% (LC=39)
Free Mem:	25288 (23880 - sendContentBlocking)
Free Stack:	3616 (1708 - LoadTaskSettings)
Boot:	Manual reboot (7)
Reset Reason:	Power on
Network ❔
Wifi:	802.11N (RSSI -74 dB)
IP config:	Static
IP / subnet:	192.168.3.150 / 255.255.255.0
GW:	192.168.3.1
Client IP:	192.168.3.6
DNS:	8.8.8.8 / (IP unset)
Allowed IP Range:	All Allowed
STA MAC:	68:C6:3A:95:74:D9
AP MAC:	6A:C6:3A:95:74:D9
SSID:	BA_Front (C8:3A:35:11:93:78)
Channel:	7
Connected:	21 s
Last Disconnect Reason:	(1) Unspecified
Number reconnects:	0
Firmware
Build:⋄	20103 - Mega
Libraries:⋄	ESP82xx Core 2_5_0_BETA2, NONOS SDK 3.0.0-dev(c0f7b44), LWIP: 2.1.2
GIT version:⋄	(custom)
Plugins:⋄	7 [Sonoff POW R1/R2]
Build time:⋄	Mar 18 2019 07:39:21
Binary filename:⋄	Self built!
System Status
Syslog Log Level:	None
Serial Log Level:	None
Web Log Level:	None
ESP board
ESP Chip ID:	9794777 (0x9574D9)
ESP Chip Freq:	80 MHz
ESP Board Name:	ESP8266_GENERIC
Storage
Flash Chip ID:	Vendor: 0xEF Device: 0x4016
Flash Chip Real Size:	4096 kB
Flash IDE Size:	4096 kB
Flash IDE speed:	40 MHz
Flash IDE mode:	DOUT
Flash Writes:	20 daily / 20 boot
Sketch Size:	614 kB (2456 kB free)
SPIFFS Size:	934 kB (856 kB free)
Here is the plugin code that allows me to use the Thingspeak controller and post all 8 fields in one go.

Code: Select all

#ifdef USES_P130
//#######################################################################################################
//#################################### Plugin 130: Octal Dummy ##########################################
//#######################################################################################################

#define PLUGIN_130
#define PLUGIN_ID_130         130
#define PLUGIN_NAME_130         "OctalDummy Device"
#define PLUGIN_VALUENAME1_8     "Octal Dummy"
boolean Plugin_130(byte function, struct EventStruct *event, String& string)
{
  boolean success = false;

  switch (function)
  {

    case PLUGIN_DEVICE_ADD:
      {
        Device[++deviceCount].Number = PLUGIN_ID_130;
        Device[deviceCount].Type = DEVICE_TYPE_DUMMY;
        Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
        Device[deviceCount].Ports = 0;
        Device[deviceCount].PullUpOption = false;
        Device[deviceCount].InverseLogicOption = false;
        Device[deviceCount].FormulaOption = false;
        Device[deviceCount].DecimalsOnly = true;
        Device[deviceCount].ValueCount = 8;
        Device[deviceCount].SendDataOption = true;
        Device[deviceCount].TimerOption = true;
        Device[deviceCount].GlobalSyncOption = true;
        break;
      }

    case PLUGIN_GET_DEVICENAME:
      {
        string = F(PLUGIN_NAME_130);
        break;
      }

    case PLUGIN_GET_DEVICEVALUENAMES:
      {
        strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_8));
        break;
      }

    case PLUGIN_WEBFORM_LOAD:
      {
        byte choice = PCONFIG(0);
        String options[1];                           //RAE
        options[0] = F("SENSOR_TYPE_OCTAL");         //RAE

        int optionValues[1];                         //RAE
        optionValues[0] = SENSOR_TYPE_OCTAL;         //RAE

        addFormSelector(F("Simulate Data Type"), F("p130_sensortype"), 1, options, optionValues, choice );   //RAE

        success = true;
        break;
      }

    case PLUGIN_WEBFORM_SAVE:
      {
        PCONFIG(0) = getFormItemInt(F("p130_sensortype"));
        success = true;
        break;
      }

    case PLUGIN_READ:
      {
        event->sensorType = PCONFIG(0);
        for (byte x=0; x<8;x++)   //RAE
        {
          String log = F("Dummy: value ");
          log += x+1;
          log += F(": ");
          log += UserVar[event->BaseVarIndex+x];
          addLog(LOG_LEVEL_INFO,log);
        }
        success = true;
        break;
      }
  }
  return success;
}
#endif // USES_P130
One other thing i did was to upload the blank bin files onto the ESP then install the new bin, there seemed to be some "left over stuff" that affected existing quad variable names, cleaning it out and reinstalling the new firmware got rid of these problems.

I will let this run for a few days and make sure nothing "nasty" happens as i don't realy know what im doing :-/

The unit is sending data to two different TS channels at 30 second intervals. One channel uses the sendtoHTTP method and the second channel uses the Thingspeak controller which from observation looks MUCH better with less data losses. Here is the channel that uses TS controller to put the data.
https://thingspeak.com/channels/731899

Cheers
Ray

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: dummy Octal

#3 Post by grovkillen » 19 Mar 2019, 11:08

I'm not understanding what you're trying to achieve here. The increased numbers of values will affect the other tasks so in a sense you're not really gaining anything. Have you tried adding devices to all tasks? Will your hack still work?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: dummy Octal

#4 Post by rayE » 19 Mar 2019, 14:56

Maybe im misunderstanding something here from my tests...............If i have 1 or more device's (quad dummy variables) sending data to a controller like Thingspeak then the first device seems to has a priority over the other devices i.e the other devices do NOT transmit their variable data in ONE send to the controller. What i want to achieve is to send ALL 8 data fields in one go. Am i missing something here?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: dummy Octal

#5 Post by grovkillen » 19 Mar 2019, 15:32

Aha, thingspeak doesnt allow for for multiple sending you mean? Well, that is something that the controller should take care of, not use a dummy for it. Please open a issue on GitHub. We should make the controller buffer all the values it should send and then send them once the buffer is filled.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Jedrunia
Normal user
Posts: 12
Joined: 28 Mar 2019, 09:22

Re: dummy Octal

#6 Post by Jedrunia » 07 Apr 2019, 23:42

Hello,

As a workaround, I suggest using rules:

on <trigger> do
SendToHTTP api.thingspeak.com,80,/update?api_key=xxxx&field1=%rssi%&field2=2&field3=[BMP#Temperature]&field4=[BMP#Pressure]&field5=[Akku#Analog]
endon

where the <trigger> is the last event in one data collecting cycle for ThingSpeak.

For example, task number 12 measure the battery voltage and save it in [Akku#Analog] -> Rules should start like this:

on Akku#Analog do
SendToHTTP api.things......
endon

Task 12 refreshed >15 sec. to receive all messages send to ThingSpeak

You don't need to use any DummyDevice

Regards
Andrzej

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests