WS2812 RGB led ring example on Microbit with Edublocks

This was a WS2812b led ring that I purchased for low cost. There are 12 LEDs in total on this and once you solder 3 cables to the module you are ready to go

Connect Vcc to MIcro:Bit 3.3 volts, Gnd to Gnd and the In to MIcro:Bit 0,

Open Edublocks and create the following


Here is the python code that is created

np = None
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0,12)
while True:
  for red in range(12):
    np[red] = (255,0,0)
  for green in range(12):
    np[green] = (0,255,0)
  for blue in range(12):
    np[blue] = (0,0,255)




A first look at edublocks and the Micro:bit

We will look at an easy to use IDE called edublocks. Here is the blurb

EduBlocks for micro:bit is the latest edition. It’s a drag and drop code editor based on MicroPython. It includes most MicroPython features that allows you to control the onboard micro:bit features as well as external components.

You can see the editor at

We will create a simple example that scrolls a letter depending on the button pressed, in Edublocks this example looks like this

You select a category from the left, for example Basic , find teh block you wish to use and drag the block into the main screen. As you can see these are colour coded.

Once complete you can save this as xml, export the python file and also download a hex file. To program your MIcro:bit, connect it to your computer via a USB cable and it will appear as a drive, copy the hex file and it will be downloaded to the micro:bit. Now press the A and B buttons.

As a matter of interest here is the python code that is exported from the example above

from microbit import *
while True:
  if button_a.is_pressed():
  elif button_b.is_pressed():


A nice easy to use online environment that can export in python

Microbit and TMP175 digital temperature sensor example

The TMP75 and TMP175 devices are digital temperature sensors ideal for NTC and PTC thermistor replacement. The devices offer a typical accuracy of ±1°C without requiring calibration or external component signal conditioning. IC temperature sensors are highly linear and do not require complex calculations or look-up tables to derive the temperature. The on-chip 12-bit ADC offers resolutions down to 0.0625°C. The devices are available in the industry standard LM75 SOIC-8 and MSOP-8 footprint.

The TMP175 and TMP75 feature SMBus, Two-Wire, and I2C interface compatibility. The TMP175 device allows up to 27 devices on one bus. The TMP75 allows up to eight 8 on one bus. The TMP175 and TMP75 both feature an SMBus Alert function.

The TMP175 and TMP75 devices are ideal for extended temperature measurement in a variety of communication, computer, consumer, environmental, industrial, and instrumentation applications.


  • TMP175: 27 Addresses
  • TMP75: 8 Addresses, NIST Traceable
  • Digital Output: SMBus™, Two-Wire™, and I2C
    Interface Compatibility
  • Resolution: 9 to 12 Bits, User-Selectable
  • Accuracy:
    • ±1°C (Typical) from –40°C to 125°C
    • ±2°C (Maximum) from –40°C to 125°C
  • Low Quiescent Current: 50-µA, 0.1-µA Standby
  • Wide Supply Range: 2.7 V to 5.5 V
  • Small 8-Pin MSOP and 8-Pin SOIC Packages



Module Connection Microbit Connection
VCC 3v3
SDA SDA – 20
SCL SCL – 19



#include <Wire.h> 
byte TempHi;              // Variable hold data high byte
byte TempLo;              // Variable hold data low byte
boolean P_N;              // Bit flag for Positive and Negative
unsigned int Decimal;     // Variable hold decimal value
void Cal_Temp();
void setup() 
  Wire.begin();             // join i2c bus (address optional for master) 
                      Main Loop
void loop() 
  const int I2C_address = 0x37;  // I2C write address 
  Wire.write(1);             // Setup configuration register
  Wire.write(0x60);          // 12-bit
  Wire.write((byte)0);             // Setup Pointer Register to 0
  while (1)
    // Read temperature value
    Wire.requestFrom(I2C_address, 2);
    while(Wire.available())          // Checkf for data from slave
      TempHi =;       // Read temperature high byte
      TempLo =;       // Read temperature low byte
    Cal_Temp ();
    // Display temperature
    Serial.print("The temperature is ");
    if (P_N == 0)
    Serial.println(" degree C");
void Cal_Temp()
  if (TempHi&0x80)          // If bit7 of the TempHi is HIGH then the temperature is negative
    P_N = 0;
  else                      // Else the temperature is positive
    P_N = 1;
  TempHi = TempHi & 0x7F;   // Remove sign
  TempLo = TempLo & 0xF0;   // Filter out last nibble
  TempLo = TempLo >>4;      // Shift right 4 times
  Decimal = TempLo;
  Decimal = Decimal * 625;  // Each bit = 0.0625 degree C



Open the serial monitor and you will see something like this

The temperature is 23.5000 degree C
The temperature is 23.5625 degree C
The temperature is 25.3125 degree C
The temperature is 26.7500 degree C
The temperature is 27.8125 degree C
The temperature is 28.5000 degree C
The temperature is 28.9375 degree C
The temperature is 29.3750 degree C
The temperature is 29.6875 degree C
The temperature is 29.9375 degree C
The temperature is 30.1250 degree C
The temperature is 30.3125 degree C



1pcs CJMCU-175 TMP175 27 Address Digital Temperature Sensor

Microbit and MS5611 barometric pressure sensor example

This barometric pressure sensor is optimized for altimeters and variometers with an altitude resolution of 10 cm. The sensor module includes a high linearity pressure sensor and an ultra-low power 24 bit ΔΣ ADC with internal factory calibrated coefficients. It provides a precise digital 24 Bit pressure and temperature value and different operation modes that allow the user to optimize for conversion speed and current consumption. A high resolution temperature output allows the implementation of an altimeter/thermometer function without any additional sensor. The MS5611-01BA can be interfaced to virtually any microcontroller. The communication protocol is simple, without the need of programming internal registers in the device.

Small dimensions of only 5.0 mm x 3.0 mm and a height of only 1.0 mm allow for integration in mobile devices. This new sensor module generation is based on leading MEMS technology and latest benefits from MEAS Switzerland proven experience and know-how in high volume manufacturing of altimeter modules, which have been widely used for over a decade. The sensing principle employed leads to very low hysteresis and high stability of both pressure and temperature signal.



  • High resolution module, 10 cm
  • Fast conversion down to 1 ms
  • Low power, 1 µA (standby < 0.15 µA)
  • QFN package 5.0 x 3.0 x 1.0 mm3
  • Supply voltage 1.8 to 3.6 V
  • Integrated digital pressure sensor (24 bit ΔΣ ADC)
  • Operating range: 10 to 1200 mbar, -40 to +85 °C
  • I2C and SPI interface up to 20 MHz
  • No external components (Internal oscillator)
  • Excellent long term stability




Microbit Module connection
3.3v Vcc
Gnd Gnd
SCL – 19 SCL
SDA – 20 SDA



This example comes from the library

#include <Wire.h>
#include <MS5611.h>
MS5611 ms5611;
double referencePressure;
void setup() 
  // Initialize MS5611 sensor
  Serial.println("Initialize MS5611 Sensor");
    Serial.println("Could not find a valid MS5611 sensor, check wiring!");
  // Get reference pressure for relative altitude
  referencePressure = ms5611.readPressure();
  // Check settings
void checkSettings()
  Serial.print("Oversampling: ");
void loop()
  // Read raw values
  uint32_t rawTemp = ms5611.readRawTemperature();
  uint32_t rawPressure = ms5611.readRawPressure();
  // Read true temperature & Pressure
  double realTemperature = ms5611.readTemperature();
  long realPressure = ms5611.readPressure();
  // Calculate altitude
  float absoluteAltitude = ms5611.getAltitude(realPressure);
  float relativeAltitude = ms5611.getAltitude(realPressure, referencePressure);
  Serial.print(" rawTemp = ");
  Serial.print(", realTemp = ");
  Serial.println(" *C");
  Serial.print(" rawPressure = ");
  Serial.print(", realPressure = ");
  Serial.println(" Pa");
  Serial.print(" absoluteAltitude = ");
  Serial.print(" m, relativeAltitude = ");
  Serial.println(" m");



Open the serial monitor and you will see something like this

rawTemp = 8432348, realTemp = 24.08 *C
rawPressure = 8669780, realPressure = 101367 Pa
absoluteAltitude = -3.50 m, relativeAltitude = -0.17 m

rawTemp = 8476892, realTemp = 25.56 *C
rawPressure = 8654596, realPressure = 101383 Pa
absoluteAltitude = -4.83 m, relativeAltitude = -1.50 m

rawTemp = 8553596, realTemp = 28.06 *C
rawPressure = 8628308, realPressure = 101383 Pa
absoluteAltitude = -4.83 m, relativeAltitude = -1.50 m

rawTemp = 8595300, realTemp = 29.42 *C
rawPressure = 8613628, realPressure = 101374 Pa
absoluteAltitude = -4.08 m, relativeAltitude = -0.75 m



GY-63 MS5611-01BA03 Precision MS5611 Atmospheric Pressure Sensor Module Height Sensor Module