Updated ELE128 Labs

This commit is contained in:
Edward Bigos 2025-09-07 08:26:56 -04:00
parent 93a269c432
commit cb4fea3022
50 changed files with 621 additions and 0 deletions

View file

@ -0,0 +1,9 @@
How to Use Shodan for Beginners!
https://www.youtube.com/watch?v=i7PIyCq_VU4
[DEFCON 20] Drinking From the Caffeine Firehose We Know as Shodan
https://www.youtube.com/watch?v=t8nkkVoEo88

View file

@ -0,0 +1,14 @@
How to Use Shodan for Beginners!
https://www.youtube.com/watch?v=i7PIyCq_VU4
DEF CON 20 - Viss - Drinking From the Caffeine Firehose We Know as Shodan
https://www.youtube.com/watch?v=-T-3buBwMEQ
Optional Material
Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CL
https://www.youtube.com/watch?v=v2EdwgX72PQ
Hunting for ICS and Other Tricks on Shodan!
https://www.youtube.com/watch?v=bZUnQR4bdT8

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 KiB

View file

@ -0,0 +1,19 @@
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
print("Hello, CircuitPython!")
while True:
print("On!")
led.value = True
time.sleep(1)
print("Off!")
led.value = False
time.sleep(1)

View file

@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import board
import adafruit_dht
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT11(board.GP4)
# you can pass DHT22 use_pulseio=False if you wouldn't like to use pulseio.
# This may be necessary on a Linux single board computer like the Raspberry Pi,
# but it will not work in CircuitPython.
# dhtDevice = adafruit_dht.DHT22(board.D18, use_pulseio=False)
while True:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print(
"Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(
temperature_f, temperature_c, humidity
)
)
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
time.sleep(2.0)

View file

@ -0,0 +1,114 @@
# SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries
# SPDX-License-Identifier: MIT
import os
import sys
import time
import ssl
import wifi
import socketpool
import microcontroller
import board
import busio
import adafruit_requests
#import adafruit_ahtx0
import adafruit_dht
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
from microcontroller import cpu
def readDHTSensor():
runFlag = True
while runFlag:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print(
"Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(
temperature_f, temperature_c, humidity
)
)
runFlag = False
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
return [temperature_f, humidity, temperature_c]
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT11(board.GP4)
wifi.radio.connect(os.getenv('CIRCUITPY_WIFI_SSID'), os.getenv('CIRCUITPY_WIFI_PASSWORD'))
aio_username = os.getenv('ADAFRUIT_IO_USERNAME')
aio_key = os.getenv('ADAFRUIT_IO_KEY')
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
# Initialize an Adafruit IO HTTP API object
io = IO_HTTP(aio_username, aio_key, requests)
print("connected to io")
# use Pico W's GP0 for SDA and GP1 for SCL
#i2c = busio.I2C(board.GP1, board.GP0)
#aht20 = adafruit_ahtx0.AHTx0(i2c)
try:
# get feed
picowTemp_feed = io.get_feed("mytemperature")
picowHumid_feed = io.get_feed("myhumidity")
except AdafruitIO_RequestError:
# if no feed exists, create one
print("Feed error")
sys.exit(-1)
# pack feed names into an array for the loop
feed_names = [picowTemp_feed, picowHumid_feed]
print("Connected to feeds.")
clock = 300
while True:
try:
# when the clock runs out..
if clock > 50:
print("") # Prints a blank line after clock print.
# read sensor
dhtData = readDHTSensor()
data = [dhtData[0], dhtData[1]]
# send sensor data to respective feeds
for z in range(2):
io.send_data(feed_names[z]["key"], data[z])
print("sent %0.1f" % data[z])
time.sleep(1)
# print sensor data to the REPL
print("\nTemperature: %0.1f C" % data[0])
print("Humidity: %0.1f %%" % data[1])
print()
time.sleep(1)
# reset clock
clock = 0
else:
clock += 1
# pylint: disable=broad-except
# any errors, reset Pico W
except Exception as e:
print("Error:\n", str(e))
# print("Resetting microcontroller in 10 seconds")
time.sleep(3)
# microcontroller.reset()
# delay
time.sleep(1)
# print(clock)
print(clock,end=" ")

View file

@ -0,0 +1,7 @@
CIRCUITPY_WIFI_SSID = "cset@stcc"
CIRCUITPY_WIFI_PASSWORD = "c1s2e3t4"
# Replace the next two lines with your Adafruit username and key.
ADAFRUIT_IO_USERNAME = "csetuser"
ADAFRUIT_IO_KEY = "aio_whil751ZM389iWH4GR20r90cTb0R"

View file

@ -0,0 +1,31 @@
import adafruit_connection_manager
import adafruit_ntp
import os
import time
import wifi
wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
wifi_password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
wifi.radio.connect(wifi_ssid, wifi_password)
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=-5, cache_seconds=3600)
while True:
print(ntp.datetime)
myTime = {'year':ntp.datetime.tm_year,
'month': ntp.datetime.tm_mon,
'day': ntp.datetime.tm_mday,
'hour': ntp.datetime.tm_hour,
'min': ntp.datetime.tm_min,
'sec': ntp.datetime.tm_sec
}
print(myTime)
time.sleep(10)
# break

View file

@ -0,0 +1,33 @@
import adafruit_connection_manager
import adafruit_ntp
import os
import time
import wifi
wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
wifi_password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
wifi.radio.connect(wifi_ssid, wifi_password)
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=-5, cache_seconds=3600)
while True:
print(ntp.datetime)
myTime = {'year':ntp.datetime.tm_year,
'month': ntp.datetime.tm_mon,
'day': ntp.datetime.tm_mday,
'hour': ntp.datetime.tm_hour,
'min': ntp.datetime.tm_min,
'sec': ntp.datetime.tm_sec
}
if myTime['min'] % 5 == 0:
print("At 5 min")
print(myTime)
time.sleep(60) # Wait until one minute passes, i.e. minute % 5 does not equal 0
time.sleep(30) # Wait 30 seconds
# break

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View file

@ -0,0 +1,63 @@
"""
This example writes data to a feed in a batch from a list.
You can install the Adafruit library using the following command.
sudo pip3 install Adafruit_IO
Before you run the program you must put in your username and key from
the Adafruit IO site. Copy from the website and replace my information.
My key will no longer work. It has been changed.
To run the program from the command line use:
python3 demo-upload.py
If you do not have Python you can install it from here:
https://www.python.org/
"""
import time
# import Adafruit IO REST client.
from Adafruit_IO import Client, Feed
# Set to your Adafruit IO key.
# Remember, your key is a secret,
# so make sure not to publish it when you publish this code!
#ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
# Set to your Adafruit IO username.
# (go to https://accounts.adafruit.com to find your username).
#ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
#################################### Replace these with your KEY. ##########################
# These are no longer valid. Replace these values with your own username and key.
ADAFRUIT_IO_USERNAME = "csetuser"
ADAFRUIT_IO_KEY = "aio_pXkk38kXLMDZ"
############################################################################################
# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
humidity_feed = aio.feeds('myhumidity')
temperature_feed = aio.feeds('mytemperature')
temperatureList = [78.5, 77.2, 79.5,81.0, 82.4,80.3,79 ]
humidityList = [57, 55, 55, 54, 57, 56.8,56,56,55.6]
print("Sending Temperature")
for fahrenheit in temperatureList:
print(f"Sending {fahrenheit}")
aio.send(temperature_feed.key, str(fahrenheit))
print("Sending Humidity")
for humidity in humidityList:
print(f"Sending {humidity} ")
aio.send(humidity_feed.key, str(humidity))

View file

@ -0,0 +1,12 @@
#
#
secrets = {
'location': 'SpecifyALocation', # Just a label
'ssid': 'putssidhere',
'password': 'putpasswordhere',
"timezone": "America/New_York", # http://worldtimeapi.org/timezones
# "openweather_location": "New York City, US",
"aio_username": "csetuser",
"aio_key": "aio_xl6iR7P9M6jDnmt",
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

View file

@ -0,0 +1,202 @@
#!/usr/bin/python3
# Python program to find current weather details of any city
# using openweathermap api
# import required modules for weather
import os
import requests, json
import urllib.request
import urllib.parse
from datetime import date,datetime
from datetime import time
import toml
# print diagnostic values if True else skip if False
diagnosticFlag = True
#diagnosticFlag = False
# import Adafruit IO REST client.
from Adafruit_IO import Client, Feed
settingsFile = 'settings.toml'
try:
with open(settingsFile, 'r') as f:
config = toml.load(f)
except:
print("File ", settingsFile," could not be opened.")
print("This file must be in the same directory as the main program.")
exit(-1)
###################### Replace these with your Open Weather KEY ##########################
# This is the OpenWeather API key.
api_key = config['API_KEY']
##################### Replace these with your Adafruit Feed KEY ##########################
# These are no longer valid. Replace these values with your own username and key code.
ADAFRUIT_IO_USERNAME = config['ADAFRUIT_IO_USERNAME']
ADAFRUIT_IO_KEY = config['ADAFRUIT_IO_KEY']
##########################################################################################
# base_url variable to store url
base_url = "http://api.openweathermap.org/data/2.5/weather?"
# Give city name
location_name = "Zobo,Ma,Us"
locationList = location_name.split(",")
cityName,stateName,countryName = locationList
# complete_url variable to store
# complete url address
complete_url = base_url + "appid=" + api_key + "&q=" + location_name
# get method of requests module
# return response object
response = requests.get(complete_url)
# json method of response object
# convert json format data into
# python format data
x = response.json()
if x["cod"] != 200:
print("Invalid return code")
print("x = ",x)
# Now x contains list of nested dictionaries
# Check the value of "cod" key is equal to
# "404", means city is found otherwise,
# city is not found
if x["cod"] != "404":
# Uncomment the next print line to show the weather in dictionary format
# print("x = ",x)
coordinates = x["coord"]
latitude = coordinates["lat"]
longitude = coordinates["lon"]
# Uncomment the next two lines to print the latitude and longitude
# print("coordinates = ",coordinates)
# print(latitude,longitude)
# store the value of the "main" dictionary key in variable y
y = x["main"]
# store the value corresponding to the "temp" key of y
current_temperature = y["temp"]
# store the value corresponding to the "pressure" key of y
current_pressure = y["pressure"]
# store the value corresponding to the "humidity" key of y
current_humidity = y["humidity"]
# store the value of "weather" key in variable z
z = x["weather"]
# store the value corresponding to the "description" key at the 0th index of z
weather_description = z[0]["description"]
# print following values if True else skip if False
if(diagnosticFlag):
print(" Temperature (in kelvin unit) = " +
str(current_temperature) +
"\n atmospheric pressure (in hPa unit) = " +
str(current_pressure) +
"\n humidity (in percentage) = " +
str(current_humidity) +
"\n description = " +
str(weather_description))
print("\n")
fahrenheit = 9/5*(current_temperature-273) + 32
pressure = current_pressure * .0145037738
today = date.today()
current_time = time()
now = datetime.now()
t = now.strftime("%H:%M:%S")
sampleDate = f"{today.year:4d}-{today.month:02d}{today.day:02d}"
# print following values if True else skip if False
if(diagnosticFlag):
print(f"{today.year:4d}-{today.month:02d}{today.day:02d} {t}")
print()
print(f"Predicted weather for {location_name} at {t} on {today.year:4d}-{today.month:02d}{today.day:02d}")
print(f"Temperature = {fahrenheit:.2f} F")
print(f"Pressure = {pressure:.2f} psi")
print(f"Humidity = {current_humidity:.0f}%")
print(str(weather_description))
else:
print(" City Not Found ")
weatherRecord = {
"sampleDate": sampleDate,
"sampleTime": t,
"city": cityName,
"state": stateName,
"country": countryName,
"latitude": latitude,
"longitude": longitude,
"temperature": f"{fahrenheit:.2f}",
"temperatureUnits": "F",
"pressure" : f"{pressure:.2f}",
"pressureUnits": "psi",
"humidity" : current_humidity,
"description": weather_description
}
# print following values if True else skip if False
if(diagnosticFlag):
print("\nweatherRecord")
print(weatherRecord)
jsonWeather = json.dumps(weatherRecord,indent=4 )
print("\njsonWeather")
print(jsonWeather)
##########################################################################################
# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
#### Send data to the predicted outside feeds.
if(diagnosticFlag):
print("Sending Temperature")
temperature_feed = aio.feeds('outsidetemperature')
aio.send(temperature_feed.key, str(fahrenheit))
if(diagnosticFlag):
print("Sending Humidity")
temperature_feed = aio.feeds('outsidehumidity')
aio.send(temperature_feed.key, str(current_humidity))
if(diagnosticFlag):
print("Sending Pressure")
temperature_feed = aio.feeds('outsidepressure')
aio.send(temperature_feed.key, str(pressure))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

33
LabSchedule.md Normal file
View file

@ -0,0 +1,33 @@
# MDC IoT Workshop 2025 Lab Schedule
September 5, 6, 7, 8
5-6 hours a day 9 AM to 3 PM
## Schedule:
Day 1 -
Day 2 - Sparkfun SIK Kit/Arduino
Day 3 - Raspberry Pi Pico, Python, MQTT to Cloud
Day 4 -
### Day 1
### Day 2
Overview of the Sparkfun Inventor's Kit (SIK) & Arduino
Breadboard circuits/Build to test
LED's, potentiometers (Pot), buttons, switch, RGB LED
Digital Output - LED
Analog input & A/D conversion
### Day 3
MicroPython & CircuitPython.
Raspberry Pi Pico
Temperature and humidity sensor
Cloud & IoT
Embedded Controller Platforms
### Day 4

View file

@ -0,0 +1,14 @@
### IoT Parts Suppliers
###Sparkfun
Supplier for the Sparkfun Inventor's Kit (SIK), Qwiic devices, and other IoT parts.
<https://www.sparkfun.com>
###Adafruit
Supplier for boards, displays, IoT parts, and the Adafruit Io IoT cloud.
<https://www.adafruit.com>

33
WorkshopSchedule.md Normal file
View file

@ -0,0 +1,33 @@
# MDC IoT Workshop 2025 Schedule
September 5, 6, 7, 8
5-6 hours a day 9 AM to 3 PM
## Schedule:
Day 1 - IoT Basics & Electronics Applications
Day 2 - IoT Networks & Security & Hardware Platforms
Day 3 - IoT Cloud Applications & Hardware Platforms
Day 4 - IoT Industrial Applications & Wireless
### Day 1
Intro to IoT & Cyber-Physical Systems
Applications/Operational Technology (OT)
Basic Electronic Control Systems
### Day 2
Basic Electrical/Electronics Theory
Microcontrollers
Networking & Security
### Day 3
Cloud & IoT
Embedded Controller Platforms
### Day 4
Wireless Networking
Industrial Networks
Automation/Robotics
Industrial IoT
Cisco Resources