Android Question Temprature reading

Alhootti

Active Member
I wanna display temperature reading in my app.
Inside and outside room.
It is possible?
Even through GPS or External Chip.
 

aminoacid

Active Member
Licensed User
Longtime User
Definitely possible. But your first step should be to select a temperature sensor that can be accessed over the network or via a WLAN. I don't know what is available in the country you are in but Amazon has several.
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User

Well, you need to find out which one can be accessed via Bluetooth or WiFi and see if they provide documentation. If not you will need to do some eavesdropping into the output of the sensor. Alternatively, if you have some hardware knowledge you can interface to sensors from Adafruit and Sparkfun where they provide you with complete documentation and examples. Either way it's going to require some work on your part.
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Assuming you have a Wlan at home, you can either:
  1. buy sensors which upload data to the manufacturers cloud and you access the cloud via an app or
  2. you could use Arduino + Sensor and send the data to Thingspeak (which is a free cloud) and then use the thingspeak app to get all sensor data
 
Upvote 0

Alhootti

Active Member
I tested above app but it not working im getting these error
Error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
b4ximageview_updateclip (java line: 291)
java.lang.RuntimeException: Method: setClipToOutline not found in: anywheresoftware.b4a.BALayout
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at b4a.example.b4ximageview._updateclip(b4ximageview.java:291)
    at b4a.example.b4ximageview._update(b4ximageview.java:217)
    at b4a.example.b4ximageview._setbitmap(b4ximageview.java:170)
    at b4a.example.b4xmainpage._setimages(b4xmainpage.java:353)
    at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:72)
    at b4a.example.b4xmainpage.callSub(b4xmainpage.java:380)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1098)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:531)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:868)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:202)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:209)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:719)
    at b4a.example.main._activity_create(main.java:370)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I tested above app but it not working im getting these error
Please, start a new thread, don't mix different issues in the same post

You can start a new thread with a link to that app,
 
Upvote 0

emexes

Expert
Licensed User

This looks good:

https://www.amazon.ae/Temperature-Humidity-Bluetooth-Wireless-Moisture/dp/B0D2Y5HF7H/ref=sr_1_5

They are available from multiple sellers, and have a display thus they're useful even standalone.

If was me: I'd buy one to try it out, make sure it works with the intended Android Bluetooth device(s). It talks about storing readings, so perhaps the Bluetooth interfacing is more complicated than just reading a characteristic. Assuming that all works ok, then buy some more for outside or other rooms or whatever.

I'm not certain how well they'd work inside of a refrigerator or freezer, but it doesn't sound those are part of your project anyway, so... no worries. Interesting to try, though: be great if you could share your findings if you do, because I just noticed a few days ago that my kitchen fridge might be playing up, so I could be following in your footsteps soon.
 
Upvote 0

emexes

Expert
Licensed User
is there any code in B4A platform to deal with it ?

If you mean: for that particular Bluetooth sensor model, then: probably not.

I would expect that the live temperature reading would just be a standard read of a standard BLE GATT characteristic, which can be tested (no programming required) using nRF Connect app BLE utility program and then, presuming that it works there, coded up using the B4A "internal" BLE2 library.
 
Upvote 0

emexes

Expert
Licensed User
Could you please provide my by small example for that.

Not yet, but I've just ordered one of those devices, says 9 day delivery, and I'll write you a small example the weekend after that.

In the meantime, if you get your hands on a BLE temperature device before I do, then start with:

https://www.b4x.com/android/forum/threads/ble-nrf-connect-pre-ble2-problem-solving.145070



The exact item ordered is: https://www.aliexpress.com/item/1005006837196415.html

Model TH05, Wireless Type: Bluetooth 5.0 BLE
 
Upvote 0

emexes

Expert
Licensed User
Model TH05, Wireless Type: Bluetooth 5.0 BLE

Well, the delivery got lost in the mail so I ordered some more and that second batch turned up.

But you're right, these doesn't seem to be a straightforward GATT interface with temperatures that are directly readable by nRF Connect. It's like Tuya has encrypted the process so that the devices only work with their proprietary software. That might explain why there is a(t least one) GitHub project for replacement firmware for the device.

When I've got more time I'll have another poke around, but don't hold your breath, might well be Christmas-New Year.

In the meantime, the devices are still useful as basic digital thermometers, even without the Bluetooth connection.
 
Last edited:
Upvote 0
Top