I tried the latest type of “Telegram send message” endpoints, but I didn’t get the notification like it should. can someone help me to solve this problem?
#include <ThingerESP8266.h>
#include <DHT.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#define USERNAME "xx"
#define DEVICE_ID "xx"
#define DEVICE_CREDENTIAL "xx"
#define SSID "Setsu"
#define SSID_PASSWORD "12345678"
static const int RXPin = 4, TXPin = 5; // GPIO 4=D2(conneect Tx of GPS) and GPIO 5=D1(Connect Rx of GPS
static const uint32_t GPSBaud = 9600;
int vs= D0;
TinyGPSPlus gps; // The TinyGPS++ object
SoftwareSerial ss(RXPin, TXPin);
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
#define DHTPIN 0 // What digital pin we're connected to
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
float t,h;
void setup() {
//pinMode(LED_BUILTIN, OUTPUT);
dht.begin();
ss.begin(GPSBaud);
pinMode(vs, INPUT);
thing.add_wifi(SSID, SSID_PASSWORD);
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
//thing["led"] << digitalPin(LED_BUILTIN);
// DHT11 Sensor
//thing["Suhu"] >> outputValue(dht.readTemperature());
//thing["Humd"] >> outputValue(dht.readHumidity());
thing["DHT11"] >> [](pson& out){
out["Suhu"] = dht.readTemperature();
out["Humd"] = dht.readHumidity();
};
//vibrate sensor
thing["getar"] >> outputValue(vibration());
}
unsigned long lastCheck = 0;
void loop() {
while (ss.available() > 0)
{
// sketch displays information every time a new sentence is correctly encoded.
if (gps.encode(ss.read()))
displayInfo();
}
thing.handle();
unsigned long currentTs = millis();
if(currentTs-lastCheck>=1*60*1000){
lastCheck = currentTs;
if(dht.readTemperature()>30){
thing.call_endpoint("high_temp_telegram");
}
}
}
void displayInfo()
{
if (gps.location.isValid() )
{
thing["location"] >> [](pson& out){
out["lat"] = gps.location.lat();
out["lon"] = gps.location.lng();
};
}
Serial.println();
}
long vibration(){
long data=pulseIn(vs, HIGH);
return data;
}
