Shahariar
Published © CC BY

PSoC6: Sending IoT Push Notifications: WiFi with MicroPython

Monitor embedded hardware & sensor event with Pushover Notifications on Android/iOS devices sent from PSoC6 MCU programmed with Micro Python

BeginnerProtip2 hours196
PSoC6: Sending IoT Push Notifications: WiFi with MicroPython

Things used in this project

Hardware components

CY8CPROTO-062-4343W
Infineon CY8CPROTO-062-4343W
×1
Infineon CY8CKIT-062S2-AI
×1
SparkFun Illuminated Push Button
×1

Software apps and online services

Pushover

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

connection diagram of IoT push button

Wiring diagram

sch board

Code

main.py

Python
import network
import time
from machine import Pin
from utime import sleep,sleep_ms

wlan = network.WLAN(network.STA_IF)
wlan.connect('YourWifiNetwork','YourWifiPassword')
time.sleep_ms(8000)


BLUE_BTN = Pin('P13_2', mode=Pin.IN, pull=Pin.PULL_UP)
BLUE_LED = Pin('P13_1', mode=Pin.OUT, value=0)

while wlan.isconnected()==False:
  BLUE_LED.low()
  #wait

if wlan.isconnected():
  BLUE_LED.high()
  time.sleep_ms(200)
  BLUE_LED.low()
  time.sleep_ms(200)




BLUE_BTN.irq(handler=lambda t:push_message(),trigger=Pin.IRQ_FALLING) 


if wlan.isconnected():
  for x in range(5):
    BLUE_LED.high()
    time.sleep_ms(x*200)
    BLUE_LED.low()
    time.sleep_ms(x*200)

  
  

import mip
mip.install('micropython-urequests')
import urequests as requests


def push_message():
  BLUE_LED.high()
  payload = {
    "token": "Your_Pushover_App_Token",
    "user": "Your_Pushover_User_Key",
    "message": " Your_Message (PSoC6 Fire on Blue Button District!!) ",
  }
  
  r = requests.post("https://api.pushover.net/1/messages.json", json=payload)
  time.sleep_ms(1000)
  BLUE_LED.low()
  

Credits

Shahariar

Shahariar

74 projects • 265 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments