-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miscellanous updates #5
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
simple.py | ||
flash_nuke.uf2 | ||
RPI_PICO_W-20240222-v1.22.2.uf2 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||
PICO_RST=https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 | ||||||
MP=https://micropython.org/resources/firmware/RPI_PICO_W-20240222-v1.22.2.uf2 | ||||||
UMQTT=https://github.com/micropython/micropython-lib/raw/master/micropython/umqtt.simple/umqtt/simple.py | ||||||
|
||||||
all: deploy | ||||||
|
||||||
$(shell basename $(PICO_RST)): | ||||||
curl -O $(PICO_RST) | ||||||
|
||||||
$(shell basename $(MP)): | ||||||
curl -O $(MP) | ||||||
|
||||||
$(shell basename $(UMQTT)): | ||||||
curl -LRJO $(UMQTT) | ||||||
|
||||||
.PHONY: dependencies | ||||||
dependencies: $(shell basename $(PICO_RST)) $(shell basename $(MP)) $(shell basename $(UMQTT)) | ||||||
|
||||||
.PHONY: deploy | ||||||
deploy: dependencies | ||||||
cp $(shell basename $(PICO_RST)) /run/media/per/RPI-RP2 | ||||||
sleep 15 | ||||||
cp $(shell basename $(MP)) /run/media/per/RPI-RP2 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
sleep 5 | ||||||
# upgrade version string so we can follow we run the latest... | ||||||
before=$$(cat main.py | grep ^version | cut -d\" -f2) ;\ | ||||||
sed -i s/^version.*/version\ =\ \"$$(($$before+1))\"/g main.py | ||||||
grep ^version main.py | ||||||
mpremote cp config.py :config.py | ||||||
mpremote cp boot.py simple.py obis.py : | ||||||
mpremote cp main.py : | ||||||
|
||||||
.PHONY: redeploy | ||||||
redeploy: | ||||||
mpremote bootloader | ||||||
sleep 4 | ||||||
make deploy | ||||||
|
||||||
.PHONY: unit-test | ||||||
unit-test: | ||||||
sudo stty -F /dev/ttyUSB0 raw | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the path here depends on you operating system and slot selected |
||||||
sudo stty -F /dev/ttyUSB0 -echo -echoe -echok | ||||||
sudo stty -F /dev/ttyUSB0 115200 | ||||||
sudo stty -F /dev/ttyUSB0 | ||||||
while true; do cat unit-test/example.msg.crlf >> /dev/ttyUSB0; sleep 10; done | ||||||
|
||||||
.PHONY: mqtt-viewer | ||||||
mqtt-viewer: | ||||||
sub --auto-reconnect \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall it be |
||||||
--broker tcp://$$(grep MQTTHost config.py.home | cut -d\' -f2):1883 \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
--topic $$(grep MQTTTopic config.py.home | cut -d\' -f2)/# | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.PHONY: clean | ||||||
clean: | ||||||
$(RM) $(shell basename $(PICO_RST)) $(shell basename $(MP)) $(shell basename $(UMQTT)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
SSID = '<yourSSID>' | ||
PSK = '<yourPSK>' | ||
MQTTHost = '<yourMQTTHost>' | ||
MQTTTopic = 'exampletopic/data' | ||
ID = 'P1mqtt-' | ||
SSID = '<SSID>' | ||
PSK = '<PSK>' | ||
MQTTHost = '<IP to mqtt server>' | ||
MQTTTopic = 'electric-meter/main' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybee add user and password for the MQTT client? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import mip | ||
import network | ||
import config | ||
|
||
wlan = network.WLAN(network.STA_IF) | ||
wlan.active(True) | ||
wlan.connect(config.SSID, config.PSK) | ||
|
||
mip.install("umqtt.simple") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.