Jump to content

Recommended Posts

Posted

Here is a preview of the UIFlow 2 blocky LegoB blocks and a working sample program. (nothing fancy motor port A follow state of Touch sensor input 1).  (On a M5 Core 2 but same has worked on a M5Stick CPlus)

1280x842.png

Posted (edited)

Well, a bit of fiddling around (I still don't really understand the webrepl aspect??  I just use Thonny to run a program) I got an older ESP32 DevKit board to work with demob.py (press button on 1 see light on A:pir-triumph: 

Baby steps :innocent2:

 

Edited by Gunners TekZone
Posted
2 hours ago, Gunners TekZone said:

Well, a bit of fiddling around (I still don't really understand the webrepl aspect??  I just use Thonny to run a program) I got an older ESP32 DevKit board to work with demob.py (press button on 1 see light on A:pir-triumph: 

Baby steps :innocent2:

 

ESP32 devkit are still the best.  very stable.  I like also the mini version of the ESP Wroom 32...

The webrepl is really to use the Wifi to access the "Shell" so you can access remotely with no USB link to your ESP32...  But it is slow.

I think, for a particular project, someone will use the USB to test and when fully functionnal, the user will rename his final project file main.py so that it will be executed automatically when you apply power...

Right now, I made provision to power my esp using the lego box power connector on the front but I do not use it because I prefer to use USB link to test.  It is faster.
But for a final project, I would disconnect the usb and use the 9vdc link to power the ESP...

I'm glad you you managed to test the setup...  I feel less lonely now ;-)

 

Posted (edited)
On 2/1/2025 at 7:52 PM, Bliss said:

I'm glad you you managed to test the setup...  I feel less lonely now ;-)

And I finally got the MQTT part working.  Took a bit to realise that, and where in the code, I needed to set the TX/RX pins...  Silly me :P

That app looks interesting... But looked like it was going to take me a bit to set it up, so I fell back to my Node-Red setup for some basic tests to confirm proper action.

 

Edited by Gunners TekZone
Posted (edited)
On 2/1/2025 at 11:13 PM, Gunners TekZone said:

And I finally got the MQTT part working.  Took a bit to realise that, and where in the code, I needed to set the TX/RX pins...  Silly me :P
That app looks interesting... But looked like it was going to take me a bit to set it up, so I fell back to my Node-Red setup for some basic tests to confirm proper action.

:thumbup:

Indeed in every demo programs I offer, there are few settings to change (Described in the README).  tx rx pin in the lego.start method and for the mqtt demo, the ip address of the broker.  In addition, the secret.py should be updated as well for using the network features (MQTT and WebREPL)...

If someone does not not need the network at all in his project, he does not need to replace the boot.py file and he only needs to copy the legob.py and his project file like demob.py or demob02.py  that's all.  No need to copy the boot.py, the lib folder, secret.py etc... 

 

The phone app IoT MQTT Panel is really just another alternative for those who wants to have a nice UI (User Interface or HMI Human Machine Interface) to control their Lego Interface B outputs from their phone a bit like the https://www.controllab.io/ which is using a webbrowser... 
I found myself this IoT MQTt Panel app very easy to setup and fun to play with.

But since IoT MQTT panel is configurable, it is more flexible.
You can also make Home Assistant Dashboard and custom "Cards" etc.  Many solutions.

Node-Red is great to test and make programs to interact between IoT devices...  It a favorite for many in the IoT world.

 

I update the demob_mqtt_v2.py to make all sensors avail to mqtt.  I also put comments at the beginning to describe the topic to use.

EDIT 2025-02-02 17h16:  I made a correction in the demob_mqtt_v2 for the reset of rotation count and I also uploaded a demob_mqtt_plc_v1.py in the LegoB "PLC" version folder...
The demob_mqtt_plc_v1 file uses the built-in umqtt.simple since there is no asyncio in this version...  We'll see if it runs reliably...

 

Have fun!  

Edited by Bliss
Posted

@Gunners TekZone

I found out that the IoT MQTT app on the phone allows to backup the configuration.

So, I just uploaded a backup (json) of my IoT MQTT Panel configuration.  You will still need to configure your broker info.

I don't know if the backup will work on an Android phone though...

 

Posted
3 hours ago, Bliss said:

I don't know if the backup will work on an Android phone though...

It's JSON so not a problem there.  Worked great!  Thanks!

I had started on a couple of settings of my own with that app... as well as some more Node-Red, but between normal grogginess and stuffed sinuses due recent weather change... I fear the more GUI/HMI interfaces I struggle to learn, the greater my chances of forgetting where I live *huh* :snicker:

Posted
4 hours ago, Bliss said:

oT MQTT app on the phone allows to backup the configuration

Woops... Be aware, not sure if due to the free or Android version, but apparently restoring will wipe out all other connections that were there?  Odd.

And having almost installed advertised programs when meaning to hit the save button at the bottom, and not willing to spend $12CAD for this at the moment, I might stick with the Virtuino IoT and Node-Red interfaces I already have and understand :snicker:

Posted (edited)

I removed the "plc" version and replaced it with LegoB micropython V2 folder.  I updated Post #1 too.

Lego Interface B MicroPython ESP32 V2

Now I use MCU Timers for both the keep alive and Inputs Byte Frame readings...  Using Timers creates constant periodic interrupts.  (There are 4 of these Timers available on the ESP32)
(Should have done this before...)

So we can do slow sequences or non blocking fast logic (like an industrial PLC).

The V2, i believe, is the simplest to use and I hope, the most stable version of the MicroPython ESP32 Lego Interface B driver.

UPDATE 2025-02-05 9h47:  I left the V2 running overnight with the MQTT demo and when I checked this morning it was stopped with an OS Error (Error from the umqtt.simple)...  ESP32S3-zero mcu...  (It seems stable with no mqtt demos)
I will let the V1 running the whole day with its MQTT demo...

UPDATE 2025-02-05 20h38: I left V1 MQTT demo running all day and no fail but maybe this version of mqtt has some auto reconnect feature.  I'm trying LegoB V2 again since few hours with the umqtt.robust rather than umqtt.simple and it does not fail, but robust version of umqtt uses the .simple with some auto reconnects on fail...

UPDATE 2025-02-06 01:06: The LegoB V2 eventually failed.  Now it was a Checksum mismatch lf the LegoB continuous inputs reading...  I suspect that when there is mqtt.robust auto reconnects, it takes ressources and bothers to reading on serial... idk...
Anyway, I made (and uploaded in dropbox of the LegoB V2) another mqtt demo (demobv2_mqtt_2.py) that uses the same "mqtt_as" library that I used for the V1 LegoB.
Now let's see if the LegoB V2 demobv2_mqtt_2.py will run overnight with no fail...

UPDATE 2025-02-06 11h47: LegoB V2: demobv2_mqtt_2.py has run overnight no fail... This mqtt_as library is really solid...

Edited by Bliss
Posted
On 2/4/2025 at 7:37 PM, Bliss said:

UPDATE 2025-02-06 11h47: LegoB V2: demobv2_mqtt_2.py has run overnight no fail... This mqtt_as library is really solid...

Well, after many days of 1st snow, 6 hour power outage (in freezing cold and all electric heat), dead camera server (faulty UPS??) computer revival/replacement, and even issues with micropython behaviour that just messed up my thinking... (PS, I belatedly realised that there is NO reason to try this on the Win 7 PC, as due it's very nature, a ESP32/Micropython controlled Interface-B needs no serial ports... Doh!)...

I can finally concur :D

I am running an Pi400 with Mosquitto MQTT broker and Node-Red.  And using Node-Red to handle the logic, the Micropython Interface-B has been running over 24 hours.  With temp, rotation, button and light (the button and bulb control and indicate the status of a 120v lamp, via Sonoff switch).

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...