updating schedule
This commit is contained in:
1 parent
b683ed2b94
commit
d75f003020
2 files changed
+90
-2
No files matched your search
@@ -120,7 +120,31 @@ Concepts Covered:
|
|||||||
**Project Pt 1:** Create your first custom printed circuit board. Learn to design for custom components and create a PCB that will print successfully with a PCB vendor. These boards will be assembled in week 6.
|
**Project Pt 1:** Create your first custom printed circuit board. Learn to design for custom components and create a PCB that will print successfully with a PCB vendor. These boards will be assembled in week 6.
|
||||||
|
|
||||||
---
|
---
|
||||||
## Week 5 - Internet of Things
|
## Week 5 - Motor Control
|
||||||
|
|
||||||
|
Learn the differences between motors and get them moving using a variety of techniques.
|
||||||
|
|
||||||
|
|
||||||
|
* Principles of DC motors
|
||||||
|
* Simple motor movement - voltage and amperage
|
||||||
|
* Two channel controllers
|
||||||
|
* Controllers with external power supply
|
||||||
|
* Servo motors - continuous and 180 degree
|
||||||
|
* Basic gearing and mechanical
|
||||||
|
|
||||||
|
|
||||||
|
Concepts Covered:
|
||||||
|
|
||||||
|
* Magnets and stators
|
||||||
|
* PWM speed control
|
||||||
|
* Control signals and power supplies
|
||||||
|
* Calculating angles for servo motors
|
||||||
|
* Steps and gear ratios
|
||||||
|
|
||||||
|
**Project** Examine all aspects of motor control using a variety of control boards. Have the rpi Pico control motors.
|
||||||
|
|
||||||
|
---
|
||||||
|
## Week 6 - Internet of Things
|
||||||
|
|
||||||
Returning to our Single Board Computer/Microcontroller pair, we learn the basics of connecting to networks and expanding our device communications.
|
Returning to our Single Board Computer/Microcontroller pair, we learn the basics of connecting to networks and expanding our device communications.
|
||||||
|
|
||||||
@@ -144,7 +168,7 @@ Concepts Covered:
|
|||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
## Week 6 - Demo Scene
|
## Bonus Week - Demo Scene
|
||||||
|
|
||||||
Assemble your custom-made PCB into a working, powered circuit. Combine your skills to connect it locally and to the internet.
|
Assemble your custom-made PCB into a working, powered circuit. Combine your skills to connect it locally and to the internet.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import time
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
import serial
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
SERIAL_PORT = '/dev/ttyAMA0' # Adjust for your system (e.g., 'COM3' on Windows)
|
||||||
|
BAUD_RATE = 9600
|
||||||
|
MQTT_BROKER = "localhost" # Public test broker
|
||||||
|
MQTT_PORT = 1883
|
||||||
|
MQTT_TOPIC = "python/mqtt/test"
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# 1. Initialize Serial Connection
|
||||||
|
try:
|
||||||
|
ser = serial.Serial(
|
||||||
|
port=SERIAL_PORT,
|
||||||
|
baudrate=BAUD_RATE,
|
||||||
|
parity=serial.PARITY_NONE,
|
||||||
|
stopbits=serial.STOPBITS_ONE,
|
||||||
|
bytesize=serial.EIGHTBITS,
|
||||||
|
timeout=1
|
||||||
|
)
|
||||||
|
except serial.SerialException as e:
|
||||||
|
print(f"Could not open serial port: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 2. Initialize MQTT Client
|
||||||
|
client = mqtt.Client()
|
||||||
|
|
||||||
|
# Optional: Add callbacks for connection status
|
||||||
|
def on_connect(client, userdata, flags, reason_code, properties):
|
||||||
|
if reason_code == 0:
|
||||||
|
print("Connected to MQTT Broker")
|
||||||
|
else:
|
||||||
|
print(f"Failed to connect, return code {reason_code}")
|
||||||
|
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||||
|
|
||||||
|
# 3. Read Serial and Publish to MQTT
|
||||||
|
print("Reading from serial port and publishing to MQTT...")
|
||||||
|
try:
|
||||||
|
for i in range(10): # Read 10 messages as an example
|
||||||
|
if ser.in_waiting > 0:
|
||||||
|
# Read line from serial port
|
||||||
|
data = ser.readline().decode('utf-8').strip()
|
||||||
|
if data:
|
||||||
|
# Publish to MQTT topic
|
||||||
|
client.publish(MQTT_TOPIC, data)
|
||||||
|
print(f"Published: {data}")
|
||||||
|
else:
|
||||||
|
print("No data available on serial port")
|
||||||
|
time.sleep(1) # Wait 1 second between reads
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Interrupted by user")
|
||||||
|
finally:
|
||||||
|
# Cleanup
|
||||||
|
ser.close()
|
||||||
|
client.disconnect()
|
||||||
|
client.loop_stop()
|
||||||
|
print("Disconnected and closed serial port.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user