B4X + B4XPages are truly amazing!

Martin Larsen

Active Member
Licensed User
Longtime User
Just wanted to express my fascination with B4X + B4XPages...

I have worked with B4A and B4i and lately also with B4R although that took me some getting used to after years of hacking with Arduino C. But I like B4R more and more, and I will soon share my creation, a Chromecast Radio :cool:

I have not used B4XPages much as my app for the Danish Society for Cat Protection "Kattens Værn" (Android, IOS) was started before B4XPages were introduced.

And I haven't used B4J at all except for a few simple non-gui experiments.

I want to install a thermometer in my greenhouse based on a ESP8266-01 and DHT11. The ESP uses a small B4R program with AsyncStream + B4RSerializator to send the readings to a simple Android app.

Then I wanted to have the app on my desktop as well, using B4J.

Fortunately I was wise enough to create the Android app with B4XPages, and B4X had already created the scaffolding for B4J automatically. So I opened the app in B4J and was curious of how much work and time it would take me to create the B4J version, given that I had almost done zero work on that platform. Wow, was I surprised ...

Steps involved:
  • I opened the designer and pasted all the controls from B4A onto it
  • I added the B4RSerializator module
  • I had to change ONE line of code: an EditText to TextField
I pressed F5, and up came a nice B4J version of my Android app. It literally took me 2 minutes to create the B4J version!

That's cool! B4X + B4XPages are truly amazing.

1615368851049.png
 

thetahsk

Active Member
Licensed User
Longtime User
..and as a next step I would embellish the graphical interface a little bit, e.g. with
 

hatzisn

Well-Known Member
Licensed User
Longtime User
B4X + B4XPages are truly amazing!

I don't agree!

View attachment 109419:)
The hand shows downwards and the smiley is next to the hand. Is this a "just kidding", a "don't like" or one of the Italian gestures that I am not aware of? 😄😄😄
 

Martin Larsen

Active Member
Licensed User
Longtime User
and as a next step I would embellish the graphical interface a little bit, e.g. with

Sure thing! This is just the first baby steps towards my greenhouse thermometer :)

The gauge looks cool, thanks for pointing me in that direction.
 

rabbitBUSH

Well-Known Member
Licensed User
Mmmm having the same experience - now that I have found the time to dive into these new B4X innovations.

[[SORRY : maybe I should have posted this against this message which I didn't see until I looked at this again :
the following should have been here

ESP8266-01 and DHT11
An off / on topic suggestion -> ESP32 (uless, of course, you hae the older version lying around doing nothing) + DHT22 (specs are better)

DHT11
  • Ultra low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 20-80% humidity readings with 5% accuracy
  • Good for 0-50°C temperature readings ±2°C accuracy
  • No more than 1 Hz sampling rate (once every second)
  • Body size 15.5mm x 12mm x 5.5mm
  • 4 pins with 0.1" spacing

DHT22 / AM2302 (Wired version)
  • Low cost
  • 3 to 5V power and I/O
  • 2.5mA max current use during conversion (while requesting data)
  • Good for 0-100% humidity readings with 2-5% accuracy
  • Good for -40 to 80°C temperature readings ±0.5°C accuracy
  • No more than 0.5 Hz sampling rate (once every 2 seconds) [[ <- that doesn't look correct ? shouldn't that be once every 1/2 seconds ?? but that part is immaterial its the above two lines]]
  • Body size 15.1mm x 25mm x 7.7mm
  • 4 pins with 0.1" spacing
 
Last edited:

Martin Larsen

Active Member
Licensed User
Longtime User
I actually both have a DHT22 and ESP12 in my ever growing pile of electronics stuff from Ebay :)

I like the ESP8266-01 for the small form factor. I have always been fond of using the smaller versions; for example, a lot of my projects are built around an Attiny85 with almost no external components. Add 5v to that tiny chip and you can do wonders.

However, there is another reason for not using ESP12 in this project. For some reason, the wifi range is much shorter than the 8266. Maybe I have just been unlucky with my board, I only have that one to test with so I don't know if this a general problem.

The reason I use DHT11 is because I have this shield lying around. But I am probably not going to use it in the final version since the onboard voltage regulator is not very efficient. Even in deep sleep mode, the board uses 2 mA. I am going to feed the 8266 directly from a battery, and then I will use the DHT22 instead.

The sample rate for DHT22 is correct. It is slower than DHT11. But this is not relevant in most use cases.

There is a problem with self-heating of the DHT11. At first I thought it was heated from the shield, so I bent the DHT11 away from the board. That didn't help much, the temperature is still about 4°C too high after a few minutes. It seems to be problem with the sensor itself. I don't know if it's the same with DHT22. However, since the thermometer will be sleeping most of the time and not reading anything from the sensor, the heating should be much less of a problem.
 

Martin Larsen

Active Member
Licensed User
Longtime User
Have you considered the BME280? It's true I2C rather than the complex DHT. I use it in my greenhouse monitoring and control system.

Funny that you mention it now, because last night I switched to BMP280 (BME280's little brother)! I did that mainly because of the much lower power consumption, but also because of the greater accuracy. And I already had it in my assortment box with all kinds of nice Ebay stuff :)

When I bought the BMP280, I didn't know the BME280. I might upgrade to that later.

Does the BMP280 library work with BME280?

Your greenhouse project looks very cool. Which controller do you use?
 
Last edited:

Acuario

Member
Licensed User
Longtime User
I use the library from here: BME280 library If I remember correctly they should both work with the same library, just one will not give you humidity.

I use an ESP8266-12 module as the controller and various I2C connected peripherals for controlling fans, pumps, valves, lights etc.
 

Acuario

Member
Licensed User
Longtime User
No, this is all written outside of the B4X framework. The main c++ code is using the Arduino platform and libraries, the web pages use jquery, javascript and html.
 
Top