# Complete project details at https://RandomNerdTutorials.com/micropython-whatsapp-esp32-esp826/
try:
import urequests as requests
except:
import requests
import network
import esp
esp.osdebug(None)
import gc
gc.collect()
#Your network credentials
ssid = 'AP-LFU'
password = 'ligafederal'
#Your phone number in international format
phone_number = '+5411'
#Your callmebot API key
api_key = ''
def connect_wifi(ssid, password):
#Connect to your network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect(ssid, password)
while station.isconnected() == False:
pass
print('Connection successful')
print(station.ifconfig())
def send_message(phone_number, api_key, message):
#set your host URL
url = 'https://api.callmebot.com/whatsapp.php?phone='+phone_number+'&text='+message+'&apikey='+api_key
#make the request
response = requests.get(url)
#check if it was successful
if response.status_code == 200:
print('Success!')
else:
print('Error')
print(response.text)
# Connect to WiFi
connect_wifi(ssid, password)
# Send message to WhatsApp "Hello"
message = 'Hello%20from%20ESP32%20%28micropython-prueba-para-ritmo_cardiaco%29' #YOUR MESSAGE HERE (URL ENCODED)https://www.urlencoder.io/
send_message(phone_number, api_key, message)