- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am trying to interface an external MCU with EVAL_PASCO2_MINIBOARD using i2c at bus speed of 100 kHz. I tried reading several registers 0x00, 0x01, 0x0F, etc. But with all read attempts I am only getting the return data value 74 (0x4A). Irrespective of the register address the return data is always 74, when the board is powered-up. I don't have any issue in communicating with other i2c peripherals on the same board. Any idea what this might be happening?
I am programming in LUA on a NODEMCU board interface to MINIBOARD, with the following code:
co2_address = 0x28
i2c.setup(self.id, sda, scl, i2c.SLOW); \\SLOW=100kHz
----------------------------------------------------------------------
//Read Function
read_reg = function(self, reg_addr)
i2c.start(self.id)
i2c.address(self.id, co2_address, i2c.TRANSMITTER)
i2c.write(self.id, reg_addr)
i2c.stop(self.id)
i2c.start(self.id)
i2c.address(self.id, co2_address, i2c.RECEIVER)
c=i2c.read(self.id,1)
i2c.stop(self.id)
return c
end
------------------------------------------------------------------------
reg = co2_sensor:read_reg(0, 0x01)
print(string.byte(reg))
-------------------------------------
Console Print = 74
Thanks for any advise.
Solved! Go to Solution.
- Labels:
-
CO2Sensor
-
ispn:32222:1:0
-
l1:314:1:0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
You seem to be reading the register at address 0x00 always and hence you're receiving the return value of 0x4A.
I suggest you to check the following API "reg = co2_sensor:read_reg(0, 0x01)" as it might be reading the register at 0x00 instead of 0x01.
Also, you can follow the application notes Programming_guide_PAS_CO2_evaluationkit and Registermap_description_PASCO2 for more information.
Do let me know your observations.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
You seem to be reading the register at address 0x00 always and hence you're receiving the return value of 0x4A.
I suggest you to check the following API "reg = co2_sensor:read_reg(0, 0x01)" as it might be reading the register at 0x00 instead of 0x01.
Also, you can follow the application notes Programming_guide_PAS_CO2_evaluationkit and Registermap_description_PASCO2 for more information.
Do let me know your observations.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi YashM,
Thanks for your reply. I solved the problem. It was a trivial programming error on my end, not related to the CO2 sensor. Just for your reference, following is my original code and the fixed code.
//reg = co2_sensor:read_reg(0, 0x01); (the first 0 was supposed to be the i2c channel #)
reg = co2_sensor:read_reg(0x01); \\apparently, I don't have to specify the i2c channel #
Thanks