Rasberry PI + GPIO for IR 520 MOSFET PWM control of Motor or LED

I am a newbie in Quarantineville trying to get my project moving.

I successfully have my PI up and running with a DHT22 connected and showing realtime data to my PC/Phone via MQTTP API and source code available from the DHT22 project on this form from (ADAM).

I am trying to add a IR520 mosfet as a device with PWM GPIO control ?

Any help appreciated

do you have python code for this?

OK Here is what I found

  1. Yes I have python code… but I gave my osciliscope away years ago so all I have is my old trusty Meter.

  2. I was able to run some python code and get the some LED’s turned on. It appears that the Current on the on V is 5.5 vs 3 on the main board.

Code reference and Tutorial https://www.youtube.com/watch?v=9tActipVqIM

Sorry the post didnt post correctly

It looks like the Gate V which is supposed to be 2–4V and trigger at 3.3. via GPIO isn’t correct. It needs 5V to open all the way.

I am able to open the Gate via GPIO but when measuring Voltage on the ouptut vs Input of the mosfet its noticeably lower. PWM functions are working, but you cannot reach Max Current or Voltage with only GPIO 3V on the Gate. This seems to be a common issue with knockoff mosfets.

A

Then it is hardware issue, do you have anything related to cayenne which you need help with?

once I get the PWM python script running how to I add it as a controlable the led brightness and motor speed ?

add a slider to cayenne dashbaord and read the value using

# The callback for when a message is received from Cayenne.
def on_message(message):
    print("message received: " + str(message))
    if (message.channel == 4) and (message.value == "1"):
        #run the PWM python script

S-

OK I have changed the mosfets to BUZ 11 and verified all HW issues, this mosfet triggers easily on 3.3V TTL level and has more than enough current for what I need to accomplish.

I have verified using this using python.

Now I am not sure how to modify the Python script to create the input loop from Cayene UI back to control the GPIO and have the bidirectional feed back

I am clearly not understanding how to tie this back up to Cayenne ?

Example Code:

import RPi GPIO as GPIO
GPIO.setmode (GPIO.BOARD)
U1=29
GPIO.setup (U1, GPIO.OUT)
my_pwm= GPIO, PWM(U1,100)
my_pwm.start(0)

Assume this is where the Loop is for cayenne?? Please help …

The callback for when a message is received from Cayenne.

def on_message(message):
print("message received: " + str(message))
if (message.channel == 4) and (message.value == “1”):
#run the PWM python script

well, that is not just the code. you need cayenne python library https://github.com/myDevicesIoT/Cayenne-MQTT-Python
Then use this code, add the code i gave above and your code.