Chat freely about anything...

User avatar
By Mikejstb
#21133 I took last week off for a vacation week. Actually I'm disabled, but I took a "mental" vacation week to just play.

On Monday my 3D printer (XYZPrinting Da Vinci 1.0 - $349) arrived and I started printing enclosures for all of my little projects which use the .96" and 1.3" oled displays. And also an enclosure for my 4x20 LCD display "mqtt message center".
The printing went amazingly well and it makes a whole world of difference in how nice my little projects look.
If I do say so myself - LOL!
That printer is just amazing - it's like magic to watch.

I also made a few more ESP projects - a couple of MOSFET light dimmers. 3,4 and 1 channel for various types of LEDs, colors, etc. I'm waiting for some desk and floor lamps to arrive to put the lights into.
As usual it's all controlled via mqtt messages.

Then another package arrived - a box of 5 Elekcity 433Mhz wireless outlet (mains) controllers.
It was 5 for $20, and I was planning on just using the enclosures and putting ESPs & SSRs in them as I've done for a few other outlets.
But the RF control was interesting, so instead of gutting the units and replacing their innards I did some rf detective work and discovered what the codes where for turning the 5 outlets on and off. By using a little 433Mhz receiver and an arduino to snoop out the signal.

Then I got a little 433Mhz transmitter module, coupled it with an ESP-12, put it all in a nice little custom printed enclosure - and now I can control all 5 outlet units, again via mqtt message. Neat! I'm going to order 5 more of these, they are very handy. The little 433Mhz "Wifi to 433Mhz" ESP bridge can be just about anywhere in my home and it's able to control all the outlets. Plus the little remote controls that came with the package still work, so that's a pretty good setup.

I made a little controller/fader app for my iPod with NetIO so I can do the lights up and down, turn the outlets on and off, etc.

My only big fail for the week was a project to try to use those 8x8 LED matrix Max7219 displays to display mqtt messages.
I've tried a handful of different modules and none of them work well. In no case can I ever have more than 4 of them daisy chained without the displays turning to garbage, and the new ones I tried that have 4 units hard wired together (thinking maybe the cables were introducing the garbage) are printing everything "backwards" both right to left and top to bottom. I've tried with arduinos, ESPs, various LED matrix libraries - and just nothing works.

But all in all it was a good week!
User avatar
By danbicks
#21137 Mikejstb,

What an amazing week buddy A+

Any chance of sharing some of that MQTT code. I am stuffed at the moment trying to get mine to reconnect without causing a WDT error. What have you used for yours eclipse?

Cheers

Dans
User avatar
By Mikejstb
#21151 It seems like ages ago but it's only been a couple of months since starting to play with these things.
I needed to learn about Lua, and mqtt, Node Red, the NodeMCU stuff - an awful lot of stuff to absorb just to get going!

I had major problems with mqtt - if my program didn't publish something in some amount of time ( around 2-3 minutes I think) then everything apparently disconnected and no more publications went through. And no errors were seen - just nothing happened anymore.

I played around for a while - I did have some bad code which has causing WDT resets - I took care of that. That was mainly getting used to the Lua event driven world. Using semiphores and flags instead of thinking any code would execute linearly. I guess my method was to sort of make a state machine to try to get things done. All of that way a huge mental change for me but from all the examples here I think I finally came to grips with it.

Then there was learning about mqtt, how to publish, how to subscribe - all the mqtt basic stuff. Once that was mostly working I found a big mqtt problem - I think it's a timeout problem.

I could publish messages - but if I didn't publish anything for a minute or two everything would just go away.

. I tried changing all of the mqtt options as far as timeouts, reconnects, etc - but nothing made any difference. If I didn't send out a message every couple of minutes my program was essentially finished.

What I finally did was a scheme where if I haven't published a message within two minutes I publish a message with the payload "stay alive".

Then my Node Red just ignores any incoming mqtt messages with "stay alive" as the payload.

That worked - and
I never went back to try to actually diagnose and solve the problem.
Pure lazy on my part.

Then there was the change to the Arduino IDE - honestly I don't remember if I had to do the same thing in that realm as I did in Lua or not. I'll try to find some samples of my code (there's been a LOT of code written these few months!) and see if I can get a firm answer on that. I think there may be a chance that the only mqtt code I've done so far in the Arduino IDE is subscription only - I don't think I have any Arduino code that publishes. I'll try to confirm if that's the case or not. It could be all my code that publishes is all in Lua...
User avatar
By danbicks
#21241 Hi Mike,

Tell me about it, a massive learning curve. I like the keep alive tip :)

Whatever you have for this will be great buddy. I am just checking that connections to network and MQTT are connected, this seems to be what causes the crash, only if the MQTT server has been established after a network disconnection, next time the system checks which is done by the use by setting a flag to check in the ticker library and then doing the actual checking in the main loop, if the network is down, I.E router unplugged a WDT reset is caused.

I can publish no problems the subscribe side is also covered.

Cheers mate

Dans