Autonomo One wire Dallas temperature DS18b20

Autonomo one wire example for the ds18b20

#include <OneWire.h>                              //Modified for cortex m0+
#include <DallasTemperature.h>

#define ONE_WIRE_BUS A7                           //Pin for the temp sensor
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Temperature7;                               

void setup() {
  sensors.begin();                                //Start sensor
  SerialUSB.begin(9600);                          //Start Serial

void loop() {
  sensors.requestTemperatures();                  //Request temp
  SerialUSB.println(sensors.getTempCByIndex(0),2);//Print temp on serial line
  delay(1000);                                    //Delay to get some space in between readings

One Wire needs to be altered to include these registries for the cortex m0+

#define PIN_TO_BASEREG(pin)             (0)
#define PIN_TO_BITMASK(pin)             (pin)
#define IO_REG_TYPE unsigned int
#define IO_REG_ASM
#define DIRECT_READ(base, pin)          digitalRead(pin)
#define DIRECT_WRITE_LOW(base, pin)     digitalWrite(pin, LOW)
#define DIRECT_WRITE_HIGH(base, pin)    digitalWrite(pin, HIGH)
#define DIRECT_MODE_INPUT(base, pin)    pinMode(pin,INPUT)
#define DIRECT_MODE_OUTPUT(base, pin)   pinMode(pin,OUTPUT)

I would like to upload the libraries, but this forrum wont allow me.

sensor DS18B20 is a digital sensor and can be connected to analog pin A7

Hi Leptirba,

Analog pins are digital pins with an extra analog to digital converter(ADC) in between.
You can use them as digital pins without any problems.


Hi Erik,

Do you have a Github account? If not, I’d suggest to get one (it’s free).
You can then clone (fork) the OneWire library from Paul Stoffregen (
and add your modifications to it.
And then push to your Github

I do own an Github account, but it hates my laptop and refuses to sync or place folders in any way.
In short, dont have any way to upload anything to it.