-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCF8583 event counter not woking with SoftWire #32
Comments
I don't understand how this is connected to the |
Hello @stevemarple . It's declared as SoftWire Newwire(sdaPin,slcPin); I was using Wire.h earlier but wanted to use timeout facility of SoftWire. But it is not working working with PCF8583. |
You need to call |
Yesterday you posted a comment with your |
Hi Steve, It's behaving irriatically. Sometimes it counts and sometimes it does not. I moved Newwire.setRxBuffer(), Newwire.setTxBuffer(), and Newwire.begin() in Arduino's setup() function. I have two 3 sensors BH1750 for lux and SHT31 and BMP80 for air temperature and Air pressure on same I2C line but on different addresses. I am reading all using Softwire library. I do Newwire.setRxBuffer(), Newwire.setTxBuffer(), and Newwire.begin() once. And then use it every time. |
Are you using repeated starts? What version of |
No. Made sure only one begin. If I remove SHT21 sensor. Event counter works. Using 2.0.9 |
Repeated starts are a feature of the I2C protocol, see https://www.i2c-bus.org/repeated-start-condition. There was an issue in So the event counter does now work with |
PCF8583 when used with Software 2.0.9 alongwith BMP80 and SHT31 on I2C line, gives getCount always as 1666665. When removing BMP80 and SHT31, it gives 0 and works fine. With v2.0.8 , even after removing getCount gives 101 always. It doesn't go to 0. Code is : // SETUP Code
{ pinMode(_sen_pwr,OUTPUT);
sensors.setRainfallMode();
deb.println(rainfall);
delay(1000); if (serializeJson(doc, payload) == 0) { // deb.println(json_pub); void loop() { void readData() char encoded_imei[Base64.encodedLength(strlen(Mod.imei))]; doc["Lw"] = sensors.getLeafWetness(); for(int i=0;i<3;i++){ doc["Wd"] = sensors.getWindDirection(); } PCF8583 code : void PCF8583::setMode(uint8_t address,uint8_t mode) uint8_t PCF8583::getMode() { void PCF8583::setCount(unsigned long count) { unsigned long PCF8583::getCount() { Newwire.beginTransmission(_address); unsigned long count = 0; return count; } // Private methods void PCF8583::icStop() { void PCF8583::icStart() { void PCF8583::setRegister(uint8_t offset, uint8_t icValue) { uint8_t PCF8583::getRegister(uint8_t offset) { uint8_t PCF8583::bcd2byte(uint8_t icValue) { uint8_t PCF8583::byte2bcd(uint8_t icValue) { |
I said previously
In The |
I am trying to use pfc8583 . Board is STM32. It always hangs on setMode function..
Sample code:
uint16_t PCF8583::setMode(uint8_t address,uint8_t mode)
{
_address = address >> 1;
// _wire = theWire;
if(!Newwire.available())
{
Newwire.setRxBuffer(NewwireRxBuffer, sizeof(NewwireRxBuffer));
Newwire.setTimeout(1000);
delay(100);
}
// if(!Newwire.available())
// return 1;
// return 2;
delay(200);
// convert to 7 bit so Wire doesn't choke
uint8_t control = getRegister(LOCATION_CONTROL);
// uint8_t control = getRegister(LOCATION_CONTROL);
control = (control & ~MODE_TEST) | (mode & MODE_TEST);
setRegister(LOCATION_CONTROL, control);
}
It hangs when Calling setMode
The text was updated successfully, but these errors were encountered: