Search found 51 matches

by beetle
Wed Aug 24, 2022 10:02 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, yes, I could have mentioned another way to send data between to separately running programs is to use the file system, clunky indeed but it works as you have found :P (btw. pickle or json is good for this sort of thing, but I leave it for you google them if desired) But if my specification no...
by beetle
Wed Aug 24, 2022 9:28 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

It's very simple. I just want to run two programs at once. PicoW_Vars.py and MQTT_PW_Vars.py Sorry Rissy, the penny has finally dropped. 2 separate programs running at once and not a main module importing the code from another module. :shock: You cannot pass data between 2 entirely separately runni...
by beetle
Wed Aug 24, 2022 3:05 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

I'm sure i'll have fun with that! It feels like going back to the beginning again! :lol: I'm sure you will have fun too. I get a good measure of satisfaction when I get to improve my version 1's (and v2's). Theres always room for improvements 8-) Actually you have motivated me to so something very ...
by beetle
Tue Aug 23, 2022 3:02 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, very good, and a good example of sharing global variables with a 'globals' module as per one of my snippets to be sure. But, and I hope this does not do you head in, the question is really not how to use global variables, but rather how to share data between your modules. But first do have a ...
by beetle
Tue Aug 23, 2022 10:49 am
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Is that it? Do i have it? (Please just be straight with me now, I'm having a hard enough time trying to get this into my thick skull) To be straight, then no I don't think so, but I find it very hard to make sense of your sudo code, it quite boggles my eyes :shock: I believe your situation is that ...
by beetle
Tue Aug 23, 2022 5:56 am
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, The examples on the global var's was to show how they could be used, mainly because you kept on remarking about their use in your programs. But I would be very remiss if I did not point out there is usually a better way so I finish up with this small example of the same sort of thing but not ...
by beetle
Mon Aug 22, 2022 9:21 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, I can't find any rpi4's :( maybe you like these examples better 8-) module_globals.py: gVar = 0 module1.py: import module_globals # define a fuction that will set the global variable def set_me_var(): module_globals.gVar = 22.63 print("module1 says I've set gVar to 22.63") module_main.py: imp...
by beetle
Mon Aug 22, 2022 7:45 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, Try to only use the on-message callback function to examine the message topic and to pass the data to another function appropriate to the message. This is all i wanted to do in all fairness. I just couldn't move my GV made from the message payload outside of that function. It was trapped!? S...
by beetle
Mon Aug 22, 2022 5:55 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, Try to only use the on-message callback function to examine the message topic and to pass the data to another function appropriate to the message. Good practice is to make functions do one thing only and do it well rather then load them up with too much baggage. But thats an aside, does the f...
by beetle
Mon Aug 22, 2022 11:12 am
Forum: Raspberry Pi microcontroller boards
Topic: Pico W Micro Python MQTT of data to a RP4B
Replies: 62
Views: 573382

Re: Pico W Micro Python MQTT of data to a RP4B

Rissy, I probably did not explain so clearly about the global variables in your program so try this. Your program starts and sets up a connection to your mqtt broker and makes subscriptions. These instruction go over your wifi and eventually you receive a message relating to your subscriptions. At t...