The MDBT42Q is the Bluetooth module that we use in Puck.js and Pixl.js devices. You can get it with Espruino installed in two forms:
Just got your MDBT42Q? Take a look here!
Note: We only provide support for MDBT42 modules purchased from us. Other modules don't have a bootloader installed and will need connecting to a programmer tool to have firmware installed.
Check out the section below on Powering - the bare MDBT42Q module and the breakout have slightly different requirements.
Once powered up follow the Getting Started Guide for details on getting the IDE connected wirelessly. You can also use a wired connection if you prefer.
Apply power between any V+
/Vin
and GND
pins. Any voltage between 2.5 and 16 volts
will work - just be careful not to get the polarity wrong! Check the pinout below
for more information on the location of pins.
Just between Vin/GND
and D9/D10
on the bottom edge of the board in the pinout
there are two 2mm-spaced pins. These can be used to fit a JST PHR-2 battery connector
as mentioned on the Battery page - these are very common for LiPo batteries,
which are a good fit for the module.
All you need to get the MDBT42Q working is to apply power between the VDD
and
GND
pins. A 3v non-rechargeable lithium cell is ideal for this (LiPo batteries
have a voltage that is too high and will need the voltage dropping with a diode
or voltage regulator). Check the pinout below for details on where to
connect power.
It is recommended to connect all the GND
pins together (especially when
designing a PCB) but it is not absolutely required - you can boot the
MDBT42Q module with just two wires.
While there are no buttons or LEDs on the bare module, the MDBT42Q build assumes the following (which are connected on the breakout board):
BTN
/BTN1
) between pin D0
and 3.3v. Pulling this high on boot
enables the bootloader.LED
/LED1
) between pin D1
and GND. This is flashes at
boot and also indicates bootloader mode.The breakout board also contains a green LED (LED2) on pin D2
(Espruino 1v99 and earlier require global.LED2=D2
to use this). Since D2
is an analog input it is possible to detect ambient light using analogRead(LED2)
- values range from around 0 (dark) to 0.25 (bright).
Occasionally you may manage to save code to your MDBT42Q that then runs at boot and stops you connecting to it, effectively 'bricking' it.
Recovering it easy:
BTN
/D0
pressed/connected for 5 seconds (or until the LED goes out).reset(true)
into the REPL. This will remove any saved code that is present in the MDBT42Q so even after a reset, your code will not be loaded.First, it's best to check out the Getting Started Guide
Tutorials using MDBT42Q:
Tutorials using Bluetooth LE:
Tutorials using Bluetooth LE and functionality that may not be part of the MDBT42Q module:
Hover the mouse over a pin function for more information. Clicking in a function will tell you how to use it in Espruino.
Note: The nRF52 port has one available I2C, SPI and USART (and infinite software SPI and I2C). Unlike STM32-based Espruino boards, these peripherals can be used on any pin.
The bare MDBT42Q module must be powered with a voltage between 1.7v and 3.6v. You can not connect a LiPo battery to it without a voltage regulator. However the breakout board contains a regulator that will work off of 2.5 to 16 volts.
Certifications:
When power is first applied, the MDBT42Q checks if pin D8
(labelled RX
on the breakout board) is at 3.3v (which will be the
case if it is connected to a Serial port's transmit line). If it is, it initialises
the on-chip UART on D8
(MDBT42Q RX) and D6
(MDBT42Q TX) and puts the Espruino
console (REPL) on it at 9600 baud.
To use it, connect to a 3.3v output USB to TTL converter as follows:
MDBT42Q | USB->TTL converter |
---|---|
GND |
GND |
D8 (RX ) |
TX ( <- PC ) |
D6 (TX ) |
RX ( -> PC ) |
3V |
3.3v (Optional - to run without a battery) |
You can now use the normal Espruino Web IDE, or a serial terminal application at 9600 baud.
When you connect via Bluetooth, the console will automatically move over. To
stop this, execute Serial1.setConsole(true)
to force the console to stay on
Serial1
.
Note: Serial1 is not enabled by default because it requires the high speed oscillator to stay on, which increases power draw a huge amount. If you connect the UART but don't power down and power on the MDBT42Q, you won't get a serial port.
Please see the Firmware Update page for detailed instructions.
Note: If you hold BTN
(or leave D0
connected to VDD
) for too long (> 3 sec),
the MDBT42 will leave bootloader mode and will instead start Espruino without loading
saved code, allowing a hard reset to be performed.
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.