micro:bit and DS1624 temperature sensor example

The DS1624 consists of two separate functional units: a 256-byte nonvolatile E2 memory and a direct-to-digital temperature sensor.

The nonvolatile memory is made up of 256 bytes of E2 memory. This memory can be used to store any type of information the user wishes. These memory locations are accessed through the 2-wire serial bus.

The direct-to-digital temperature sensor allows the DS1624 to measure the ambient temperature and report the temperature in a 12-bit word with 0.0625°C resolution. The temperature sensor and its related registers are accessed through the 2-wire serial interface. Figure 1 in the full data sheet shows a block diagram of the DS1624.

Features

Reduces Component Count with Integrated Temperature Sensor and Nonvolatile E2 Memory
Measures Temperatures from -55°C to +125°C in 0.0625°C Increments
±0.5°C Accuracy from 0°C to 70°C
256 Bytes of E2 Memory for Storing Information Such as Frequency Compensation Coefficients
No External Components
Easy-to-Use 2-Wire Serial Interface
Temperature is Read as a 12-Bit Value (2-Byte Transfer)
Available in 8-Pin SO and DIP Packages

Connection

Module Microbit
VDD 3v3
Gnd Gnd
SDA P20
SCL P19

Code

I downloaded and imported the following library – https://github.com/bluemurder/DS1624 . I saw errors and had to update the library

The error seen is error: call of overloaded ‘write(int)’ is ambiguous. So it appears that in the library – Wire.write(0xAC); has to be changed to Wire.write((float)0xAC);

DS1624-2.0.0

This is the example so some of the hard graft has already been done for you

#include <DS1624.h>
 
// Sensor presents all address pins connected to ground
DS1624 ds1624(0x00);
 
void setup()
{ 
// Begin serial connection at 9600 baud
Serial.begin(9600);
}
 
void loop()
{
float temperature;
bool valid;
 
// Get current temperature
ds1624.GetTemperature(temperature, valid);
 
// Print it
Serial.println(temperature);
 
// Wait a while
delay(1000);
}

 

Testing

Open the serial monitor and you should see the following

21.62
21.62
21.69
21.69
21.75
21.94
22.62
23.75
24.19

 

Link

https://datasheets.maximintegrated.com/en/ds/DS1624.pdf

CJMCU-1624 DS1624 temperature sensor, high precision digital thermometer with memory function

micro:bit and bmp180 sensor example

This bmp180 from Bosch is the best low-cost sensing solution for measuring barometric pressure and temperature. The sensor is soldered onto a PCB with a 3.3V regulator, I2C level shifter and pull-up resistors on the I2C pins. The BMP180 replaces the BMP085.

Specification

  • Pressure sensing range: 300-1100 hPa (9000m to -500m above sea level)
  • Up to 0.03hPa / 0.25m resolution
  • -40 to +85°C operational range, +-2°C temperature accuracy

Here is a breakout which makes it easy to use the sensor, link at the bottom.

bmp180 module

bmp180 module

 

Wiring and layout

Make the following connections

GND <-> GND

3V3 <-> VIN (or 3Vo)

P19 <-> SCL

P20 <-> SDA

Here is a layout drawn in fritzing

microbit and bmp180

microbit and bmp180

 

Code

You will need the Adafruit BMP085 library for this example, you can either download it or use the library manager in newer Arduino IDEs.

https://github.com/adafruit/Adafruit-BMP085-Library

In this example I am only looking at the temperature and pressure but there are other functions in the library

#include <Wire.h>
#include <Adafruit_BMP085.h>
 
Adafruit_BMP085 bmp;
 
void setup() 
{
  Serial.begin(9600);
  if (!bmp.begin()) 
  {
    Serial.println("Could not find BMP180 or BMP085 sensor at 0x77");
    while (1) {}
  }
}
 
void loop() 
{
  Serial.print("Temperature = ");
  Serial.print(bmp.readTemperature());
  Serial.println(" Celsius");
 
  Serial.print("Pressure = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pascal");
 
 
  Serial.println();
  delay(5000);
}

 

Output

Open the Serial monitor and you should see something like this

Temperature = 20.10 Celsius
Pressure = 100775 Pascal

Temperature = 20.00 Celsius
Pressure = 100773 Pascal

Temperature = 19.90 Celsius
Pressure = 100778 Pascal

Temperature = 25.80 Celsius
Pressure = 100835 Pascal

Links

Free Shipping 1PC BMP180 Digital Barometric Pressure Sensor Board Module compatible with BMP085 For Arduino