DFRobot wifi Tel0126 and IFTTT

Hello,
I am recording Temp and Humidity inside my greenhouse and water temp in my tank using UNO+DHT11+DS18S20.
Trying to use Tel0126 (DFRobot wifi) to send the data to IFTTT at my request when I press a button.
I followed the example from DFRobot website #Project 3-Temperature Sending (Based on IFTTT) but somehow it didn’t work. Most likely because of my poor skill and understanding of the library that comes with Tel0126.
https://wiki.dfrobot.com/WiFi_IoT_Module_SKU_TEL0126#target_6

Attached are zip of the ino file and the library .h and .cpp files.
Temp.zip (10.7 KB)

Any advise/help is much appreciated.

Thanks.

Hi Tien,

I suggest breaking your project down into smaller bits first, generally forums are good at solving specific problems, rather than debugging monolithic systems.

  • Have you established your DS18B20 works? Make up a small sketch to print the recorded temperatures to serial. Same goes for the DHT11
  • Have you established that the WiFi works? Maybe confirm you can connect to an AP correctly, and say, ping www.google.com
  • Have you established your IFTTT works? Make up a small sketch to send a test message to IFTTT and see if it comes up on your dashboard/inbox

Let us know what problems occur in the above, and we’ll try our best to get you past them.

1 Like

Hello James,

  1. The DHT11 and DS80 working fine.
  2. WIFI was connected. TEL0126 ok.
  3. IFTTT was not sure. The main issue is TEL0126 comes with its own library. So it doesn’t have the common esp32 library such as wificlientsecure.h. or wificlient.h for esp8266. I am not a programmer so have no idea how to program and ask the TEL0126 library to send the data out to get IFTTT to work. So maybe someone out there knows how to or has successfully using TEL0126 to work in IFTTT?

The example code is using ESP8266 or esp32 to get IFTTT to work. There isnt much examples out there using TEL0126.

Thanks.

Hi Tien,

What error message did you get when you tried to run the sample code included in Project 3-Temperature Sending (Based on IFTTT)?

If you don’t worry about the DHT11 and DS80 and just try to run the excerpt of sample code provided that might tell us more about what part of the IFTTT side isn’t working. You can put those parts back into the code once you’ve determined all 3 sections work independently.

The temperature sensor included in the example is just an analog sensor, so even if the sensor isn’t connected you should still get a number read (whatever voltage the analog pin is floating at).

Hello Trent,
I ‘tried’ to study the code in the library associated with this wifi module from DFRobot and made some changes in my arduino codes.

The error msg was memory allocation failed? And after that, it sort of ‘fudge’ my serial monitor data???

15:53:34.031 → [getWifiState(): 419 ] WIFI SUCCESS CON
15:53:34.031 → Wifi Connect Success
15:53:34.031 → [writeReg(): 669 ] D
15:53:34.031 → HTTP Configuration Succeeded
15:53:34.031 → IFTTT Configuration Succeeded
15:53:45.665 → DHT T:22.00 DHT H:17.00 Water T:0.00
15:53:45.665 → [IFTTTSendMessage(): 619 ] trigger/Notify/with/key/
15:53:45.665 → memory allocation failed
15:54:00.684 → memory allocation failedData sending timeout
15:54:15.707 → DHT T:22.00A⸮26.00|aaaa0.00
15:54:15.754 → DHT T:22.00A⸮26.00|aaaa0.00

I think it is the codes in the library, which I am too amateur to edit unfortunately. :sweat_smile:

{
  uint8_t recvHTTPData[1000];
  String sendData = ""; 
  sendData += "{\"value1\":\"";
  sendData += data1;
  sendData += "\",\"value2\":\"";
  sendData += data2;
  sendData += "\",\"value3\":\"";
  sendData += data3;
  sendData += "\" }\r";
  String url = "";
  url += "trigger/";
  url += _iftttevent;
  url += "/with/key/";
  url += _iftttkey;
  
  String ur2 = "";
  ur2 += url;
  ur2 += ',';
  ur2 += sendData;
  DBG(url);
  manageFunction(IOT_RUN_COMMAND,HTTP_POST_URL_CON,(char*)ur2.c_str(),ur2.length());
  uint8_t state = parameterReturn(HTTP_NORMAL_RETURN, HTTP_ERROR_RETURN, &recvHTTPData[0]);
  if(state == 0){
    return 0;
  }
  return 1;
}```

[Temp.zip|attachment](upload://pIJzjDkQbnVXrfCyI9JG7ymwDg0.zip) (10.7 KB)

Hi Tien,

Just wanted to clarify, have you tried running just the sample code, with no changes?

Code integration is always the hardest part so we need to confirm if this is a problem with the sample code itself, or the way the sample code runs when it includes the changes you’ve made to add your two sensors.

Hello Trent,
I coded mine using the sample code. Still no data (DHT temp, humidity, DS18 Temp). Able to get email from IFTTT when “EventName” triggered.

The DFRobot website, using Value1, Value2, Value3,
image

In my IFTTT,

The email was only showing this but not the actual data,

Still don’t know what’s went wrong with regards to as how to paste the 3 data into IFTTT JsonPayLoad format from the Tel0126 library???

#include "DFRobot_WiFi_IoT_Module.h"
#include <SoftwareSerial.h>
#include <dht.h>
#include <OneWire.h>   //ds18b20
#define  DHTPin 8
String msg;
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
dht DHT;
float TemperatureSum, TDHT11, HDHT11;
int button = 4;
OneWire ds(DS18S20_Pin);  // on digital pin 2
//UART mode
//Use software serialport: D/R: 10, C/T: 11
SoftwareSerial    mySerial(10, 11);
DFRobot_WiFi_IoT_Module_UART IoT(&mySerial);

//Configure WiFi name and password
const char *WIFI_SSID           = "XXX";
const char *WIFI_PASSWORD       = "xxx";
//Configure IFTTT
const char *IFTTT_ADDRESS       = "maker.ifttt.com";
const char *IFTTT_ENVENT        = "NotifySL";
const char *IFTTT_KEY           = "xxx";
//IFTTT Send message
const char *IFTTT_VALUE_1       = "Value1";
const char *IFTTT_VALUE_2       = "Value2";
const char *IFTTT_VALUE_3       = "Value3";

void setup() {
  //Use software serialport 9600 as communication port
  mySerial.begin(9600);
  //Use serialport 115200 as print port
  Serial.begin(115200);
  //Init communication port
  while (IoT.begin() != 0) {
    Serial.println("init ERROR!!!!");
    delay(100);
  }
  Serial.println("init Success");
  //Connect to WiFi
  while (IoT.connectWifi(WIFI_SSID, WIFI_PASSWORD) != 0) {
    Serial.print(".");
    delay(100);
  }
  Serial.println("Wifi Connect Success");
  //Init HTTP
  while (IoT.HTTPBegin(IFTTT_ADDRESS) != 0) {
    Serial.println("Parameter is empty!");
    delay(100);
  }
  Serial.println("HTTP Configuration Succeeded");
  //Init IFTTT
  while (IoT.IFTTTBegin(IFTTT_ENVENT, IFTTT_KEY) != 0) {
    Serial.println("Parameter is empty!");
    delay(100);
  }
  Serial.println("IFTTT Configuration Succeeded");

  pinMode(button, INPUT);
}

void loop() {
  String data1 = (String)DHTT();
  String data2 = (String)DHTH();;
  String data3 = (String)getTemp();
  //Serial.println(data1);
  //Serial.println(data2);
  //Serial.println(data3);

  if (digitalRead(4) == 1)
  {
    IoT.IFTTTSendMessage(data1.c_str(), data2.c_str(), data3.c_str());
    Serial.println("send message success!");
  }
}

float DHTT() {
  int readData = DHT.read11(DHTPin); // DHT11
  float value1 = DHT.temperature;
  return value1;
}

float DHTH() {
  int readData = DHT.read11(DHTPin); // DHT11
  float value2 = DHT.humidity;
  return value2;
}

float getTemp() {
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
    //no more sensors on chain, reset search
    ds.reset_search();
    return -1000;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
    Serial.println("CRC is not valid!");
    return -1000;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
    Serial.print("Device is not recognized");
    return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);
  ds.write(0xBE); // Read Scratchpad


  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }

  ds.reset_search();

  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;

  return TemperatureSum;
}

I think it’s better to use an ESP32 instead of Arduino UNO.You can send Sensor Readings to Google Sheet Through IFTTT using ESP32. That will be easier.

To Rooppoor,
I bought 2 Tel0126 thinking it would work with my UNO/Mega. Plus the DFRobot expansion shields too. LOL. Just trying to get them to work before spending more money. Their website ‘shows’ it will work on IFTTT! :sweat_smile: :thinking: :face_with_spiral_eyes:

I also visited DFRobot support forum but can’t find any past solutions? No reply from the tech support too?

Hello all,
I have made some progress but still unable to figure out what was the reason?

Case A has the full string output according to the DFRobot library but unable to get any response from IFTTT.

Case B has the data missing in the string but able to get IFTTT to respond but without the much needed data! Just another serial monitor output added base on the sample code from the DFRobot website example.

Case A:

void loop() {
  String dat1 = (String)DHTT();
  String dat2 = (String)DHTH();;
  String dat3 = (String)getTemp();
  
  if (digitalRead(4) == 1)
  {
    IoT.IFTTTSendMessage(dat1.c_str(),dat2.c_str(),dat3.c_str());
     }
}

Serial monitor:

[HTTPPost(): 318 ] |3|2|http://maker.ifttt.com/trigger/NotifySL/with/key/dcr-dTl2FnydMtJE4OpnBp,{"value1":"23.00","value2":"25.00","value3":"23.69"}

IFTTT = No notification or email sent

Case B:

void loop() {
  String dat1 = (String)DHTT();
  String dat2 = (String)DHTH();;
  String dat3 = (String)getTemp();
  
  if (digitalRead(4) == 1)
  {
    IoT.IFTTTSendMessage(dat1.c_str(),dat2.c_str(),dat3.c_str());
    Serial.println("send message success!");
     }
}

Serial monitor:

16:00:55.242 -> [HTTPPost(): 318 ] |3|2|http://maker.ifttt.com/trigger/NotifySL/with/key/dcr-dTl2FnydMtJE4OpnBp,|
16:00:57.835 -> [receiveData(): 1161 ] 6
16:00:58.127 -> [receiveData(): 1171 ] |3|200|Congratulations! 
16:00:59.116 -> send message success!

IFTTT = Yes. notification or email sent but no data({“value1”:“23.00”,“value2”:“25.00”,“value3”:“23.69”})

You can try to simplify the code and sending test values to IFTTT to help identify any issues with the data formatting or transmission.

Just suggesting someone switch platforms when their current platform also has guides suggesting it’ll work is not constructive. It’s true that the ESP32 is a faster, more network-oriented platform, but not without it’s own suite of quirks and issues.

@Tien191618, I’m unsure why one of those works, and one doesn’t as they both have the same functional code except for the print statement. You could try adding a significant delay to the one without the serial print, as your send function may fire many times while you have the button pressed. I’ve also edited your post to add code formatting, please do this in future as it’s near impossible to read otherwise.

image

What happens when you just send, say, "A" "B" and "C" as dat1 dat2 and dat3? does that work? There may be some errors with all the data conversions and casting you are doing.

Keen to see if you get anywhere :slight_smile:

Hello James,
I tried ABC but results were same. Same with having a delay from 100 to 20000.

Just wondering if the reason the JSON data unable to show was due to changes made on IFTTT?

Some old search online, the {{Value1}}, {{Value2}}, {{Value3}}, which was the coding used in the DFRobot library. But nowadays IFTTT has changed into JsonPayload. I wonder if this was the issue that data was not parsed?

Preformatted textimage

New IFTTT format
Preformatted textimage

Thanks mate

All,
This is beyond me, unfortunately have to abandon this TEL0126. Disappointing that bought it thinking it would work as per its example on their website. Just no help from DFRobot tech support.

Hi Tien
I don’t know anything about what you are trying to do but I did notice something.

Is there any reason for the two “;” at the end. Could this be fouling something up???
Cheers Bob

Hi Robert,
It has been fixed while compiling. Just a feeling that the library somehow

  1. unable to ‘join’ the URL and Data string and then send to IFTTT
  2. able to ‘join’ the URL and Data string and failed to send to IFTTT

No idea. Gave up…
Thanks.

Hello All,
With the help of someone online, we managed to get TEL0126 working with IFTTT.
Recap here in case someone had the same issue,

  • Select Webhooks (Receive a web request) with value1, value2, and value3, not Receive a web request with JSONpayload.

  • Create function () and use void loop () to call the function(s)

  • Function(s) return value as string only

  • Don’t Serial.print if possible. It seems to do funny thing with the full string generated by the library itself. Sometimes, the whole string may not appeared? Timing?

  • No need to put any delay(); Same as above. Best to leave as it is. Call the function and let the TEL0126 library does its thing.

  • http[TEL0126] or https [in the IFTTT] doesn’t seem to a problem.

Thanks all.

2 Likes