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

Does DS18B20 library build for you?

Hi ScruffR, thanks for the reply. I get exactly the same errors when trying to build the DS18B20 library. Cheers, Andrew

Hi all, 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 <iostream>
#include <string>
#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);
}
3 Likes

Good to know :+1:

I had raised the question about the OneWire lib an RPi support behind the scenes, but haven’t had any official response yet - so sorry for not reporting back :blush:

1 Like

Hi how you import your own created library into WEB IDE? I was not able to find way how to use any other library than listed. I am solving the same issue. Training to get up and running two DS18B20 sensors on Raspberry. No working library listed. All have issue during compilation.
Thank you for you help
J.

In order to upload and publish it as a library, you should use CLI particle library create to get the structure of a valid library. Then distribute the files as needed (sources in src , examples in examples/<exampleName> , adapt the respective entries in library.properties (especially set the URL and repository fields to point to your GitHub repo) and then run particle library upload to upload the library as private to test whether all examples can be used as expected and once the tests are successful run particle library publish to make it public.

thank you