Author Topic: quickstart with MQTT help needed  (Read 843 times)

0 Members and 1 Guest are viewing this topic.

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7672
  • Country: us
    • SiliconValleyGarage
quickstart with MQTT help needed
« on: August 09, 2021, 04:11:30 pm »
So , i have a board ( esp32) and an entire stack that can subscribe an MQTT broker, login , password, encryption and send / receive. so i am good on that end.
the other end is the trouble. i do not want to run my own server.

- are there any free mqtt broker services where i can create a userspace, set a username and password and enroll my device
- do they have a simple user interface where i can basically open a webpage , login and have  a  'console' so i can type in a something and hit 'send' , and see what comes back ? basically a serial port over mqtt...
- how do i create an application , on a windows pc, in visual basic (running inside excel)  , where i can send a message to my device somewhere on the internet. again , the only thing i need is raw transport. here, send this string to my target. and if something comes back, give me the string. basically i want to make a small spreadsheet in excel where i can enter some numbers in a grid and have a button that sends them over.
i don't need multiple targets , my device does not send something unless asked. and it is a one off thing ( sprinkler controller ) the grid is basically valve number, start time and duration

so to 'upload' a timer program i just send a list where each mqtt message is <command><programnumber><linenumber>,<valvenumber>,<starttime>,<runtime>
for example :
PA00109220002  : Program A line 001 valve 09 starts at 22:00 and runs for 2 minutes
PA00208220209 : program a line 002 valve 8 starts at 22:02 and rus for 9 minutes
PA00301220401 : program a line 3 valve 1 starts at 22:04 and runs 1 minutes    , so this valve opens 2 minutes after 8 is on for one minute and then closes. valve 8 keeps going (valve 1 is a fertilizer injector. we water 2 minuts, inject fertilizer in the line for a minute then keep regular water for the remainder.

and so on
i have room for 10 programs ( abcdefghij ) each with 100 lines
thereis another command
RA8F  Run program A monday thru sunday ( 8F ) is hex notation whre each bit in the 7 bit word is a day of the week (0SMTWTFS). so mondayt and friday would be  00100010 -> RA22

third command T
TDHHMMSS   : D = day of week , hours minutes seconds. this sets the internal clock. date is irellevant. it only needs ot know what day of the week we are

Lx : List program X

Oxx : open valve xx
C xx close valve xx

S : show schedule for the 10 programs
D0 : debug off
D1 debug on : sends mqtt message every time a valve toggles.

NVV<16chars>  name valve VV with name <name>

so my mqtt commands are very shorts strings and they are only used to send the programs and schedule. during operation there is no messages being sent. i can have a debug mode. in debug mode it tells you
<timestamp> <valve name> <new state>

22:02 Fruittrees off
22:02 Palmtrees on
22:04 Fertilizer on
22:04 Fertilizer off
22:11 Palmtrees off


Any leads how to jumpstart this ?
i basically need a very simple send and receive routine.
send this string
if something comes back : invoke a callback so i can print it to a debug textbox.
something along the lines of

handle = MQTTconnect(username,password,device)

MQTTsend(handle, string)

event MQTTreceive()
     print MQTTresponse

Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline gmb42

  • Regular Contributor
  • *
  • Posts: 235
  • Country: gb
Re: quickstart with MQTT help needed
« Reply #1 on: August 10, 2021, 09:52:43 am »
Maybe some help here.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf