Cannot compile OneWire library examples (Raspberry Pi Zero)

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

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

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.

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.

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
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);

}

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