# Cannot compile OneWire library examples (Raspberry Pi Zero)

**URL:** <https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038>\
**Category:** Particle\
**Created:** [29 May 2017 04:00 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038 "2017-05-29T04:00:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew17391](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrew17391/32/565_2.png) [@Andrew17391](https://forum.core-electronics.com.au/u/Andrew17391)\
**Post date:** [29 May 2017 04:00 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038/1 "2017-05-29T04:00:38Z")

</div>

Hi there,

I am trying to test a DS18B20 temperature sensor through the OneWire interface - using Particle and a Raspberry Pi Zero.

I am consistently getting the following compilation errors when trying to use the the OneWire example (“DS18x20\_Temperature”) from the community libraries.

/workspace/lib/OneWire/src/OneWire.h:96:5: error: ‘STM32\_Pin\_Info’ does not name a type  
STM32\_Pin\_Info\* PIN\_MAP = HAL\_Pin\_Map(); // Pointer required for highest access speed  
/workspace/lib/OneWire/src/OneWire.h:99:7: error: ‘PIN\_MAP’ was not declared in this scope  
PIN\_MAP[\_pin].gpio\_peripheral-\>BSRRH = PIN\_MAP[\_pin].gpio\_pin;  
/workspace/lib/OneWire/src/OneWire.h:103:7: error: ‘PIN\_MAP’ was not declared in this scope  
PIN\_MAP[\_pin].gpio\_peripheral-\>BSRRL = PIN\_MAP[\_pin].gpio\_pin;

Physical device : Raspberry Pi Zero W  
Particle-agent version : 0.2.4  
Developing using the web-based IDE on [https://build.particle.io/build](https://build.particle.io/build)

Note that I can successfully include, and use other community libraries (eg. #include “LiquidCrystal\_I2C\_Spark.h”) However I am not having any luck with OneWire.

Any help would be appreciated.

Thanks,  
Andrew

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [29 May 2017 23:11 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038/2 "2017-05-29T23:11:22Z")

</div>

Hi Andrew,

That does look a bit funky, I’d say it’s an issue between the Particle-Raspberry Pi abstraction. The best bet would be to get in touch with Particle directly (unless someone else has previously encountered this issue and can shed some light). The error regarding the STM32 pin suggests that something is crossing over from the original hardware integration of the library to the software mapping (STM32 was the original chipset on the Particle boards).

I’d definitely hit up their forum as well, and then let us know how it goes/what the fix was.

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [31 May 2017 03:27 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038/3 "2017-05-31T03:27:45Z")

</div>

I’ve also taken that for a spin on a Pi we’ve got here and I ran into the exact same thing. After some googling it appears that other people are also running into that issue. I’d say it’s definitely an error in the library mapping, but the Pi does have support for a one wire interface (I’ve done a tutorial on it), so it looks very low level.

---

<div class="post-metadata">

**Author:** ![Andrew17391](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/andrew17391/32/565_2.png) [@Andrew17391](https://forum.core-electronics.com.au/u/Andrew17391)\
**Post date:** [31 May 2017 03:59 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038/4 "2017-05-31T03:59:42Z")

</div>

Hi Sam, I gave up on getting the Particle libraries to work. Instead I  
started from scratch and found some working C++ code that reads the DS18B20  
sensors. [https://github.com/TeraHz/DS18B20](https://github.com/TeraHz/DS18B20)  
I simply created my own versions in Particle and copied the DS18B20.h  
and DS18B20.cpp file contents into the IDE. It was then simply a matter of  
taking snippets from the DS18B20Test.cpp file and adding this into my  
Particle project. Worked first time!

// This #include statement was automatically added by the Particle IDE.  
#include   
#include   
#include "DS18B20.h"  
using namespace std;

char w1\_address[16];

void setup() {

```
Particle.publish("setup", "start", PRIVATE);

strcpy(w1_address, "28-0416947b6dff");

```

}

void loop() {

```
DS18B20 w1Device1 (w1_address);

double tempNow;
tempNow = w1Device1.getTemp();

Particle.publish("loop", String(tempNow), PRIVATE);

delay(5000);

```

}

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/sam/32/99_2.png) [@Sam](https://forum.core-electronics.com.au/u/Sam)\
**Post date:** [31 May 2017 04:15 UTC](https://forum.core-electronics.com.au/t/cannot-compile-onewire-library-examples-raspberry-pi-zero/1038/5 "2017-05-31T04:15:00Z")

</div>

Nice, looks good, that would have been my next suggestion, definitely a pointer for other people with the same issue.
