I've mentioned before that the plan is to use the Mud-Py Django project as a library in the bridge that communicates with the ESP32 nodes via MQTT.
I want them to be two projects, but still have Mud-Py in the bridge project.
The way I came up with to do that is to make use of Git submodules.
I spent some time this weekend figuring out how to arrange one project as a submodule of another, and then working out how to actually use the submodule project as a library in the higher level project.
I'd never done that before, so although I knew it could be done I had to figure out how to get it right.
I may not have it right, but at least I have it semi-functional.
I put a new repository up on GitHub, with the beginnings of the Mud-Py MQTT Bridge in it.
If you clone that repository, you will find that it has a full copy of the Mud-Py repository embedded in it.
The way it is supposed to work is that when I make changes to Mud-Py, those changes will be reflected in the Mud-Py MQTT Bridge on the next pull - we'll see how that goes.
The Django Mud-Py project would normally be installed somewhere that the web server has access to it, while I expect the bridge needs to be installed somewhere else.
In actual use, there'll be two copies of the Mud-Py project involved, each installed where ever it makes the most sense. Both instances will use the same database. They can be on one server or on separate servers.
During development, I can start the Django test server in the Mud-Py folder of the bridge and only have to have one local copy of Mud-Py.
It turned out to be trickier than expected to import the Mud-Py libraries from the submodule. The solution was pretty much to import the Django apps like wsgi.py does (which is automatically created by the Django project setup.)
The bridge repository doesn't contain any really useful code right now. The various files are experiments in how to fit the pieces together, but there's not a comprehensive, whole thing there yet.
- There's "Simulations/send_node.py," which can send a simple "node" message via MQTT. I'll use it to simulate the ESP32 nodes until I get one ready for use - and probably afterwards as well. The real nodes will spend most of their time sleeping, so experiments are easier to do with a simulation.
- There's "bridge.py" which just imports the Mud-Py libraries and creates a node in the database. It doesn't do much at all, except remind me how the real bridge will have to import the Mud-Py libraries.
- There's "mud_py_mqtt_client.py" which I used to make some experiments in connecting a client to the MQTT server and subscribing different topics to separate handler methods.
As I said, nothing really useful there yet. Just bits and pieces of me getting organized.
The rest of my sensors arrived today, as did the switches I ordered to disconnect the ESP32s from the power banks. I got some pin headers and sockets as well as some perf boards on Saturday. I think I have all the electronics in hand. Once I get a functional bridge set up, I'll get to work modifying the power banks,
Here's what 300 euros worth of sensors looks like:
That's five packages of three sensors each. I expected the price of the sensors to drop some since last year - it didn't happen. I had to reduce to number of sensors to keep the costs at least somewhat reasonable.
Instead of the planned 30 sensors in the garden, it'll be 21. That's the 15 new sensors and the 6 I already had from last year.
15 will go in the front yard with the other 6 in the flower pots behind the house.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.