Hi
Does anyone have code or libraries to get this to work on the RPI Pico using micropython?
Thanks
Hi
Does anyone have code or libraries to get this to work on the RPI Pico using micropython?
Thanks
Hi Clint,
I took a look and it seems no-one has ported this one to MicroPython
Though the product wiki gives some simple example code that could be ported over to a Pico easily:
#include "Wire.h"
#define address 0x40
char dtaUart[15];
char dtaLen = 0;
uint8_t Data[100] = {0};
uint8_t buff[100] = {0};
void setup()
{
Serial.begin(9600);
Wire.begin();
}
uint8_t buf[4] = {0};
uint16_t data, data1;
float temp;
float hum;
void loop()
{
readReg(0x00, buf, 4);
data = buf[0] << 8 | buf[1];
data1 = buf[2] << 8 | buf[3];
temp = ((float)data * 165 / 65535.0) - 40.0;
hum = ((float)data1 / 65535.0) * 100;
Serial.print("temp(C):");
Serial.print(temp);
Serial.print("\t");
Serial.print("hum(%RH):");
Serial.println(hum);
delay(500);
}
uint8_t readReg(uint8_t reg, const void* pBuf, size_t size)
{
if (pBuf == NULL) {
Serial.println("pBuf ERROR!! : null pointer");
}
uint8_t * _pBuf = (uint8_t *)pBuf;
Wire.beginTransmission(address);
Wire.write(®, 1);
if ( Wire.endTransmission() != 0) {
return 0;
}
delay(20);
Wire.requestFrom(address, (uint8_t) size);
for (uint16_t i = 0; i < size; i++) {
_pBuf[i] = Wire.read();
}
return size;
}
All our product design team (the ones that would usually consider making a port) are tied up with our PiicoDev and other ranges, but we’re happy to help with any snags you have if you want to give this a crack yourself
Hi Clint,
ChatGPT is pretty handy for porting small libraries like this (GPT4 ought to work if ChatGPT doesn’t).
Thanks James - I will have a crack.
Thanks Liam - I will try ChatGPT