To measure water levels in a tank I use an ESP32 in combination with an ultrasonic level meter. The ESP is set with an fixed IP address and connected to my local network. In an app on my tablet or computer I can connect with the ESP and read the measured values. Because the IP address of the ESP is fixed I always know which IP address to use. Also after a restart of the ESP.
For another project I translated the CallMeBot script (https://www.b4x.com/android/forum/t...atsapp-telegram-messenger-voice-calls.144892/) to B4R to be able to send a message to my WhatsApp. Also this works fine.
When I try to combine both projects I’m getting an error message when trying to send a WA message.
If I don't set a fixed IP address it works fine.
What am I missing or doing wrong?
For another project I translated the CallMeBot script (https://www.b4x.com/android/forum/t...atsapp-telegram-messenger-voice-calls.144892/) to B4R to be able to send a message to my WhatsApp. Also this works fine.
When I try to combine both projects I’m getting an error message when trying to send a WA message.
Error Message::
https://api.callmebot.com/whatsapp.php?phone=123456789012&text=Level+52+cm+Volume+548+ltr&apikey=1234567
trying to connect to: api.callmebot.com port: 443 ssl: 1
#########################################################
JobName: WaterTankLevel
ErrorMessage: Failed to connect
Status : 0
#########################################################
If I don't set a fixed IP address it works fine.
What am I missing or doing wrong?
Set Fixed IP address:
Sub SetUp_Fixed_IP_Adres
' Set Fixed IP Address
RunNative("Set_Fixed_IP",Null)
End Sub
#Region C_Code
#If C
void pulseins (B4R::Object* o) {
b4r_main::_pulseduration = pulseIn(o->toULong(),HIGH);
}
void Set_Fixed_IP(B4R::Object* o) {
Serial.println(" ");
Serial.println("#########################################################");
Serial.println(" Fixed IP address set on: ");
Serial.println(" 192.168.1.201 ");
Serial.println("#########################################################");
Serial.println(" ");
// IPAddress ip(192, 168, 1, XXX) ; XXX is desired IP
IPAddress ip(192, 168, 1, 201) ;
IPAddress gateway(192, 168, 1, 1) ;
IPAddress subnet(255, 255, 255, 0) ;
WiFi.config(ip,gateway,subnet) ;
}
#End if
#End Region
Send Message with the CallMeBot:
Sub Send_WA_Message_Alarm
Timers_Stop
Log(" ")
Log("#########################################################")
Log("Send WA message with level and volume")
Dim str_Send As String
str_Send = _
JoinStrings (Array As String( _
"https://api.callmebot.com/whatsapp.php?phone=123456789012&text=" , _
"Level+" , h_water , _
"+cm" , _
"+Volume+" , v_water , _
"+ltr" , _
"&apikey=1234567" ))
Log(str_Send)
Log(" ")
HttpJob.Initialize("WaterTankLevel")
HttpJob.Download(str_Send)
End Sub
Sub JobDone (Job As JobResult)
Log(" ")
Log("#########################################################")
Log("JobName: ", Job.JobName)
If Job.Success Then
Log("Succes")
Timers_Run
Else
Log("ErrorMessage: ", Job.ErrorMessage)
Log("Status : ", Job.Status)
Log(Job.Response)
Timers_Run
End If
Log("#########################################################")
End Sub