Grove Barometer High Accuracy

MurrayJ

Senior Member
Just trying to get the Grove Barometer High Accuracy working with my Axe300 board in Blockly. I am confused about how to combine the VarA (sign +/-), VarB (integer) and VarC (remainder) into something readable on a Grove lcd module.

i2cbarometer.JPG
 

MurrayJ

Senior Member
Just to add I tried the below program and could not change the readings for the temperature by putting my finger on the sensor. Debug would not change and showed:

VarA 00045 $002D
VarB 00000 $0000
VarC 00001 $0001

All other Variables were zero.

Thermometer1.jpg
 

The bear

Senior Member
Hi MurrayJ,
Its above my pay scale.
Can your program be converted into Picaxe basic?
If so, I'm sure you would get some response.

bear..
 

hippy

Ex-Staff (retired)
If I recall correctly - VarA is a character, "+" or "-" ( 43/$2B or 45/$2D ), VarB the integer part, VarC the part after the decimal point. So to show the result, in PICAXE Basic that would likely be something like -

Code:
ReadGroveI2cHighAccuracySensor( varA, VarB, varC )
Select Case varC
  Case < 10  : SerTxd( varA, #varB, ".00", #varC )
  Case < 100 : SerTxd( varA, #varB, ".0",  #varC )
  Else       : SerTxd( varA, #varB, ".",   #varC )
End Select
I cannot off-hand recall what range of values is in varC. It might be that the msb represents 0.5, next along 0.25 etc.
 

AllyCat

Senior Member
Hi,

Why does the blockly "block" say "temperature". Is that a "pull-down" option (or an input parameter) or are there individual blocks for pressure (and height)? But a response of "-0.1" doesn't look very promising, whatever it's supposed to be reporting.

It might be helpful to post the Basic code produced by Blockly. I would expect to see it reading from I2c address $EC and it might be worth using some test code to check that something is responding to that address.

Cheers, Alan.
 

MurrayJ

Senior Member
This is the converted code from my second post. A simple picaxe basic code to test if the device is working would be helpful.

Code:
symbol varA = w0
symbol varB = w1
symbol varC = w2
;    Temporary word variables used by Grove modules.
symbol grove_w1 = s_w1
symbol grove_w2 = s_w3
symbol grove_w3 = s_w4
symbol grove_w4 = s_w6
symbol grove_w5 = _h_w0
symbol grove_w6 = _h_w1
symbol grove_w7 = _h_w2

    ;Initialise barometer module
symbol grove_barometer_int = grove_w1
symbol grove_barometer_rem = grove_w2
symbol grove_barometer_sign = grove_w3
symbol grove_barometer_cmd = grove_w4
    hi2csetup i2cmaster, 0xEC, i2cslow, i2cbyte
    hi2cout (0x06)


main:
    do
      grove_barometer_cmd = 0x32
      gosub grove_barometer_read
      varA = grove_barometer_sign
      varB = grove_barometer_int
      varC = grove_barometer_rem
      pause 500
      debug
    loop
    stop

grove_barometer_read:
    hi2csetup i2cmaster, 0xEC, i2cslow, i2cbyte
    hi2cout (0x48)
    pause 25
    hi2cin grove_barometer_cmd, (grove_w5, grove_w6, grove_w7)
    grove_w6 = grove_w6 * 256 + grove_w7
    if grove_w5 < 0x80 then
        grove_w5 = grove_w5 & 0x07
        grove_barometer_sign = "+"
    else
        grove_w5 = grove_w5 ^ 0x07 & 0x07
        grove_w6 = -grove_w6
        grove_w5 = grove_w6 max 1 ^ 1 + grove_w5
        grove_barometer_sign = "-"
    end if
        grove_w7 = grove_w6 // 200
        grove_w7 = grove_w5 * 536 + grove_w7 // 200
        grove_w6 = grove_w6 / 8
        grove_w6 = grove_w5 * $2000 + grove_w6 / 25 * 2
        grove_barometer_int = grove_w7 / 100 + grove_w6
        grove_barometer_rem = grove_w7 // 100
    if grove_w5 = 8 then
        grove_barometer_int = 5242
    end if
    return
 

hippy

Ex-Staff (retired)
After
Code:
hi2cin grove_barometer_cmd, (grove_w5, grove_w6, grove_w7)
You could add
Code:
sertxd( #grove_w5, " ", #grove_w6, " ", #grove_w7, cr, lf )
You will probably have to remove the DEBUG command to see its output.

Edited: Added # before grove_w7
 
Last edited:

MurrayJ

Senior Member
I have made the changes and to make it easier I ran the code in Picaxe Editor 5. I wasn't sure what to do after that so I opened the terminal window and got an unchanging output of the following (and the Y had two dots above it -

255 255 Y
 

hippy

Ex-Staff (retired)
Sorry; I missed a # out before grove_w7. I would expect the result to now be "255 255 255" which suggests the sensor is not being read properly.

I would suggest the sensor component on the module is different to the one expected, I2C Device Address is wrong for the module you have, the I2C bus lines are switched over or connected to the wrong pins, the module isn't being powered, or there is some other hardware issue.
 

AllyCat

Senior Member
Hi,

Yes, the 255s probably indicate that the Grove is not responding (successfully) but it may be difficult for anybody to help with this apparently rather uncommon barometer chip.. Unfortunately, the device doesn't appear to have an "identify" command (byte) but it looks as if the Control Registers $0B - $0D (commands $8B - $8D ?) should respond with a byte value of zero, or with a few bits set.

Reading through the Hope Data sheet,, I think perhaps a command is needed to activate the ADC, between the Reset ($06) and Read ($32) commands. From the Data Sheet:

ADC_CVT (010, 3‐bit DSR, 2‐bit CHNL)
This command let the device to convert the sensor output to the digital values with or without compensation depends on the PARA register setting. The 2‐bit channel (CHNL) parameter tells the device the data from which channel(s) shall be converted by the internal ADC. The options are shown below:
00: sensor pressure and temperature channel
10: temperature channel
The 3‐bit DSR defines the decimation rate of the internal digital filter as shown below:
000: DSR = 4096 011: DSR = 512
001: DSR = 2048 100: DSR = 256
010: DSR = 1024 101: DSR = 128
Example: DSR = 256, CHNL = 10, the ADC conversion command code is 0x52.


So perhaps try adding the following (and a PAUSE) after the Soft Reset command:
Code:
    hi2cout (0x52)
Cheers, Alan.
 
Top