Jump to content

Recommended Posts

Posted

@Toastie,

Wow, I knew from your other threads and posts that you don't do things halfway and this is no exception.

This is a very cool setup as you can easily use USB or BT (HC-05).


I'm working on a version based on the Int.A V2, but is uses WebSocket through wifi.  It's using an ESP32 to make the bridge between wifi and the Arduino serial.  ESP32 (WIFI) here replaces an HC-05 (BT)

It still under testing and I'm not sure I will officially release it as the setup is a bit more complex to get a bit more speed and a lot more distance...
The setup for the WebSocket Bridge requires:

  • Need Wifi (goes through a wifi router.  I guess everybody has wifi at home...  I guess it could work with ESP32 in AP mode...  I did not test this)
  • Wire RX2, TX2 of ESP32 to TX, RX of arduino...
  • Need nginx sofware on the computer that has blockly (small exe and conf file)
  • Upload the Lego9750_ws sketch (which is almost the same as the v2) into an arduino uno or nano. (This is temporary as I want to adapt so it is the same sketch)
  • Upload a ESP32_WS_Bridge sketch into an ESP32 Wroom (I use mini esp32 devkit)
  • You must edit the sketch to enter your wifi ssid and password before you upload.
  • Once uploaded, use the arduino IDE serial debug to get the IP address of the ESP32
  • Edit the nginx.conf to put this ip address.
  • Start NGINX.
  • Enter https://127.0.0.1 in chrome to accept security warning and get the welcome to nginx page...
  • In blockly, select Int.A WS and connect...   Use the same blocks as for Int.A V2...

So as you can see, it's more setup but it's feasible.

After many iterations, it's appears to work reliably but it has not been easy.
So i might add the files in my github and some instructions but not sure anyone will use it :-)

 

Posted (edited)
6 hours ago, Toastie said:

Now I have a BT/USB Int.A interface for LEGO Blockly, which works without Int.A connected - regarding the outputs. I can just carry the lill Uno with me when traveling ;) Input wise, bold switches, as the 4.5V touch sensors work as well (but logic is inverted).

Oh wow!  Very nice!!   Makes me want to build something similar to fit in my current MEGA with display sandwich (it is already three boards thick including MEGA and display), to add in the Blockly BT option, and a nicer Int-A connection with less dupont. 

As well as just for the fun of building it :pir-triumph:

2026-05-04-17.57.22.jpg?rlkey=ve4or31wm4

Alas... First I still need to find a way to merge the MEGA Touch Screen control and Blockly interface code together... And catch up with all the Blockly changes...

But all that requires too much thinking *huh*  So for now I just lurk :innocent2:

BTW... I have noticed that both of my Interface-A's only output 3.7 - 3.8vdc (but it is stable even with motors running) regardless of type of AC or DC adapter connected to them.  Can others measure their voltage outputs and let me know what they are?  Thanks!  I am wondering if I need to do some regulator upgrades in both of mine??

Edited by Gunners TekZone
Posted (edited)

@Gunners TekZone

Thanks - and yes, the BT connection clears up some mess, particularly when you feed Int.A as well as the Arduino/Mega from the same 9-12 V power supply. That doesn't even violate the strict LEGO philosophy of isolating everything on the Int.A power side incl. GND from the PC power side, as air is rather non-conductive :D Also, the Dupont type connection to 9750 (I am always using when prototyping) is a bit shaky when moving the equipment around. 

18 hours ago, Gunners TekZone said:

Can others measure their voltage outputs and let me know what they are?  Thanks!  I am wondering if I need to do some regulator upgrades in both of mine?

The circuit diagram of 9750 says "+4V" as feed voltage for the power MOSFETs of the 6 outputs and the permanent 4V output. So I guess 3.7 - 3.8V is fine. My three 9750's are all in the same range as yours on the permanent 4V output. 

Best
Thorsten

 

@Bliss

Thank you - well, I am trying to do it as clean as I can, but that does not mean much!

19 hours ago, Bliss said:

I'm working on a version based on the Int.A V2, but is uses WebSocket through wifi.  It's using an ESP32 to make the bridge between wifi and the Arduino serial.  ESP32 (WIFI) here replaces an HC-05 (BT)

THAT sounds also really cool! Yes, Wifi seems to be everywhere ... don't the Shelly people use customized ESP32s to use and extend Wifi range at the same time for all their wireless stuff? There are some Shellys (Wifi power plugs) in the house, as the Huawei EMMA controller for our PV system knows how to talk to them. "No sun, no juice" control :D 

How about using the Arduino "UNO Rev4 WiFi" board with RA4M1 and ESP32-S3 controllers for that purpose? There are also ample of LEDs on the board itself, as shown for example here: https://www.reichelt.com/de/en/shop/product/arduino_uno_rev4_wifi_ra4m1_esp32-s3-353108?country=de&CCTYPE=private&LANGUAGE=en

EDIT: And it has BT as well ...

All the best
Thorsten 

Edited by Toastie
Posted
19 hours ago, Gunners TekZone said:

Alas... First I still need to find a way to merge the MEGA Touch Screen control and Blockly interface code together.

Correct me if I'm wrong but your display + mega setup is for testing "Interface A" inputs and outputs only, there is no lego project program running in this setup?

This is the setup we see on LVL1 website right?
The version 1 of Interface A blockly driver using arduino is using LVL1 arduino code so I guess you could add the necessary code in arduino to support the touch screen but you would need to add some kind of button, on the touch screen maybe,  to switch between outputs controlled by the screen or outputs controlled by blockly so they don't fight each other...

However, I'm planning to get rid of v1 arduino code and replace it with v2 arduino code which is a totally different code not compatible with LVL1 as it is more like Int.B protocol in v2 version.
But it does not mean you cannot integrate the touch screen to v2 arduino code...  It just might be less obvious as the original LVL1 touch screen mega program would have to be modified a bit.

Both versions are still avail in lego blockly but I encourage every one to start using Int.A v2 and convert their v1 blockly program to v2....

 

Why did I make a Int.A Arduino v2?  It's to try to optimize serial requests... 

Every time we checked inputs in a loop, it was doing a read request to the arduino...  If we check input 6 and 7 in a loop, it was 2 separate read request.
In v2 arduino sends a packet with all input states (even output states).
Blockly app read continuously in a separate internal routine like Interface B.
In v1, LVL1 version is using TEXT commands and it takes few bytes per command.  (1 byte for each characters)
v2 now uses only byte opCode.  Like interface B.

I'm not sure it is realy faster and efficient but it feels like it is ;-)

 

 

 

Posted
5 hours ago, Bliss said:

I'm not sure it is realy faster and efficient but it feels like it is ;-)

I have the same feeling, but did not yet stress test. I shall do that over the weekend - if you leave V1 up until then, that is.

Also, I like your V2 Arduino code much better than the V1 version.

Regards
Thorsten

Posted (edited)
17 hours ago, Bliss said:

Correct me if I'm wrong but your display + mega setup is for testing "Interface A" inputs and outputs only, there is no lego project program running in this setup?

This is the setup we see on LVL1 website right?

YES, as is just manual. NO LEGO program (although some simple "ladder logic?" like LEGO Lines could be programmed in) and YES same one on LVL1.

Edited by Gunners TekZone
Posted (edited)
On 5/5/2026 at 5:56 AM, Toastie said:

How about using the Arduino "UNO Rev4 WiFi" board with RA4M1 and ESP32-S3 controllers for that purpose? There are also ample of LEDs on the board itself

For Web Socket (WiFi), it might do the job.  However, ESP32 wroom is more mature for this matter.
This new UNO R4 is not cheap though compared to a cheap clone Nano/UNO with a cheap ESP32 Wroom Mini.

On 5/5/2026 at 5:56 AM, Toastie said:

EDIT: And it has BT as well ...

S3 has only BLE.  It does not support bluetooth classic.  BLE is longer range but is much slower than BT Classic.  An HC-05 would be faster.

However I tried ESP32 Wroom BT to see if it was better than HC-05 and I did not see much gain so I abandonned the project but it was working somehow.

 

Edited by Bliss
Posted (edited)
19 hours ago, Bliss said:

For Web Socket (WiFi), it might do the job.  However, ESP32 wroom is more mature for this matter.

19 hours ago, Bliss said:

S3 has only BLE.  It does not support bluetooth classic.  BLE is longer range but is much slower than BT Classic.  An HC-05 would be faster.

However I tried ESP32 Wroom BT to see if it was better than HC-05 and I did not see much gain so I abandonned the project but it was working somehow.

Ah, I see! Thanks for the clarification! And yes, it really is expensive.

For controlling my PoweredUp stuff, I am using the ESP32 Vroom Devkit 1 boards along with the LEGOino software Cornelius Munz has developed earlier; would that do the trick for the Wi-Fi application you are working on? If not, can you suggest appropriate ESP32 boards? There are soo many ...

Best wishes,
Thorsten

 

Edited by Toastie
Posted (edited)
15 hours ago, Toastie said:

ESP32 Vroom Devkit 1 boards

This board should be fine to run the WebSocket Bridge.  I'm using ESP32 MiniKIT myself which I like cause the 4 pins I need are all aligned together.

4000f7bb33b4f3fa619e079742fda1535bab8ba9

Pins used: VCC, GND, IO16 (RX2), IO17(TX2)

 

I re-wrote my github Readme file in https://github.com/BlissCA/lego-blockly/tree/main

I added a folder called WebSocket and inside this folder there is a README_WS.md.
If you are interested to test, please read the README_WS and let me know here if you have any questions. 

 

Latest version of Lego Blockly is: Version: 2026-05-07-1412

Please, use Ctrl-Shift R to make sure it loads to latest version.

 

PLEASE NOTE:  When you connect to Intertface A using WebSocket, the javascript uses "https://127.0.0.1:7890" local URL to discover any ESP32 WS Bridge alive.
Since we use self signed certificate, you will see a small message at the top (In chrome, it is at the right of the address bar) that says this is not Secure.  This is unarmful and will not stop Blockly to run.

 

Edited by Bliss
Posted (edited)

I added Input Counter blocks in Lego Int. A v2 and Lego Int. B as well.

These are raising edge counter (0->1 only).  These counter are done in the drive code of the devices so it is very fast and sync.

The generic counter block is still ok but for device inputs, it might miss a pulse sometime because it is not synchronous with the input packet reading...

chrome_5slRSOZdhW.png

It looks like the rotation counter but the rotation counter counts both edge 0->1 and 1->0.

 

Example of use with a Wait Until block:
chrome_BGz6HMhMdP.png

Or with the use of a user defined function with output called Count1 that has an input value variable "Preset" and that output true when preset count is reached. 
This allow to see the accumulated value incrementing live while waiting to reach the preset:

chrome_DlREK4TWYG.png

Edited by Bliss
Posted

Hi !

I had the two last pages to read and a question: in the end, won't you make a project to mimic interface-B but via WiFi or Bluetooth? Chance on me : I'm really really bad at coding, if i wasn't it will already be on my to-do list. :laugh_hard:

(There is so many damaged 9v cables on the wild where you can take the connectos, such a project look realistic)

Posted
46 minutes ago, Wapata said:

in the end, won't you make a project to mimic interface-B but via WiFi or Bluetooth?

Hello,

not sure what you mean: Interface B is a serial device; I have it connected via Bluetooth to my computer and use @Bliss' LBlockly for programming.

Does "mimicking" mean that you want lets say an Arduino or any other microcontroller board replacing Interface B and have access to it via BT?

Best
Thorsten

Posted
9 hours ago, Wapata said:

won't you make a project to mimic interface-B but via WiFi or Bluetooth?

Mimic interface-B, I thing I already talked about it when thinking on how to implement interface-A but no, it is not on my to-do list for the moment.

I do not see the gain for such a project since you need to make hardware modifications (for example, remplacing hardware inside a dead interface B, could be the controller only or maybe also the H-Bridge etc...).

For now, the Int.B (A real functional one) is working wireless with BT both on PC and Android with a HC-05 or alike with Lego Blockly.

For the Wi-Fi, I could do an ESP32 bridge for Int.B as I did for Interface A (It's on my list but not a priority for the moment) but it's quite another setup and you need to use nginx on you blockly machine and it does not work on android device...

You still have the Int.B ESP32 Micropython project I did and presented in another thread on this forum that make Int.B fully Autonomous like an RCX/EV3 brick.  
It's a Int.B driver module working on ESP32 using micropython and you can put your own program in the esp32 along with other modules like MQTT and control your Int.B with your phone and or your smart home using MQTT...
BUT, the user must make his program in MicroPython.  No blockly ... YET...

 

Posted (edited)

Hello all,

Please update to version: Version: 2026-05-14-0204
If it does not update automatically, you can use shift-ctrl-R and if it resists, delete the cache of your browser.

I fixed a bug for the Wait Until Time block.  I have broken this a little while ago and just found out about it while testing the new LPF2 device...

I'm actively working on the implementation of LPF2 (Powered UP, Boost, Technic Hub etc...)

In this version you will find a very basic LPF2 driver.  Only motor blocks are there but will add more blocks shortly.
There is a lot to do...  It is a big one.

I have only one device for testing and this is the Lego Boost (Lego Move Hub).  But I might buy a technic hub as it seems to be still available at Lego Store.  I would like to get a Robot Inventor or Spike Prime set but those are so expensive these days...

I hope some of you will have time to test LPF2.

In the Boost, there are virual ports that are automatically defined to operate both Motor AB (or CD) synchronously.
Some LPF2 devices do not support combined motors and some other hubs support combined motors but you have to create the virtual ports and it could be any mixed pair of ports..
I will add support later for this.

Next step is to add some sensors (In the actual version, there is only the motor tacho feedback...)

Please note: When you connect to the LPF2 device, it will connect fast enough but it takes roughly 20 sec for the device to be really ready as there are many request at the beginning to built the portInfo table...

What are the LPF2 motor blocks:

  • motor power: Run the motor at a certain power -100 to -1 for CCW, 1 to 100 for CW, 0 = Stop Float and 127 = Stop Brake.
  • motor stop: stop motor with brake type option: 0=float, >0 = Brake. (Same as above with power 0 or 127, but added for convenience)
  • motor speed: run motor at constant speed.  If you try to slow it down, it will fight to keep constant speed until it reached the adjustable max power .  Speed = -100 to + 100, 0 will brake and HOLD.  You must use motor stop block to stop without hold.
  • motor set rotation count:  this is to reset the motor built in encoder value.
  • motor angle: run motor up to a certain relative position in degree.  You can use negative or positive angle.
  • motor position: run motor up to a certain absolute position.
  • motor run for time: run the motor for the specified time in ms at the specified speed.

Note that for the angle and position block, it does not stop exactly at the specified position specially if the speed is high...  But at lower speed, it is precised enough.
There is a feature I did not implement but I will at least try it, it's the user accel / decel profile that is used for all motor commands that could maybe help to achieve more precision. 
Motor speed, angle and position blocks work only for motors with internal tacho.
 

Edited by Bliss
Posted
3 hours ago, Bliss said:

In this version you will find a very basic LPF2 driver.  Only motor blocks are there but will add more blocks shortly.
There is a lot to do...  It a big one.

@Bliss

this will develop into the most powerful software for LEGO's interfaces and PBricks >ever<. Just imagining that I can use a PUp sensor on a simple hub, let's say the 2-port City hub, or the even more powerful but rather cheap 4-port Technic hub to control a 4.5V output on a Technic "machine" is breathtakingly nice! Instead of using two Int.A's to get 4 inputs, I could use a Technic hub and one Int.A ... Wow - this is crazy and opens uncountable options for new routes into machine control - using LEGO technology from 1986 to 2026 - and counting!

I never expected something even remotely happening.

Thank you very much!!!

All the best
Thorsten   

   

Posted
4 hours ago, Toastie said:

Just imagining that I can use a PUp sensor on a simple hub, let's say the 2-port City hub, or the even more powerful but rather cheap 4-port Technic hub to control a 4.5V output on a Technic "machine" is breathtakingly nice!

I don't want to ruin your enjoyment, but those battery operated BLE PUp devices autonomy is very disappointing.
The motors look great, but they are power hungry...  (Compared to an old 9v geared motor...) and BLE takes on the batteries too...

I put 6x AAA batteries in my Boost, tested motors, sensors once in a while for a couple minutes, and within few days, batteries were drained.
Apparently, the PUp hub for train is even worst.  Like 30 min train running time max.

With a wired Int.B, I can leave it powered 24/7...

I ended up doing the power cord hack on the Boost (without damaging the hub)...

I've seen some rechargeable battery pack exist for more recent LPF2 devices? but not sure which ones...

Posted
17 minutes ago, Bliss said:

Apparently, the PUp hub for train is even worst.  Like 30 min train running time max.

With a wired Int.B, I can leave it powered 24/7...

I ended up doing the power cord hack on the Boost (without damaging the hub)...

Absolutely true, this is and has been a disaster.

However, the way around that is doing your hack. All my builds are essentially locally installed/fixed machines doing things either on my train layout or on shelves etc. So all the PUp devices (as well as RCX' - this is why I only have the 1.0 version) have permanent power I can switch on/off with wireless remotes (Simple 433MHz stuff, ZigBee stuff, Shelly stuff.

When it comes to train layouts, I am using the old 9V rail system, feed that permanently with 15V DC and tap into this "power line" going around my office for all the controlling devices (RCX, Scout, MicroScout, NXT, Int.A, Int.B, 8485 ...)

A number of my trains are PUp operated; here I use the 9V train motors as a) power pickups from the rails and b) propelling units ;) The rail power goes to a rechargeable battery, here the luxury version is LEGO's 8878 - but this has become superexpensive. Here is what I did - it still works as on day one:

It works with other LiPo's as well though. On my "ICE" type train, based on set's 7987 RC module, I am trickle-charging the six NiMH batteries by bringing the 15V DC rail voltage down. This worked for more than a decade now. This trickle charging works also in other PBricks.

But yes, PoweredUP is power hungry ... 

Nevertheless: I remain super-excited about your LBlockly!!!

Best wishes
Thorsten

Posted

Sorry been awayhor a bit sorting out holiday and my lego mindstorms/Spybots.

I see VLL is now added, how do I use it or what is needed?

 

Posted (edited)
4 hours ago, AJB2K3 said:

Sorry been awayhor a bit sorting out holiday and my lego mindstorms/Spybots.

I see VLL is now added, how do I use it or what is needed?

 

Hello @AJB2K3,

Please have a look to the following post (with pictures) for all instructions:
 

You need a USB to Serial adapter that has the DTR pin, a LED (I tested with Bright White LED) and a resistor.

I personnaly preferred and tested with a USB to TTL module (FTDI) like shown in the pics.

Also, I only tested with the Lego Code Pilot brick.

For the Code Pilot and Scout, the codes are listed in the ScoutSDK document (Link provided in the post I linked above).

I have no idea how it can be used with SpyBots...
REMEMBER, Lego Blockly can only SEND VLL, not receive.

Let me know how it works for you.

 

Edited by Bliss
Posted (edited)

Lego-Blockly LPF2 driver:

I added some Sensors for the LPF2 (toolbox, LPF2 ->  Input)

Please update to version: Version: 2026-05-14-2320

I tested with the sensors that comes with the BOOST set and also WeDo 2.0.

Note that the WeDo 2.0 hub does not work with LPF2 last specification and I will do a separate driver for the WeDo 2.0 eventually, but its sensors/motor work well with LPF2 Blockly driver.

 

EDIT 2026-05-15

In version Version: 2026-05-15-1106

The motor command angle, pos and time will wait until completion before going to next block.

If you want your code to do something else while those commands execute, just put those command in a separate task

chrome_FxWnKKysfq.png

 

EDIT 2026-05-16

In version Version: 2026-05-16-0301

The LPF2 device will be ready faster.  There was a duplicate in the port information requests that made tons of requests at the beginning and I also keep a hard coded "dictionary" of the known ioType I have in hand (Boost set internal and external sensors and motors, WeDo 2.0 sensors and motors).  So the code does not request "mode" information for known i/o Types.

I also got a mindstorms robot inventor set but the firmware does not use the LPF2 BLE.  It's using some BT like a HC-05 that makes com ports at the PC.
However, I flashed the spike firmware in the hub, and now it is BLE but it uses a different protocol than LPF2...
Apparantly I would have to use the PyBrick firmware to make it LPF2 compatible...

I also tried to connect the Mindstorm inventor motors to Boost hub but the Boost firmware does not support the high resolution encoder of those motor.  I can only use the motor Power command with those motors on the boost...

The Inventor set Color sensor and also Distance sensor do not work with the boost hub tested with the Pup app...

I will try later to flash the Inventor with the PyBrick fw...  to be continued.

Edited by Bliss
Posted (edited)

@Bliss

I am doing a bit of testing (will get much more elaborate in the coming weeks :innocent2:)

LPF2 wise (LWP3.0) I have 2-port City and 4-port Technic hubs. As I said, I really find it so powerful to easily connect different generations of LEGO devices to one programming environment.

  • BLE connections seem to be rock solid (I know, you don't like these devices ;) regardless what else I do in parallel on my computer.
  • USB V2 connections to the Arduino interface are as well rock solid. 
  • BT V2 connections are not: If I don't anything else on my laptop than running LBlockly, they are fairly stable. However, running e.g., a browser (Firefox) almost immediately leads to a lost connection error.

This is all fine and well. Just to get you some data points.

I am always using the off-line version of Blockly.

One more: The Technic hub has an internal tilt sensor, which can be quite useful.

All the best
Thorsten

Edited by Toastie
Posted (edited)
1 hour ago, Toastie said:

BT V2 connections are not

I guess you mean by USB V2 and BT V2, using the serial Interface A v2 in blockly.  One with a usb cable directly to arduino (USB) and BT using an HC-05 set at 115kb on pin 0 and 1 (Using voltage divider on Arduino Tx).

I did not test the BT for long I admit.

But remember that if you occasionnaly hide you Lego Blockly app window, this will throttle the app and you will eventually loose connection.

The blockly app must have the focus at all time.

I'm using more the app in the chrome browser in its own Tab and if I switch to another tab, the device will eventually disconnect...

Also, make sure you disable energy saving for your CPU and monitor.

I also use a function in Javascript called wakelock to keep chrome from slowing down after idle time...

I guess for the arduino (int A) the 115kb through HC-05 is not the best option...

 

For the BLE, what did you test exactly?  I'm a bit curious to know if some have tested the LPF2 blocks yet which I tested only with Boost hub and its motors and sensors...
I'm missing data for the other hubs/sensors etc but I should get a technic hub soon.

If you connect to the Technic hub successfully, check the chrome console (press F12).  Then, Check for the unknown ioType that list all the modes available for this sensor.
Technic hub has an IMU sensor I think (Inertia Measurement Unit) which is more complex than the Tilt sensor from boost and WeDo 2.0...
You can copy paste in a code window here what it after the green text in the console window for new sensor IO types.
I can then try to add support for it...  (I think the sensor ioType is 58 (0x3A hex) and there must be many possible modes...

 

Edited by Bliss
Posted
22 minutes ago, Bliss said:

I guess you mean by USB V2 and BT V2, using the serial Interface A v2 in blockly.  One with a usb cable directly to arduino (USB) and BT using an HC-05 set at 115kb on pin 0 and 1 (Using voltage divider on Arduino Tx).

Exactly. One or the other - with my above posted interface, HC05 removed when connected via USB and plugged in when using BT.

What I find interesting is that BLE connections stay live, regardless what I do, as do USB cable wired connections to Arduino V2, but BT connections to Arduino V2 react nervously and disconnect when doing something else in focus. 

Again: It is all fine! 

Best
Thorsten

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...