B4R Tutorial B4R Experiments

Hi,

whilst exploring B4R (as a hobbyist), build experiments in several categories. The experiments also show B4X integration examples.
A few experiments to mention:

Change Log
2018-02-12: (Post #13) openHAB Home Automation Experiments integrating Arduino, XBee, ESP8266.
2017-11-16: (Post #12) L9110 DC Motor Control (B4R,B4J,Node-RED)
2017-11-12: (Post #11) Remote controlled battery powered motorized locomotive Duplo train track with ABMaterial Client
2017-11-09: (Post #10) Remote controlled battery powered motorized locomotive Duplo train track
2017-10-23: (Post #9) Servo Motor Duplo Train Track Switcher 6379 (Serial,B4R,Node-RED)
2017-10-14: (Post #6) Servo Motor Duplo Train Track Switcher 3775 (Serial,B4R,Node-RED)
2017-01-04: (Post #5) ESP8266 to Node-RED using UDP, Make: Project numberX.
2016-12-12: (Post #4) Arduino to Node-RED.
2016-12-07: (Post #3) DHT11 MQTT
2016-07-11: (Post#2) ESP8266: LED Blink, LED Control [MQTT,Node-RED,Raspberry Pi], Servo Control [MQTT,Node-RED,Raspberry Pi]

Enjoy
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update Jul 11, 2016
  • ESP8266: LED Blink, LED Control [MQTT,Node-RED,Raspberry Pi], Servo Control [MQTT,Node-RED,Raspberry Pi]
Notes
Started to explore Node-RED, IBM browser-based visual tool for IoT programming. It runs on the Raspberry Pi OS Raspian (Jessie) latest versions (documentation).
In addition, installed the Node-RED addon node-red-contrib-ui, which introduces number of widgets (nodes) enabling rapid dashboard implementation. Nice UIs must say. See below UI screenshots for the 2 experiments mentioned earlier. The labels are the node names (easier for testing), of course this can be changed to more non-technical.
Communication is handled using MQTT with B4J Non-UI Application MQTT Broker. The Node-RED Nodes for the 2 experiments all use MQTT.
The first impression of Node-RED is very good = looks promising.

LED Control Flow + Browser
upload_2016-7-11_14-31-49.png


Servo Control Flow + Browser
upload_2016-7-11_14-31-16.png
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update Dec 07, 2016
  • DHT11 MQTT (B4R, B4J-MQTT-Broker, B4J-UI-MQTT-Client, B4A-MQTT-Client, Node-RED-Flow, Lazarus-MQTT-Client)

Note
1) In preparation of a LEGO experiment Weather58, build this experiment to publish, in intervals via MQTT, the temperature (Deg C) and humidity (%RH) of a DHT11 sensor (Sunfounder) connected to an ESP8266 (WeMOS D1). The ESP8266 is connected to a WiFi Network and a Raspberry Pi (RPi) USB port (for power supply only). For B4R development, the ESP8266 is connected to a PC.
This experiment shows in principle publishing and subscribing to MQTT topics using B4R, B4J, B4A and other like Mosquitto, Node-RED and Lazarus. It can be used as a base for other solutions.
2) Please note that there are several threads about functioning of the rDHT library with all kind of devices. For this experiment the rDHT v2.00 is doing a good job ;)

upload_2016-12-7_14-14-38.png
 

Attachments

  • b4rhowtoesp8266dht11mqtt.zip
    94.5 KB · Views: 330
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update Dec 12, 2016
  • Experiment Arduino to Node-RED (Attached B4R source & Node-RED flow)
Notes
  • Publish in regular intervals on Node-RED (running on a Raspberry Pi), the temperature (T, Deg C), air pressure (P, mBar), altitude (A, m), polling interval (I, s) and reference altitude (R, m) of a BMP180 sensor connected to an Arduino MEGA. The Arduino is connected via serial line to a Raspberry Pi USB port. Data is send in JSON format and parsed by Node-RED.
  • Open to add more sensors, like photoresistor or to make the Node-RED Dashboard more fancy/longer data storage.
  • Instead of sending a JSON string, there might be better ways like using the B4RSerializer - but found handling JSON in Node-RED is simple.
upload_2016-12-16_10-23-25.png
 

Attachments

  • b4rhowtoarduinonodered.zip
    15.4 KB · Views: 367
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update Jan 04, 2017

  • Experiment: ESP8266 BMP180 UDP communication to Raspberry Pi Node-RED (Attached Source Code)
  • Make Project: NumberX - a device to generate and display a random number within a given range (Attached Source Code).
Notes
numberX
is at prototype stage. The code is ready (B4R 1.8.0), used rLEDControl library for the display. Next step is to build the Lego Case. While developing, new ideas triggered for a next version (potmeter to set the timerinterval, switch to turn the RGBLED off, control via BLE with B4A).


upload_2017-1-4_10-9-36.png

Prototyp Arduino MEGA with the 4 pushbuttons to set the random number range. The RGB LED to light green when ready generating or random color while generating. The very right pushbutton to generate the number while holding down. The two time 4digit 7-segment display.
upload_2017-1-4_10-10-45.png
 

Attachments

  • b4rhowtoesp8266bmp180udp.zip
    8 KB · Views: 370
  • Make_NumberX.zip
    13 KB · Views: 362
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update October 15, 2017

New experiment Servo Motor Duplo Train Track Switcher (Serial,B4R,Node-RED).
The Duplo Train Track Switcher uses a Servo Motor controlled by an Arduino UNO.
The solution will be part of a planned Make Project Duplo Train Control.

Please note, that my website has changed from an own solution using w3.css to a phpBB solution. Makes it much more easier to organize and maintain.
 

Attachments

  • trackswitcher3775.zip
    350.1 KB · Views: 376
Last edited:

inakigarm

Well-Known Member
Licensed User
Longtime User
Please note, that my website has changed from an own solution using w3.css to a phpBB solution. Makes it much more easier to organize and maintain.

Looks nice !

Hope you can import the old Web easily (the new search option could be very useful)

P.d: Have you consider ABMATERIAL for the new Website in front phpBB? (I suppose phpBB have predefined schimes to implement a forum site)
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Looks nice !
Hope you can import the old Web easily (the new search option could be very useful)
P.d: Have you consider ABMATERIAL for the new Website in front phpBB? (I suppose phpBB have predefined schimes to implement a forum site)

Thanks. The import of the old web site is making good progress - good opportunity to clean up old stuff.

In phpBB it is possible to define own styles - a great example is the Raspberry Pi Forum site.

Initially had been thinking of using ABMaterial as a complete solution (it is a great B4J AddOn), but (my opinion) the effort for learning, designing and maintenance is rather high compared to the off the shelve package I selected ... although with ABMaterial nicer look-and-feel sites can be build ... but that was not my intention.

My hosting provider offers several web apps as part of my package = explored several, like Typo3, WordPress, MediaWiki, CMS, Drupal etc. BUT found phpBB most powerful and easy to use - without the need for a steep learning curve - esp having experience in using forums - phpBB has also good reference sites which I looked up.
So far, quite happy with phpBB and lets see what the (near) future brings ...
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Update October 23, 2017

Building upon experiment mentioned post #6, created another solution using a different Duplo Track Switcher to include LEDs for the direction. The solution usede the Lego Duplo Train Track Switcher 6379 (Serial,B4R,Node-RED).
Enhanced controlling via Node-RED. Next is to build a train with a NodeMCU to be controlled either via Node-RED or Android App (B4A) ... also considering ABMaterial as well.

upload_2017-10-23_11-53-22.png
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update November 9, 2017

The fun goes on as continued mentioned Post #9 by building the locomotive.
Remote controlled battery powered motorized locomotive running on Duplo train track (B4R, Node-RED) (Attached Source Code).

Summary: The locomotive prototype has a ESP8266 Node-MCU with DC Motor, Distance Sensor, LED Headlight, Buzzer and is powered by a B4R program which is remote controlled by Node-RED running on a Raspberry Pi. Communication protocol is MQTT (Mosquitto broker, several clients possible).
Loco control functions: move forwards/reverse, set break, set speed, set obstacle distance which stops the loco if reached and the beep goes on.
Notes: Next version, the HC-SR04 will be powered by 5v (more suitable). Will share small video as well. Considering ABMaterial client on Raspberry Pi.

upload_2017-11-9_10-33-53.png
 

Attachments

  • b4rhowtoduploeloco.zip
    448.7 KB · Views: 365
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update November 12, 2017 = Addition to Post #10

Enhanced controlling the Remote controlled battery powered motorized locomotive running on Duplo train track (B4R, Node-RED) by an ABMaterial Client solution.
The solution is written using B4J v5.90 and ABMaterial 4.00. (Source Code see Port #10 - Note that not the full ABMaterial code is included, only the application source).

Screen shot Android Smartphone with LocoControl ABMaterial application in FireFox Browser
upload_2017-11-12_19-57-0.png
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update November 16, 2017

L9110 DC Motor Control (B4R,B4J,Node-RED)

This is an alternative to the previous motor shield solution shared. It uses the cheap L9110 Motor Driver.
The Arduino UNO runs a B4R program controlled by a B4J Application or Node-RED running on the Raspberry Pi. Communication via the serial line with asyncstreams. Details and download in the link above.

Attached: Source Code

Overview: The Node-RED function nodes are connected to a Serial Out Node (now shown on the picture)
upload_2018-8-17_8-42-29.png
 

Attachments

  • b4rhowtoarduinol9110.zip
    245.3 KB · Views: 368
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Update Feb 12, 2018

New experiments related to my openHAB Home Automation Solution in progress.

Philips Hue Dimmable Light Remote Control (openHAB,B4R,MQTT)
To control a Philips Hue dimmable light, via WiFi & MQTT, by using a LCD Keypad Shield on top of an ESP8266 WeMOS D1 (retired).

Attached: Source Code
 

Attachments

  • hueremotecontrollcdkeypad.zip
    3.3 KB · Views: 362
Last edited:
Top