B4R Question Requesting library for TMP006...

rbghongade

Active Member
Licensed User
Longtime User
Dear friends,
I tried to make a B4R library using B4Rh2xml.jar for TMP006 Infrared Thermopile Sensor but have failed. Can any one wrap this library? TMP006 is a non contact temperature sensor. The cpp and h files are attached herewith.
 

Attachments

  • Adafruit_TMP006-master.zip
    8.1 KB · Views: 241

rbghongade

Active Member
Licensed User
Longtime User
Already ordered. I was trying to see whether the object is recognised by compiler. Managed to get the short name displayed but since I do not have the sensor yet no ways to verify!
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel,
I received TMP006 yesterday and I was able to read the device with inline c code. Following code works!
B4X:
Sub Process_Globals
       Public Serial1 As Serial
       Public OBJTEMP As Double
    Public DIETEMP As Double
    Private d1pins As D1Pins
   Private timer1 As Timer
  
  
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   timer1.Initialize("timer1_Tick",4000)
   timer1.Enabled=True
   RunNative("setup",Null)

  
End Sub

Sub timer1_tick
   
    RunNative("read",0)
    Log(OBJTEMP)
    Log(DIETEMP)
   
End Sub

#if C
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_TMP006.h"
Adafruit_TMP006 tmp006;
void setup(B4R::Object* o){
tmp006.begin();
tmp006.wake();
}
void read (B4R::Object* o) {
   b4r_main::_objtemp = tmp006.readObjTempC();
   b4r_main::_dietemp = tmp006.readDieTempC();
}

We can solve most of the interfacing problems using inline c code, but I feel that B4R should have less to no dependency on such things like inline c , hence a library wrapper would still be desirable! Just my thoughts!
 
Upvote 0
Top