Does BW16 support one wire communication?

I tried to get temperature value from DS18b20 on my BW16 board. But I can’t get any useful value from sensor. I cannot find any example of using DS18b20 with RTL8720DN on the Internet.

Here is my code:

/********************************************************************/
// First we include the libraries
#include <OneWire.h> 
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino 
#define ONE_WIRE_BUS  2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices  
// (not just Maxim/Dallas temperature ICs) 
OneWire oneWire(ONE_WIRE_BUS); 
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);
/********************************************************************/ 
void setup(void) 
{ 
 // start serial port 
 Serial.begin(115200); 
 Serial.println("Dallas Temperature IC Control Library Demo"); 
 // Start up the library 
 sensors.begin(); 
} 

void loop(void)
{

float temperature; 

sensors.requestTemperatures();  
temperature = sensors.getTempCByIndex(0);  
Serial.println(temperature);
delay(1000);

}

Thanks.

1 Like

Hi @adadadd

Please check out this link @

Please note that, some modifications are to be done to be compatiable with BW16 at line 254 of the OneWire.h file

Thanks for your advice.

But I would like to ask more detail about it. Is that mean I should modify the content inside?

What I have done is:

#define DIRECT_MODE_INPUT(port, mask)   ( *( (volatile uint32_t *)( 0x48014050 + ((uint32_t)port) * 0x400 ) ) &= ~mask )
#define DIRECT_MODE_OUTPUT(port, mask)  ( *( (volatile uint32_t *)( 0x48014000 + ((uint32_t)port) * 0x400 ) ) |=  mask )

Is there any more I should modify?

Thanks.

1 Like

Hi @xidameng 请问RTL8722DM需要做哪些设置才可以使用OneWire通信?我的应用跟题主一样,也是读DS18B20的数据。

Hi I have updated the AmebaOneWire zip lib, you may find it under my repo through this PR

已更新AmebaOneWire zip lib,更新形況可見這個PR

OneWire is supported, you may see this link for a simple demo

Hi @xidameng 已经可以正常通信了,谢谢
image

Hello
I cant get it with my BW16 (RTL8720DN)
I download the @xidameng libs and connecting my ds18b20 to PA27 using a pull up resistor, and no way.
Besides I modified the onwire.h lib with the #define DIRECT_MODE_INPUT(port, mask) tips but no way.
I am using the example code provided inside the AmebaOneWire.zip for test.

Any help, please??